-
Notifications
You must be signed in to change notification settings - Fork 765
FEAT: patternLayout function name, class name and function alias #1316
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
FEAT: patternLayout function name, class name and function alias #1316
Conversation
Added to patternLayout the following fields: - %M - function name of the caller issuing the logging request - %C - class name of the caller issuing the logging request - %A - function alias of the caller issuing the logging request The first two come from log4j, and use the same field specifiers. When called from method bar of a Class foo: - %M will be replaced with bar - %C will be replaced with Foo - %A will be empty When called from function foo: - %M will be replaced with foo - %C will be empty - %A will be empty %A will be non empty only if the call stack parsed to obtain the values contains string [as foo].
Can you provide a sample for my understanding? 🤗 |
The names come from splitting an input string, that comes from the call stack. This string can be anything between:
Somehing like |
|
I see. So You must be careful to ensure the test cases have good coverage for the various permutations/combinations for the match. |
|
I have added the Test should be good, but please review, I've tried my best to add all possible permutations. |
lamweili
left a comment
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.
Hi, I made a review and have some comments.
Could you please address them? 🙏
|
Anyway, I have also edited your original post with a table for clarity for whoever might be reading in future. |
It's good. No need for changes. |
Co-authored-by: Lam Wei Li <peteriman@mail.com>
6c214ca to
dd3051d
Compare
|
Great to see this merged! Can't wait the see this available on npm so I can use it in my work. |
refactor(#1316): code flow and readability (%C:class, %M:function, %A:alias, %F:full - in order)
|
When are we expecting a release for this? |
|
Target by end of the week. 🤗 |
|
Released in |
Added to patternLayout the following fields:
%M- function name of the caller issuing the logging request%C- class name of the caller issuing the logging request%A- function alias of the caller issuing the logging requestThe first two come from log4j, and use the same field specifiers.
When called from method
barof a classFoo:%Mwill be replaced withbar%Cwill be replaced withFoo%Awill be emptyWhen called from function foo:
%Mwill be replaced with foo%Cwill be empty%Awill be empty%Awill be non empty only if the call stack parsed to obtain the values contains string[as foo].This is the same behaviour as log4j (except for the
%A).Advise: would it make sense to also include something like
%Ffor obtaining the full, unsplitted name?Added table for clarity:
function name
class name
alias name
caller name
foofoofoofoo [as bar]foobarfoo [as bar]Foo.barbarFooFoo.barFoo.bar [as baz]barFoobazFoo.bar [as baz]