-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[5889] Bmoric/mdc manipulation tools [1/2] #7266
Conversation
|
||
@BeforeEach | ||
public void init() { | ||
MDC.clear(); |
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.
MDC.clear(); |
From the MDC docs:
Set the current thread's context map by first clearing any existing map and then copying the map passed as parameter
It shouldn't be necessary to clear.
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.
Done,
CYAN("\u001b[36m"), | ||
WHITE("\u001b[37m"); | ||
|
||
private final String ainsiCode; |
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.
ansi, not ainsi
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.
Done
|
||
@Override | ||
public void close() throws Exception { | ||
MDC.clear(); |
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.
MDC.clear(); |
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.
Done
@@ -4,7 +4,7 @@ | |||
|
|||
<!-- The following patterns mask the string apikey=<string> to apikey=***** to prevent secrets leaking. --> | |||
<Property name="default-pattern">%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %highlight{%p} %C{1.}(%M):%L - %X - %replace{%m}{apikey=[\w\-]*}{apikey=*****}%n</Property> | |||
<Property name="docker-worker-file-pattern">%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %p (%X{job_root}) %C{1}(%M):%L - %replace{%m}{apikey=[\w\-]*}{apikey=*****}%n</Property> | |||
<Property name="docker-worker-file-pattern">%replace{%X{log_source} - }{^ - }{}%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %p (%X{job_root}) %C{1}(%M):%L - %replace{%m}{apikey=[\w\-]*}{apikey=*****}%n</Property> |
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.
Can you add a comment to describe what's happening here? It's kind of difficult to work backwards to figure out what is happening here for someone not super familiar with log4j2.
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.
Done
* </code> | ||
* </pre> | ||
*/ | ||
public class ScopedMDCChange implements AutoCloseable { |
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.
nit: I don't really love the name. Maybe MdcScope
? Definitely not blocking.
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.
Done
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.
nice!
|
||
/** | ||
* This class is an autoClosable class that will add some specific values into the log MDC. When | ||
* being close, it will restore the orginal MDC. It is advise to use it like that: |
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.
* being close, it will restore the orginal MDC. It is advise to use it like that: | |
* being closed, it will restore the original MDC. It is advised to use it like that: |
@@ -4,7 +4,8 @@ | |||
|
|||
<!-- The following patterns mask the string apikey=<string> to apikey=***** to prevent secrets leaking. --> | |||
<Property name="default-pattern">%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %highlight{%p} %C{1.}(%M):%L - %X - %replace{%m}{apikey=[\w\-]*}{apikey=*****}%n</Property> | |||
<Property name="docker-worker-file-pattern">%d{yyyy-MM-dd HH:mm:ss}{GMT+0} %p (%X{job_root}) %C{1}(%M):%L - %replace{%m}{apikey=[\w\-]*}{apikey=*****}%n</Property> | |||
<!-- The following patter log the application name in the beginning of the line, then a regular log line after a - separator. If the application name is not present in the context, the separator is removed --> |
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.
<!-- The following patter log the application name in the beginning of the line, then a regular log line after a - separator. If the application name is not present in the context, the separator is removed --> | |
<!-- The following pattern log the application name in the beginning of the line, then a regular log line after a - separator. If the application name is not present in the context, the separator is removed --> |
This is preparing the tagging of the application that generate a log which is requested in airbytehq#5889 It is adding helper to add a color to the log and safely manipulate the MDC. It is also modifying the log4j pattern. The use of those helper will will be implemented in another PR.
What
This is preparing the tagging of the application that generate a log which is requested in #5889
It is adding helper to add a color to the log and safely manipulate the MDC.
It is also modifiying the log4j pattern.
The use of those helper will will be implemented in another PR.