Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: t0xa/gelfj
base: master
...
head fork: racker/gelfj
compare: graylog_facility_fix
Checking mergeability… Don’t worry, you can still create the pull request.
  • 9 commits
  • 7 files changed
  • 0 commit comments
  • 3 contributors
Commits on Feb 09, 2012
Dan Di Spaltro Use the loggername for a facility 2640c1e
Dan Di Spaltro Make this more generic instead.
Add a new setting to deal with logging the facility as the logger name
b69b11c
Commits on Mar 08, 2012
@Kami Kami If short_message is empty when extracting the stack trace, add stack …
…trace to

the short_message.
33622a9
@Kami Kami Merge remote-tracking branch 'remotes/origin/ckdev' into use_message_…
…if_short_message_is_not_available
6af75d1
@Kami Kami Always truncate shortMessage at the end. 85ce4ce
@Kami Kami Merge pull request #1 from Kami/use_message_if_short_message_is_not_a…
…vailable

Append stack trace to short_message if extractStacktrace is true and shortMessage is empty
a8ed9a9
Commits on Mar 19, 2012
@Kami Kami Bump version to 0.9.2 44405ed
Commits on Mar 24, 2012
Ryan Lewon Fixes for appender for proper facility. 8f07cc6
Commits on Mar 27, 2012
Ryan Lewon Version bump to 0.9.3 f971239
View
4 build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'java'
sourceCompatibility = 1.5
-version = '0.9.1'
+version = '0.9.3'
jar {
manifest {
attributes 'Implementation-Title': 'GELF Java Implementation', 'Implementation-Version': version
@@ -22,4 +22,4 @@ task libDir(dependsOn: configurations.runtime.buildArtifacts, type: Copy) {
into('lib')
from configurations.runtime
from configurations.runtime.allArtifacts.file
-}
+}
View
2  pom.xml
@@ -6,7 +6,7 @@
<groupId>org.graylog2</groupId>
<artifactId>gelfj</artifactId>
- <version>0.9.1-SNAPSHOT</version>
+ <version>0.9.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>gelfj</name>
View
4 src/main/java/org/graylog2/GelfMessageFactory.java
@@ -59,6 +59,10 @@ public static final GelfMessage makeMessage(LoggingEvent event, GelfMessageProvi
gelfMessage.setFacility(provider.getFacility());
}
+ if (provider.getFacilityIsLogger()) {
+ gelfMessage.setFacility(event.getLoggerName());
+ }
+
Map<String, String> fields = provider.getFields();
for (Map.Entry<String, String> entry : fields.entrySet()) {
if (entry.getKey().equals(ORIGIN_HOST_KEY) && gelfMessage.getHost() == null) {
View
1  src/main/java/org/graylog2/GelfMessageProvider.java
@@ -10,4 +10,5 @@
public String getFacility();
public Map<String, String> getFields();
public boolean isAddExtendedInformation();
+ public boolean getFacilityIsLogger();
}
View
9 src/main/java/org/graylog2/log/GelfAppender.java
@@ -37,6 +37,7 @@
private boolean extractStacktrace;
private boolean addExtendedInformation;
private Map<String, String> fields;
+ private boolean facilityIsLogger;
public GelfAppender() {
super();
@@ -104,6 +105,14 @@ public boolean isAddExtendedInformation() {
return addExtendedInformation;
}
+ public void setFacilityIsLogger(boolean facilityIsLogger) {
+ this.facilityIsLogger = facilityIsLogger;
+ }
+
+ public boolean getFacilityIsLogger() {
+ return facilityIsLogger;
+ }
+
public void setAddExtendedInformation(boolean addExtendedInformation) {
this.addExtendedInformation = addExtendedInformation;
}
View
34 src/main/java/org/graylog2/log/GelfConsoleAppender.java
@@ -24,14 +24,16 @@
*
*/
public class GelfConsoleAppender extends ConsoleAppender implements GelfMessageProvider{
-
+
private static String originHost;
private boolean extractStacktrace;
private boolean addExtendedInformation;
private Map<String, String> fields;
-
+ private String facility;
+ private boolean facilityIsLogger;
+
// parent overrides.
-
+
public GelfConsoleAppender() {
super(); //To change body of overridden methods use File | Settings | File Templates.
}
@@ -43,13 +45,13 @@ public GelfConsoleAppender(Layout layout) {
public GelfConsoleAppender(Layout layout, String target) {
super(layout, target); //To change body of overridden methods use File | Settings | File Templates.
}
-
+
// GelfMessageProvider interface.
-
+
public void setAdditionalFields(String additionalFields) {
fields = (Map<String, String>) JSONValue.parse(additionalFields.replaceAll("'", "\""));
}
-
+
public boolean isExtractStacktrace() {
return extractStacktrace;
}
@@ -57,7 +59,7 @@ public boolean isExtractStacktrace() {
public void setExtractStacktrace(boolean extractStacktrace) {
this.extractStacktrace = extractStacktrace;
}
-
+
public boolean isAddExtendedInformation() {
return addExtendedInformation;
}
@@ -65,7 +67,7 @@ public boolean isAddExtendedInformation() {
public void setAddExtendedInformation(boolean addExtendedInformation) {
this.addExtendedInformation = addExtendedInformation;
}
-
+
public String getOriginHost() {
return originHost;
}
@@ -75,7 +77,19 @@ public void setOriginHost(String originHost) {
}
public String getFacility() {
- return null;
+ return facility;
+ }
+
+ public void setFacility(String facility) {
+ this.facility = facility;
+ }
+
+ public void setFacilityIsLogger(boolean facilityIsLogger) {
+ this.facilityIsLogger = facilityIsLogger;
+ }
+
+ public boolean getFacilityIsLogger() {
+ return this.facilityIsLogger;
}
public Map<String, String> getFields() {
@@ -86,7 +100,7 @@ public String getFacility() {
}
// the important parts.
-
+
@Override
protected void subAppend(LoggingEvent event) {
GelfMessage gelf = GelfMessageFactory.makeMessage(event, this);
View
24 src/main/java/org/graylog2/logging/GelfHandler.java
@@ -155,16 +155,8 @@ public void close()
private GelfMessage makeMessage( final LogRecord record )
{
String message = record.getMessage();
-
- final String shortMessage;
- if ( message.length() > MAX_SHORT_MESSAGE_LENGTH )
- {
- shortMessage = message.substring( 0, MAX_SHORT_MESSAGE_LENGTH - 1 );
- }
- else
- {
- shortMessage = message;
- }
+ String shortMessage = new String(message);
+ String stackTrace;
if ( extractStacktrace )
{
@@ -173,10 +165,20 @@ private GelfMessage makeMessage( final LogRecord record )
{
final StringWriter sw = new StringWriter();
thrown.printStackTrace( new PrintWriter( sw ) );
- message += "\n\r" + sw.toString();
+ stackTrace = "\n\r" + sw.toString();
+ message += stackTrace;
+
+ if ( shortMessage.length() == 0 ) {
+ shortMessage += stackTrace;
+ }
}
}
+ if ( shortMessage.length() > MAX_SHORT_MESSAGE_LENGTH )
+ {
+ shortMessage = shortMessage.substring( 0, MAX_SHORT_MESSAGE_LENGTH - 1 );
+ }
+
final GelfMessage gelfMessage =
new GelfMessage( shortMessage,
message,

No commit comments for this range

Something went wrong with that request. Please try again.