Skip to content

Conversation

@josedonizetti
Copy link
Collaborator

@josedonizetti josedonizetti commented Oct 29, 2025

Changes:

  • New flag format: Changed from --log level:debug to --log level=debug
  • Structured filters: Changed from --log filter:msg=error to --log filter.include.msg=error
  • Level field rename: Changed level: to lvl: in config for consistency
  • Consistent syntax: All log options now use dot notation for hierarchy and equals for values
  • Added constants: Defined all log flag constants for maintainability
  • Updated parsing: Refactored PrepareLogger to handle new structured format
  • Fixed bugs: Resolved issues with multiple filter options not being applied correctly

Examples:

Old flag format (deprecated):

--log level:debug
--log file:/tmp/tracee.log  
--log aggregate:5s
--log filter:msg=error,pkg=core
--log filter-out:lvl=debug

New flag format:

--log level=debug
--log file=/tmp/tracee.log
--log aggregate.enabled=true --log aggregate.flush-interval=5s
--log filters.include.msg=error --log filters.include.pkg=core
--log filters.exclude.lvl=debug

Old config format (deprecated):

log:
  level: debug
  file: /tmp/tracee.log
  filters:
    msg: [foo, bar]
    level: [error]
  filter-out:
    level: [debug]

New config format:

log:
  level: debug
  file: /tmp/tracee.log
  filters:
    include:
      msg:
        - foo
        - bar
      lvl:
        - error
    exclude:
      lvl:
        - debug

Testing: All existing tests updated + comprehensive test coverage for new format.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 56.98324% with 77 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.64%. Comparing base (034cbab) to head (e3b01df).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cmd/flags/logger.go 52.94% 59 Missing and 13 partials ⚠️
cmd/tracee/cmd/root.go 0.00% 3 Missing ⚠️
cmd/tracee/cmd/analyze.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4999      +/-   ##
==========================================
- Coverage   29.72%   29.64%   -0.09%     
==========================================
  Files         234      228       -6     
  Lines       26186    25569     -617     
==========================================
- Hits         7785     7579     -206     
+ Misses      17864    17456     -408     
+ Partials      537      534       -3     
Flag Coverage Δ
unit 29.64% <56.98%> (-0.09%) ⬇️
Files with missing lines Coverage Δ
pkg/cmd/cobra/config.go 89.25% <100.00%> (-0.14%) ⬇️
cmd/tracee/cmd/analyze.go 32.52% <66.66%> (ø)
cmd/tracee/cmd/root.go 0.00% <0.00%> (ø)
pkg/cmd/flags/logger.go 56.82% <52.94%> (-8.44%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josedonizetti josedonizetti force-pushed the newLogFlag branch 2 times, most recently from 26eec40 to 1f7f81c Compare October 30, 2025 18:52
@josedonizetti josedonizetti changed the title New log flag Refactor log flag to new structured Oct 30, 2025
@josedonizetti josedonizetti marked this pull request as ready for review October 30, 2025 19:21
@josedonizetti josedonizetti changed the title Refactor log flag to new structured Refactor log flag to new structure Oct 30, 2025
@yanivagman
Copy link
Collaborator

Overall LGTM, but:

  1. Looks like some commits should be squashed (currently 19 commits for this change, including commits like "fix PR review comments")
  2. Why did we change level to lvl? Don't we want to be explicit with level?

@josedonizetti josedonizetti changed the title Refactor log flag to new structure flag(log): new flag format Nov 2, 2025
Copy link
Collaborator

@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants