This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Sender specific configurations on sender factory #34
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,11 @@ | |
import static biz.paluch.logging.gelf.LogMessageField.NamedLogField.SourceSimpleClassName; | ||
import static biz.paluch.logging.gelf.LogMessageField.NamedLogField.ThreadName; | ||
import static biz.paluch.logging.gelf.LogMessageField.NamedLogField.Time; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import biz.paluch.logging.gelf.DynamicMdcMessageField; | ||
import biz.paluch.logging.gelf.LogMessageField; | ||
import biz.paluch.logging.gelf.MdcGelfMessageAssembler; | ||
|
@@ -73,6 +78,7 @@ public class GelfLogbackAppender extends AppenderBase<ILoggingEvent> implements | |
|
||
protected GelfSender gelfSender; | ||
protected MdcGelfMessageAssembler gelfMessageAssembler; | ||
protected Map<String,Object> senderSpecificProperties = new HashMap<String,Object>(); | ||
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. This field is not used. |
||
|
||
public GelfLogbackAppender() { | ||
gelfMessageAssembler = new MdcGelfMessageAssembler(); | ||
|
@@ -88,7 +94,7 @@ protected void append(ILoggingEvent event) { | |
|
||
try { | ||
if (null == gelfSender) { | ||
gelfSender = GelfSenderFactory.createSender(gelfMessageAssembler, this); | ||
gelfSender = createGelfSender(); | ||
} | ||
|
||
GelfMessage message = createGelfMessage(event); | ||
|
@@ -104,6 +110,11 @@ protected void append(ILoggingEvent event) { | |
reportError("Could not send GELF message: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
protected GelfSender createGelfSender() { | ||
return GelfSenderFactory.createSender(gelfMessageAssembler, this, Collections.EMPTY_MAP); | ||
} | ||
|
||
|
||
public void reportError(String message, Exception exception) { | ||
addError(message, exception); | ||
|
@@ -236,4 +247,8 @@ public boolean isIncludeFullMdc() { | |
public void setIncludeFullMdc(boolean includeFullMdc) { | ||
gelfMessageAssembler.setIncludeFullMdc(includeFullMdc); | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package biz.paluch.logging.gelf.standalone; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import biz.paluch.logging.gelf.intern.ErrorReporter; | ||
import biz.paluch.logging.gelf.intern.GelfSenderConfiguration; | ||
|
||
|
@@ -14,6 +17,7 @@ public class DefaultGelfSenderConfiguration implements GelfSenderConfiguration { | |
private ErrorReporter errorReporter; | ||
private String host; | ||
private int port; | ||
protected Map<String,Object> specificConfigurations = new HashMap<String,Object>(); | ||
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. How about initializing the field with 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. You are right! |
||
|
||
public DefaultGelfSenderConfiguration() { | ||
errorReporter = new Slf4jErrorReporter(); | ||
|
@@ -49,4 +53,17 @@ public void setHost(String host) { | |
public void setPort(int port) { | ||
this.port = port; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getSpecificConfigurations() { | ||
return specificConfigurations; | ||
} | ||
|
||
public void setSpecificConfigurations(Map<String, Object> specificConfigurations) { | ||
this.specificConfigurations = specificConfigurations; | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 field is not used.