-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Logging: Make node name consistent in logger #31588
Changes from 4 commits
6ebceb5
88db037
29074b2
76a6607
41e7be4
c924ade
a98de4a
c428a08
d1b1999
25c1b3e
048eccf
75a10e2
59f56ed
7122d0f
eaea37b
64505e9
f1ba7c5
1fb555f
9dbd4be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
appender.console.type = Console | ||
appender.console.name = console | ||
appender.console.layout.type = PatternLayout | ||
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%m%n | ||
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker %m%n | ||
|
||
rootLogger.level = info | ||
rootLogger.appenderRef.console.ref = console |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ public void testInvalidValue() { | |
final boolean enforceLimits = randomBoolean(); | ||
final IllegalArgumentException e = expectThrows( | ||
IllegalArgumentException.class, | ||
() -> BootstrapChecks.check(new BootstrapContext(Settings.EMPTY, null), enforceLimits, emptyList(), "testInvalidValue")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In production code this used to be the node name but it is no longer required because the node name is already part of the logger. |
||
() -> BootstrapChecks.check(new BootstrapContext(Settings.EMPTY, null), enforceLimits, emptyList())); | ||
final Matcher<String> matcher = containsString( | ||
"[es.enforce.bootstrap.checks] must be [true] but was [" + value + "]"); | ||
assertThat(e, hasToString(matcher)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,13 @@ public static Logger getLogger(String prefix, Class<?> clazz) { | |
} | ||
|
||
public static Logger getLogger(String prefix, Logger logger) { | ||
if (prefix == null || prefix.length() == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of our loggers don't actually have a prefix so I felt like we shouldn't wrap the default logger in that case. It is one less object to allocate and one less synchronized block to execute. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not fail here? These would just be noop calls that could be removed right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now everything gets routed through this method even if there isn't a prefix. How about this: I promise to remove as many of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Can you at least add a comment here that this leniency should/will be removed in the future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! |
||
/* | ||
* In an followup we'll throw an exception in this case directing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I wasn't explicit, I meant create a GH issue and link here. |
||
* folks to LogManger.getLogger. | ||
*/ | ||
return logger; | ||
} | ||
return new PrefixLogger((ExtendedLogger)logger, logger.getName(), prefix); | ||
} | ||
|
||
|
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.
Should this example include
[%node_name]
?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.
I didn't add it because I didn't think the transport client has a node name.