build+config: move file logger specific options to logging.file#9233
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
6159f79 to
4f38b2c
Compare
| } | ||
|
|
||
| // SuportedLogCompressor returns whether or not logCompressor is a supported | ||
| // supportedLogCompressor returns whether or not logCompressor is a supported |
There was a problem hiding this comment.
I think these will be used in other projects (e.g. tapd), so we shouldn't un-export them.
|
|
||
| // DefaultMaxLogFiles is the default maximum number of log files to | ||
| // keep. | ||
| DefaultMaxLogFiles = 3 |
There was a problem hiding this comment.
If we touch these, I also feel like it would be a good idea to slightly increase those numbers... Maybe 10 and 20 respectively? It just seems to happen often that users don't have what we need in their logs anymore. Or perhaps we could make it dependent on the log level? If they're running with DBG or higher, increase the numbers? That would probably be out of scope for this PR, just brain storming a bit here.
There was a problem hiding this comment.
cool - updated the defaults in a commit at the end (just to keep this commit a refactor) :)
|
|
||
| cfg.LogConfig.File.MaxLogFiles = cfg.MaxLogFiles | ||
| } | ||
| if cfg.MaxLogFileSize != build.DefaultMaxLogFileSize { |
yyforyongyu
left a comment
There was a problem hiding this comment.
Nice refactor! Just a new nits and should be good to go.
|
|
||
| // FileLoggerConfig extends LoggerConfig with specific log file options. | ||
| // | ||
| //nolint:lll |
There was a problem hiding this comment.
Wanted to comment the same when going through it commit by commit. But longer lines are added to it later, so I think it's still needed.
There was a problem hiding this comment.
oh yeah lol 🙃 will re-add (in correct commit)
| LogDir string `long:"logdir" description:"Directory to log output."` | ||
| MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"` | ||
| MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"` | ||
| MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation). DEPRECATED: use --logging.file.max-files instead"` |
There was a problem hiding this comment.
oh yeah good idea
to config_prod.go in preparation for adding a shared config.go file.
Move all shared code to config.go which has no build tags.
In preparation for extending LoggerConfig with file specific config.
4f38b2c to
f1b900a
Compare
ellemouton
left a comment
There was a problem hiding this comment.
Thanks for the quick reviews ya'll! 🌊
| LogDir string `long:"logdir" description:"Directory to log output."` | ||
| MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"` | ||
| MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"` | ||
| MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation). DEPRECATED: use --logging.file.max-files instead"` |
There was a problem hiding this comment.
oh yeah good idea
|
|
||
| // DefaultMaxLogFiles is the default maximum number of log files to | ||
| // keep. | ||
| DefaultMaxLogFiles = 3 |
There was a problem hiding this comment.
cool - updated the defaults in a commit at the end (just to keep this commit a refactor) :)
This is not a breaking change since the logcompressor config option has not been released yet.
Add deprecation notices but continue to read both.
f1b900a to
e547d21
Compare
This PR:
logcompressoroption tologging.file.compressor(this is not a breaking change since thelogcompressoroption has not yet been included in a release.logging.file.max-file-sizeandlogging.file.max-filesoptions and deprecates the oldmaxlogfilesandmaxlogfilesizeoptions. Both will work for the time being.