Skip to content

[refactor] Implemention of default logger with json output #1643

@knyk-dev

Description

@knyk-dev

Implement DefaultLogger in log/default_logger.go.

  • It needs to implement the Logger interface.
  • We should use RWMutex to ensure the enable switch is thread-safe. Don't use complex channels.
  • For logic, OnBeforeEvent records start time. OnAfterEvent calcs duration, formats LogEntry to map, and prints as JSON string.
  • It should support subscription filtering.
  • Returning nil simply means log all events.

Tests:
Create log/default_logger_test.go. Verify the enabling switch and filter logic. Check if the output is valid JSON with expected fields. Ensure high test coverage and handle edge cases like nil pointers.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions