Permalink
Browse files

Reformat, added Eclipse formatter config

  • Loading branch information...
1 parent 905e93f commit 16af38306597f033126aef044f221f0e07d65ff1 @mp911de committed Oct 15, 2013
Showing with 1,314 additions and 1,035 deletions.
  1. +279 −0 as7formatter.xml
  2. +3 −3 src/main/java/biz/paluch/logging/RuntimeContainer.java
  3. +5 −1 src/main/java/biz/paluch/logging/StackTraceFilter.java
  4. +5 −5 src/main/java/biz/paluch/logging/gelf/GelfMessageAssembler.java
  5. +50 −52 src/main/java/biz/paluch/logging/gelf/GelfUtil.java
  6. +2 −1 src/main/java/biz/paluch/logging/gelf/LogEvent.java
  7. +40 −45 src/main/java/biz/paluch/logging/gelf/LogMessageField.java
  8. +34 −33 src/main/java/biz/paluch/logging/gelf/MdcGelfMessageAssembler.java
  9. +21 −21 src/main/java/biz/paluch/logging/gelf/MdcMessageField.java
  10. +1 −2 src/main/java/biz/paluch/logging/gelf/MessageField.java
  11. +2 −3 src/main/java/biz/paluch/logging/gelf/PropertyProvider.java
  12. +21 −21 src/main/java/biz/paluch/logging/gelf/StaticMessageField.java
  13. +2 −2 src/main/java/biz/paluch/logging/gelf/intern/GelfMessage.java
  14. +48 −45 src/main/java/biz/paluch/logging/gelf/jboss7/JBoss7GelfLogHandler.java
  15. +3 −4 src/main/java/biz/paluch/logging/gelf/jboss7/JBoss7JulLogEvent.java
  16. +1 −1 src/main/java/biz/paluch/logging/gelf/jboss7/package-info.java
  17. +207 −206 src/main/java/biz/paluch/logging/gelf/jul/GelfLogHandler.java
  18. +139 −140 src/main/java/biz/paluch/logging/gelf/jul/JulLogEvent.java
  19. +2 −2 src/main/java/biz/paluch/logging/gelf/jul/JulPropertyProvider.java
  20. +1 −1 src/main/java/biz/paluch/logging/gelf/jul/package-info.java
  21. +197 −196 src/main/java/biz/paluch/logging/gelf/log4j/GelfLogAppender.java
  22. +4 −5 src/main/java/biz/paluch/logging/gelf/log4j/Log4jLogEvent.java
  23. +2 −2 src/main/java/biz/paluch/logging/gelf/log4j/Log4jVersionChecker.java
  24. +1 −1 src/main/java/biz/paluch/logging/gelf/log4j/package-info.java
  25. +10 −11 src/main/java/biz/paluch/logging/gelf/log4j2/GelfLogAppender.java
  26. +1 −2 src/main/java/biz/paluch/logging/gelf/log4j2/HostnameConverter.java
  27. +3 −4 src/main/java/biz/paluch/logging/gelf/log4j2/Log4j2LogEvent.java
  28. +2 −1 src/main/java/biz/paluch/logging/gelf/log4j2/PatternLogMessageField.java
  29. +1 −1 src/main/java/biz/paluch/logging/gelf/log4j2/package-info.java
  30. +183 −181 src/main/java/biz/paluch/logging/gelf/logback/GelfLogbackAppender.java
  31. +2 −2 src/main/java/biz/paluch/logging/gelf/logback/LogbackLogEvent.java
  32. +1 −1 src/main/java/biz/paluch/logging/gelf/logback/package-info.java
  33. +1 −1 src/main/java/biz/paluch/logging/gelf/package-info.java
  34. +3 −3 src/test/java/biz/paluch/logging/gelf/GelfTestSender.java
  35. +1 −1 src/test/java/biz/paluch/logging/gelf/jboss7/JBoss7GelfLogHandlerTest.java
  36. +9 −10 src/test/java/biz/paluch/logging/gelf/log4j/AbstractGelfLogAppenderTest.java
  37. +2 −1 src/test/java/biz/paluch/logging/gelf/log4j/GelfLogAppenderPropertiesTest.java
  38. +2 −1 src/test/java/biz/paluch/logging/gelf/log4j/GelfLogAppenderXmlTest.java
  39. +7 −6 src/test/java/biz/paluch/logging/gelf/log4j/GelfLogHandlerTest.java
  40. +3 −4 src/test/java/biz/paluch/logging/gelf/log4j2/GelfLogAppenderMinimalTest.java
  41. +6 −7 src/test/java/biz/paluch/logging/gelf/log4j2/GelfLogAppenderTest.java
  42. +2 −2 src/test/java/biz/paluch/logging/gelf/logback/AbstractGelfLogAppenderTest.java
  43. +5 −4 src/test/java/biz/paluch/logging/gelf/logback/GelfLogbackAppenderTest.java
View
Oops, something went wrong.
@@ -1,13 +1,13 @@
package biz.paluch.logging;
-import org.apache.log4j.Logger;
-
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
+import org.apache.log4j.Logger;
+
/**
* Static Details about the runtime container: Hostname (simple/fqdn), Address and timestamp of the first access (time when the
* application was loaded).
@@ -66,7 +66,7 @@ private RuntimeContainer() {
} catch (IOException e) {
LOGGER.info(e.getMessage(), e);
}
-
+
FQDN_HOSTNAME = myFQDNHostName;
HOSTNAME = myHostName;
ADDRESS = myAddress;
@@ -4,7 +4,11 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
/**
* Filtering Facility for Stack-Traces. This is to shorten very long Traces. It leads to a very short Trace containing only the
@@ -1,5 +1,9 @@
package biz.paluch.logging.gelf;
+import biz.paluch.logging.RuntimeContainer;
+import biz.paluch.logging.StackTraceFilter;
+import biz.paluch.logging.gelf.intern.GelfMessage;
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
@@ -8,10 +12,6 @@
import java.util.Date;
import java.util.List;
-import biz.paluch.logging.RuntimeContainer;
-import biz.paluch.logging.StackTraceFilter;
-import biz.paluch.logging.gelf.intern.GelfMessage;
-
/**
* @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
* @since 26.09.13 15:05
@@ -85,7 +85,7 @@ public GelfMessage createGelfMessage(LogEvent logEvent) {
if (value == null) {
continue;
}
-
+
gelfMessage.addField(field.getName(), value);
}
@@ -1,73 +1,71 @@
package biz.paluch.logging.gelf;
-import java.util.Date;
-
-import org.apache.log4j.MDC;
-
import biz.paluch.logging.gelf.intern.GelfMessage;
+import java.util.Date;
+
/**
* @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
* @since 17.09.13 10:47
*/
public class GelfUtil {
- /**
- * Profiling Start in MDC (msec).
- */
- public static final String MDC_REQUEST_START_MS = "profiling.requestStart.millis";
- /**
- * Profiling End in MDC.
- */
- public static final String MDC_REQUEST_END = "profiling.requestEnd";
+ /**
+ * Profiling Start in MDC (msec).
+ */
+ public static final String MDC_REQUEST_START_MS = "profiling.requestStart.millis";
+ /**
+ * Profiling End in MDC.
+ */
+ public static final String MDC_REQUEST_END = "profiling.requestEnd";
- /**
- * Profiling Duration in MDC.
- */
- public static final String MDC_REQUEST_DURATION = "profiling.requestDuration";
+ /**
+ * Profiling Duration in MDC.
+ */
+ public static final String MDC_REQUEST_DURATION = "profiling.requestDuration";
- private GelfUtil() {
+ private GelfUtil() {
- }
+ }
- public static void addMdcProfiling(LogEvent logEvent, GelfMessage gelfMessage) {
- Object requestStartMs = logEvent.getMdc(MDC_REQUEST_START_MS);
- long timestamp = -1;
+ public static void addMdcProfiling(LogEvent logEvent, GelfMessage gelfMessage) {
+ Object requestStartMs = logEvent.getMdc(MDC_REQUEST_START_MS);
+ long timestamp = -1;
- if (requestStartMs instanceof Long) {
- timestamp = ((Long) requestStartMs).longValue();
- }
+ if (requestStartMs instanceof Long) {
+ timestamp = ((Long) requestStartMs).longValue();
+ }
- if (timestamp == -1 && requestStartMs instanceof String) {
- String requestStartMsString = (String) requestStartMs;
- if (requestStartMsString.length() == 0) {
- return;
- }
- timestamp = Long.parseLong(requestStartMsString);
- } else {
- return;
- }
+ if (timestamp == -1 && requestStartMs instanceof String) {
+ String requestStartMsString = (String) requestStartMs;
+ if (requestStartMsString.length() == 0) {
+ return;
+ }
+ timestamp = Long.parseLong(requestStartMsString);
+ } else {
+ return;
+ }
- long now = System.currentTimeMillis();
- long duration = now - timestamp;
+ long now = System.currentTimeMillis();
+ long duration = now - timestamp;
- String durationText;
+ String durationText;
- if (duration > 10000) {
- duration = duration / 1000;
- durationText = duration + "sec";
- } else {
- durationText = duration + "ms";
- }
- gelfMessage.addField(MDC_REQUEST_DURATION, durationText);
- gelfMessage.addField(MDC_REQUEST_END, new Date(now).toString());
- }
+ if (duration > 10000) {
+ duration = duration / 1000;
+ durationText = duration + "sec";
+ } else {
+ durationText = duration + "ms";
+ }
+ gelfMessage.addField(MDC_REQUEST_DURATION, durationText);
+ gelfMessage.addField(MDC_REQUEST_END, new Date(now).toString());
+ }
- public static String getSimpleClassName(String className) {
- int index = className.lastIndexOf('.');
- if (index != -1) {
- return className.substring(index + 1);
- }
- return className;
- }
+ public static String getSimpleClassName(String className) {
+ int index = className.lastIndexOf('.');
+ if (index != -1) {
+ return className.substring(index + 1);
+ }
+ return className;
+ }
}
@@ -3,6 +3,7 @@
/**
*
* Generic Log Event.
+ *
* @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
* @since 26.09.13 15:16
*/
@@ -51,5 +52,5 @@
* @return MDC value, if available, else null.
*/
String getMdc(String mdcName);
-
+
}
@@ -11,61 +11,56 @@
/**
* Named references to common log event fields.
*/
- public static enum NamedLogField {
- Time("Time"),
- Severity("Severity"),
- ThreadName("Thread"),
- SourceClassName("SourceClassName"),
- SourceSimpleClassName("SourceSimpleClassName"),
- SourceMethodName("SourceMethodName"),
- Server("Server");
+ public static enum NamedLogField {
+ Time("Time"), Severity("Severity"), ThreadName("Thread"), SourceClassName("SourceClassName"), SourceSimpleClassName(
+ "SourceSimpleClassName"), SourceMethodName("SourceMethodName"), Server("Server");
- private final String fieldName;
+ private final String fieldName;
- NamedLogField(String fieldName) {
- this.fieldName = fieldName;
- }
+ NamedLogField(String fieldName) {
+ this.fieldName = fieldName;
+ }
- public String getFieldName() {
- return fieldName;
- }
- }
+ public String getFieldName() {
+ return fieldName;
+ }
+ }
- private String name;
- private NamedLogField namedLogField;
+ private String name;
+ private NamedLogField namedLogField;
- public LogMessageField(String name, NamedLogField namedLogField) {
- this.namedLogField = namedLogField;
- this.name = name;
- }
+ public LogMessageField(String name, NamedLogField namedLogField) {
+ this.namedLogField = namedLogField;
+ this.name = name;
+ }
- public NamedLogField getNamedLogField() {
- return namedLogField;
- }
+ public NamedLogField getNamedLogField() {
+ return namedLogField;
+ }
- @Override
- public String getName() {
- return name;
- }
+ @Override
+ public String getName() {
+ return name;
+ }
- public static List<LogMessageField> getDefaultMapping() {
+ public static List<LogMessageField> getDefaultMapping() {
- List<LogMessageField> result = new ArrayList<LogMessageField>();
+ List<LogMessageField> result = new ArrayList<LogMessageField>();
- for (NamedLogField namedLogField : NamedLogField.values()) {
- result.add(new LogMessageField(namedLogField.fieldName, namedLogField));
- }
+ for (NamedLogField namedLogField : NamedLogField.values()) {
+ result.add(new LogMessageField(namedLogField.fieldName, namedLogField));
+ }
- return result;
- }
+ return result;
+ }
- @Override
- public String toString() {
- final StringBuffer sb = new StringBuffer();
- sb.append(getClass().getSimpleName());
- sb.append(" [name='").append(name).append('\'');
- sb.append(", namedLogField=").append(namedLogField);
- sb.append(']');
- return sb.toString();
- }
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [name='").append(name).append('\'');
+ sb.append(", namedLogField=").append(namedLogField);
+ sb.append(']');
+ return sb.toString();
+ }
}
@@ -4,55 +4,56 @@
/**
* Message-Assembler using MDC.
+ *
* @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
* @since 26.09.13 15:05
*/
public class MdcGelfMessageAssembler extends GelfMessageAssembler {
- public static final String PROPERTY_MDC_PROFILING = "mdcProfiling";
- public static final String PROPERTY_MDC_FIELD = "mdcField.";
+ public static final String PROPERTY_MDC_PROFILING = "mdcProfiling";
+ public static final String PROPERTY_MDC_FIELD = "mdcField.";
- private boolean mdcProfiling;
+ private boolean mdcProfiling;
- public void initialize(PropertyProvider propertyProvider) {
+ public void initialize(PropertyProvider propertyProvider) {
- super.initialize(propertyProvider);
- mdcProfiling = "true".equalsIgnoreCase(propertyProvider.getProperty(PROPERTY_MDC_PROFILING));
+ super.initialize(propertyProvider);
+ mdcProfiling = "true".equalsIgnoreCase(propertyProvider.getProperty(PROPERTY_MDC_PROFILING));
- setupMdcFields(propertyProvider);
+ setupMdcFields(propertyProvider);
- }
+ }
- public GelfMessage createGelfMessage(LogEvent logEvent) {
+ public GelfMessage createGelfMessage(LogEvent logEvent) {
- GelfMessage gelfMessage = super.createGelfMessage(logEvent);
- if (mdcProfiling) {
- GelfUtil.addMdcProfiling(logEvent, gelfMessage);
- }
+ GelfMessage gelfMessage = super.createGelfMessage(logEvent);
+ if (mdcProfiling) {
+ GelfUtil.addMdcProfiling(logEvent, gelfMessage);
+ }
- return gelfMessage;
- }
+ return gelfMessage;
+ }
- private void setupMdcFields(PropertyProvider propertyProvider) {
- int fieldNumber = 0;
- while (true) {
- final String property = propertyProvider.getProperty(PROPERTY_MDC_FIELD + fieldNumber);
- if (null == property) {
- break;
- }
+ private void setupMdcFields(PropertyProvider propertyProvider) {
+ int fieldNumber = 0;
+ while (true) {
+ final String property = propertyProvider.getProperty(PROPERTY_MDC_FIELD + fieldNumber);
+ if (null == property) {
+ break;
+ }
- MdcMessageField field = new MdcMessageField(property, property);
- addField(field);
- fieldNumber++;
- }
- }
+ MdcMessageField field = new MdcMessageField(property, property);
+ addField(field);
+ fieldNumber++;
+ }
+ }
- public boolean isMdcProfiling() {
- return mdcProfiling;
- }
+ public boolean isMdcProfiling() {
+ return mdcProfiling;
+ }
- public void setMdcProfiling(boolean mdcProfiling) {
- this.mdcProfiling = mdcProfiling;
- }
+ public void setMdcProfiling(boolean mdcProfiling) {
+ this.mdcProfiling = mdcProfiling;
+ }
}
Oops, something went wrong.

0 comments on commit 16af383

Please sign in to comment.