-
Notifications
You must be signed in to change notification settings - Fork 155
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
Redirect netty logging to driver logging #437
Conversation
62d3ce7
to
11c1a2f
Compare
…logging system While as netty use `{}` instead of `%s`, we cannot print their log message properly. This PR did not address the conversion between two logging systems.
11c1a2f
to
3dcf9c5
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.
@zhenlineo review completed. Made some comments & suggestions.
@@ -112,7 +112,7 @@ public void close() | |||
{ | |||
if ( closed.compareAndSet( false, true ) ) | |||
{ | |||
log.info( "Driver instance is closing" ); | |||
log.info( "Closing driver instance %s", this ); |
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.
Maybe worth adding info log where driver is created? Otherwise printing of this
does not seem very valuable.
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.
Added another logging in constructor
// builder.append( "[" ).append( record.getSourceClassName() ).append( "." ); | ||
// builder.append( record.getSourceMethodName() ).append( "] - " ); | ||
// builder.append( "[" ).append( record.getLevel() ).append( "] - " ); | ||
// builder.append("[").append(record.getLoggerName()).append("] "); |
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 line be uncommented? Can we remove next 3 commented lines?
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.
This ConsoleLogging class is just for internal use purpose. I would prefer keep these commented there in case if we ever need to print more info to help debug.
import static java.lang.String.format; | ||
|
||
|
||
public class DelegateLogger implements InternalLogger |
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.
How about calling this smth like NettyLogger
?
I think we could also extend io.netty.util.internal.logging.AbstractInternalLogger
to reduce amount of code.
@Override | ||
public String name() | ||
{ | ||
return null; |
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.
This class could take name as another constructor argument and return it here.
/** | ||
* This is the logging factory to delegate netty's logging to our logging system | ||
*/ | ||
public class DelegateLogging extends InternalLoggerFactory |
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.
How about calling this smth like NettyLogging
?
|
||
private String toDriverLoggerFormat( String format ) | ||
{ | ||
return format.replaceAll( "\\{\\}", "%s" ); |
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.
It might be better for performance to precompile pattern with Pattern.compile("\\{\\}")
into a static final
constant and then use it like PATTERN.matcher(format).replaceAll("%s")
.
An example of output on DEBUG (FINE) level using our
ConsoleLogging
: