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):

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

New flag format:

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

Old config format (deprecated):

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

New config format:

logging:
  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 74.81203% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.77%. Comparing base (034cbab) to head (4467f53).
⚠️ Report is 71 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cmd/flags/logging.go 78.45% 41 Missing and 12 partials ⚠️
cmd/tracee/cmd/analyze.go 50.00% 4 Missing ⚠️
cmd/tracee/cmd/root.go 0.00% 4 Missing ⚠️
pkg/cmd/cobra/cobra.go 0.00% 3 Missing ⚠️
pkg/cmd/flags/errors.go 0.00% 2 Missing ⚠️
cmd/tracee/cmd/man.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4999      +/-   ##
==========================================
+ Coverage   29.72%   30.77%   +1.04%     
==========================================
  Files         234      235       +1     
  Lines       26186    26753     +567     
==========================================
+ Hits         7785     8232     +447     
- Misses      17864    17974     +110     
- Partials      537      547      +10     
Flag Coverage Δ
unit 30.77% <74.81%> (+1.04%) ⬆️
Files with missing lines Coverage Δ
pkg/cmd/flags/config.go 86.93% <100.00%> (+86.93%) ⬆️
cmd/tracee/cmd/man.go 40.95% <50.00%> (ø)
pkg/cmd/flags/errors.go 83.33% <0.00%> (-8.98%) ⬇️
pkg/cmd/cobra/cobra.go 0.00% <0.00%> (ø)
cmd/tracee/cmd/analyze.go 32.52% <50.00%> (ø)
cmd/tracee/cmd/root.go 0.00% <0.00%> (ø)
pkg/cmd/flags/logging.go 78.45% <78.45%> (ø)

... and 21 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

@josedonizetti josedonizetti marked this pull request as draft November 25, 2025 03:04
@josedonizetti josedonizetti force-pushed the newLogFlag branch 7 times, most recently from c149859 to e5f7117 Compare November 30, 2025 01:33
@josedonizetti josedonizetti marked this pull request as ready for review November 30, 2025 01:34
@josedonizetti josedonizetti force-pushed the newLogFlag branch 3 times, most recently from 8dc5d51 to df0b45f Compare November 30, 2025 02:55
@josedonizetti
Copy link
Collaborator Author

The documentation error, is because the script doesn't consider renames log.md become logging.md, so it fails, but it is correct.

Copy link
Member

@geyslan geyslan left a comment

Choose a reason for hiding this comment

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

LGTM. Put just some thoughts.

BREAKING CHANGE: add --logging to replace --log
@josedonizetti josedonizetti marked this pull request as draft December 8, 2025 22:48
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