Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement flag parsing for Logging. #4474

Open
9 tasks
Tracked by #4453
ShohamBit opened this issue Jan 9, 2025 · 0 comments
Open
9 tasks
Tracked by #4453

Implement flag parsing for Logging. #4474

ShohamBit opened this issue Jan 9, 2025 · 0 comments

Comments

@ShohamBit
Copy link
Collaborator

ShohamBit commented Jan 9, 2025

Tasks

Preview Give feedback

The following design describes the CLI flag:

--log level=<level>                                 # Set log level (debug, info, warn, error, fatal, panic)
--log file=<path>                                   # Path to the log file
--log aggregation.enabled=<true/false>              # Enable log aggregation
--log aggregation.flush-interval=<interval>          # Aggregation interval (e.g., "5s", "1m", "1h")
--log filters.include.msg=<message>                 # Include messages containing this string (multiple allowed)
--log filters.include.package=<package>             # Include messages from this package (multiple allowed)
--log filters.include.file=<file>                   # Include messages from this file (multiple allowed)
--log filters.include.level=<level>                 # Include messages with this log level or higher (multiple allowed)
--log filters.include.regex=<pattern>               # Include messages matching this regex pattern (multiple allowed)
--log filters.exclude.msg=<message>                 # Exclude messages containing this string (multiple allowed)
--log filters.exclude.package=<package>             # Exclude messages from this package (multiple allowed)
--log filters.exclude.file=<file>                   # Exclude messages from this file (multiple allowed)
--log filters.exclude.level=<level>                 # Exclude messages with this log level (multiple allowed)
--log filters.exclude.regex=<pattern>               # Exclude messages matching this regex pattern (multiple allowed)

The following design describes the config:

log:
  level: info                  # Log level (debug, info, warn, error, fatal, panic) (default: info)
  file: ""                     # Path to the log file (optional, defaults to stdout)
  aggregation:
    enabled: false             # Enable log aggregation (default: false)
    flush-interval: "5s"       # Aggregation interval (e.g., "5s", "1m", "1h") (default: "5s")
  filters:                     # Filter log messages
    include:                   # Include messages based on criteria (optional)
      msg:                     
        - SampleMessage1       # Include messages containing this string
      package:                 
        - package1             # Include messages from this package
      file:                     
        - file1.go             # Include messages from this file
      level:                   
        - warn                 # Include messages with this log level or higher
      regex:
        - ^pattern1           # Include messages matching this regex pattern
    exclude:                   # Exclude messages based on criteria (optional)
      msg:
        - ExcludedMessage1     # Exclude messages containing this string
      package:
        - excludedPackage       # Exclude messages from this package
      file:
        - excludedFile.go       # Exclude messages from this file
      level:
        - debug               # Exclude messages with this log level
      regex:
        - ^excludedPattern     # Exclude messages matching this regex pattern

Implementation Notes:

  • Multiple values: Ensure the implementation correctly handles flags that can accept multiple values (e.g., --log filters.include.msg).
  • Regular expressions: Implement proper parsing and handling of regular expressions in filter flags.
  • Log level validation: Validate log level values to ensure they are valid levels.
  • Aggregation interval parsing: Implement parsing of the flush-interval value to handle different time units (seconds, minutes, hours).
  • Configuration merging: Define how CLI flags and configuration file settings will be merged, with CLI flags potentially overriding config file values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant