-
Notifications
You must be signed in to change notification settings - Fork 77
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
added layout #145
added layout #145
Conversation
💚 CLA has been signed |
❕ Build Aborted
Expand to view the summary
Build stats
Steps errorsExpand to view the steps failures
|
Any news on this PR? It would be very useful to be able to configure the layout to customize the message. |
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.
@dgempiuc this looks like a reasonable functionality addition, thanks.
Note that we won't be able to merge the PR without you signing the Contributor Agreement with your GitHub email.
@felixbarny any reason you see for not adding it?
@@ -54,6 +55,7 @@ public class EcsEncoder extends EncoderBase<ILoggingEvent> { | |||
private boolean includeOrigin; | |||
private final List<AdditionalField> additionalFields = new ArrayList<AdditionalField>(); | |||
private OutputStream os; | |||
protected Layout<ILoggingEvent> layout; |
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.
protected Layout<ILoggingEvent> layout; | |
protected Layout<ILoggingEvent> messageLayout; |
if(layout == null) { | ||
EcsJsonSerializer.serializeFormattedMessage(builder, event.getFormattedMessage()); | ||
} else { | ||
EcsJsonSerializer.serializeFormattedMessage(builder, this.layout.doLayout(event)); |
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.
EcsJsonSerializer.serializeFormattedMessage(builder, this.layout.doLayout(event)); | |
EcsJsonSerializer.serializeFormattedMessage(builder, this.messageLayout.doLayout(event)); |
public Layout<ILoggingEvent> getLayout() { | ||
return this.layout; | ||
} | ||
|
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.
public Layout<ILoggingEvent> getLayout() { | |
return this.layout; | |
} |
No need for a getter
public void setLayout(Layout<ILoggingEvent> layout) { | ||
this.layout = layout; | ||
} |
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.
public void setLayout(Layout<ILoggingEvent> layout) { | |
this.layout = layout; | |
} | |
public void setMessageLayout(Layout<ILoggingEvent> messageLayout) { | |
this.messageLayout = messageLayout; | |
} |
Add a javadoc saying this Layout
will be applied specifically to format the message
field based on the logging event.
No objections but it would be interesting to know about the use case this solves. Why would you want to use a layout within the |
@felixbarny the reason for needing this is covered by #144, basically being able to mask fields in environments where you are handling sensitive data would be good to have in this encoder. If @dgempiuc can't update this PR to get it merged, I would be willing to contribute this as well. |
SGTM. But please be sure to take his commits as the foundation so that he still appears as a co-author of your PR. |
Any news here? @rdifrango |
@maxiking445 Unfortunately, I haven't had time to get back to it...I had it staged and started the proposed changes but haven't yet finished them :( |
@maxiking445 I'm working through the process now to contribute this back. It'll likely be in the form of a new PR with the commits from @dgempiuc as the base. |
Replaced by #220 |
@JonasKunz now that #220 is merged we should go ahead and close this one as it supersedes it. |
layout field added and encode method modified by using the layout while adding the messages to the log file.