Fix logger initialization - #4091
Merged
Merged
Conversation
daipom
force-pushed
the
fix-logger-initialization
branch
from
March 12, 2023 15:27
b37532b to
d2dfdd9
Compare
ashie
self-requested a review
March 13, 2023 05:03
Member
|
Basically it looks good to me. I'm still checking details. |
Contributor
Author
|
Thanks! |
daipom
commented
Mar 14, 2023
Comment on lines
236
to
239
| def reopen! | ||
| @logger.reopen! if @logger | ||
| @out.reopen(@path, "a") if @path && @path != "-" | ||
| nil | ||
| end |
Contributor
Author
There was a problem hiding this comment.
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.
Contributor
Author
|
I'll rebase this to apply |
daipom
force-pushed
the
fix-logger-initialization
branch
from
March 14, 2023 07:12
d2dfdd9 to
879eeec
Compare
abetomo
reviewed
Mar 14, 2023
Contributor
Author
|
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 <fukuda@clear-code.com>
The previous one was almost testing nothing. Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
* 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 <fukuda@clear-code.com>
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 <fukuda@clear-code.com>
Just add `sub_test_case "init logger"`. Other all diff is re-indent. Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
Removed `rotate`, `rotate to max age` tests since `LogTest::test_log_rotates_specified_size_with_logdevio` already exists. Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
daipom
force-pushed
the
fix-logger-initialization
branch
from
March 14, 2023 08:29
879eeec to
a9f5113
Compare
Member
|
Thanks! |
Contributor
Author
|
Thanks for your review! |
daipom
added a commit
to daipom/fluentd
that referenced
this pull request
May 29, 2023
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 <fukuda@clear-code.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
LoggerInitializerDocs 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-ageand--log-rotate-sizeshould be merged intosystem_configinbuild_system_config()fluentd/lib/fluent/supervisor.rb
Lines 1050 to 1061 in ee796ef
However, the log options in
logdirectives are not inFluent::SystemConfig::SYSTEM_CONFIG_PARAMETERS, so--rotate_ageand--rotate_sizeare not merged intosystem_config.So I have no choice but to give special treatment to the rotation parameters.
(I left comments for now)