-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix logger initialization #4091
Conversation
b37532b
to
d2dfdd9
Compare
Basically it looks good to me. I'm still checking details. |
Thanks! |
def reopen! | ||
@logger.reopen! if @logger | ||
@out.reopen(@path, "a") if @path && @path != "-" | ||
nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: The previous logic is meaningless.
This method was not used, and even if this is called, it will do nothing.
filedev
is always nil
here.
I'll rebase this to apply |
d2dfdd9
to
879eeec
Compare
All tests on Windows succeed!! Yay!! |
The logic of initializing logger is so difficult and has caused many bugs. This fix simplifies it and prevents logger from outputting some initial log messages with some settings not applied, such as `format`. This fix consists of the following 2 points. * All logger parameters are now set in the first initialization. * Previously, only parameters related to rotation were applied first, but it is preferable to apply all parameters on that point. * Remove LoggerInitializer * This class was a source of confusion because its role is difficult to understand. TODO: Fix tests. Signed-off-by: Daijiro Fukuda <[email protected]>
The previous one was almost testing nothing. Signed-off-by: Daijiro Fukuda <[email protected]>
Signed-off-by: Daijiro Fukuda <[email protected]>
* Overwritten `DamonLogger#level=` is not used now, since Fluentd doesn't use ServerEngine's reloading feature. * The parameters about rotate is in `Fluent::LogDeviceIO`, not in `ServerEngine::DaemonLogger`. Signed-off-by: Daijiro Fukuda <[email protected]>
This test should be fixed more..., but it should be done in another branch. Currently, `TestSystemConfig` tests some Supervisor logic too. This is not good, and it should be moved to SupervisorTest. We should remove `FakeSupervisor` class. Signed-off-by: Daijiro Fukuda <[email protected]>
Just add `sub_test_case "init logger"`. Other all diff is re-indent. Signed-off-by: Daijiro Fukuda <[email protected]>
Signed-off-by: Daijiro Fukuda <[email protected]>
Removed `rotate`, `rotate to max age` tests since `LogTest::test_log_rotates_specified_size_with_logdevio` already exists. Signed-off-by: Daijiro Fukuda <[email protected]>
Signed-off-by: Daijiro Fukuda <[email protected]>
879eeec
to
a9f5113
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! |
Thanks for your review! |
Fix a bug of f8b73a5 (fluent#4091). Before that fix, Fluentd can start if rotation is enabled but the log file path is not specified. After that fix, the logger setup starts to fail on Windows. This fix solves it. Signed-off-by: Daijiro Fukuda <[email protected]>
Which issue(s) this PR fixes:
What this PR does / why we need it:
This fix prevents the logger from outputting some initial log messages with some settings not applied, such as
format
. (Please see #4037).In addition, the logic of initializing the logger is so difficult and has caused many bugs.
This fix simplifies it.
This fix consists of the following points.
LoggerInitializer
Docs Changes:
Not needed.
Release Note:
Fix bug that the logger outputs some initial log messages with some settings not applied, such as
format
.Additional Context
Currently, there is a bug in overwriting of
build_system_config()
.It must prefer the options explicitly specified in the command line.
So
--log-rotate-age
and--log-rotate-size
should be merged intosystem_config
inbuild_system_config()
fluentd/lib/fluent/supervisor.rb
Lines 1050 to 1061 in ee796ef
However, the log options in
log
directives are not inFluent::SystemConfig::SYSTEM_CONFIG_PARAMETERS
, so--rotate_age
and--rotate_size
are not merged intosystem_config
.So I have no choice but to give special treatment to the rotation parameters.
(I left comments for now)