Class LoggerEx
java.lang.Object
com.inductiveautomation.ignition.common.util.LoggerEx
- Direct Known Subclasses:
- ReportExecutionContext.ReportLoggerEx
This class is a wrapper around a logger which provides additional useful tools. To create one, use the newBuilder()
 function and configure the builder.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classprotected classprotected classprotected static enumstatic class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final org.apache.commons.lang3.builder.ToStringStyleprotected org.slf4j.Markerprotected ObjectThe ident object to tack onto the beginning of all log messages (may be null).protected booleanSet this to true if you want the ident object to be to-stringed for each log messageprotected StringThe stored toString of the ident object (may be null)protected org.slf4j.LoggerThe underlying loggerprotected Object[]protected org.apache.commons.lang3.builder.ToStringStyleThe style to use to turn the ident obj into a string
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected StringcreateMessage(String message, Object... args) createSubLogger(Class<?> clazz) createSubLogger(String name) Creates a child logger that extends from the current name, with the same identity object, event marker, and MDC context.voidvoiddebugDuration(String message) Duration trackers log start and finish times for operations.voiddebugEvent(String message, Object... args) Logs a debug message with the event marker defined on the logger.voidvoidvoidvoidvoiderrorEvent(String message, Object... args) Logs an error message with the event marker defined on the logger.voidvoidvoidvoidvoidvoidprotected Stringorg.apache.log4j.LoggerDeprecated.org.slf4j.LoggergetName()org.apache.commons.lang3.builder.ToStringStylevoidvoidinfoDuration(String message) Duration trackers log start and finish times for operations.voidLogs an info message with the event marker defined on the logger.voidvoidbooleanbooleanbooleanbooleanstatic voidlog(Class<?> clazz, LoggerEx.Level level, MDCUtils.MDCDetails mdc, String message, Object... args) Deprecated.voidmdcClose()The complementary function to mdcSet, if the AutoClosable return of the set function wasn't used.voidConvenience function that calls MDC putmdcPutClosable(String key, String value) voidConvenience function that calls MDC removemdcSet()Sets the registered mdc key/value pairs and returns a closable that can be used to unset them.static LoggerEx.Builderprotected voidsetEventMarker(org.slf4j.Marker marker) voidsetIdentObject(Object identObj) voidsetIdentObjectIsMutable(boolean identObjectIsMutable) protected voidsetLog(org.slf4j.Logger log) protected voidsetStaticMDCContextValues(Object... values) A set of key/value pairs that will be set and unset in the mdc context around each logging operation.voidsetToStringStyle(org.apache.commons.lang3.builder.ToStringStyle toStringStyle) voidvoidtraceDuration(String message) Duration trackers log start and finish times for operations.voidtraceEvent(String message, Object... args) Logs a trace message with the event marker defined on the logger.voidvoidvoidvoidvoidLogs a warning message with the event marker defined on the logger.voidvoid
- 
Field Details- 
logprotected org.slf4j.Logger logThe underlying logger
- 
toStringStyleprotected org.apache.commons.lang3.builder.ToStringStyle toStringStyleThe style to use to turn the ident obj into a string
- 
identObjThe ident object to tack onto the beginning of all log messages (may be null).
- 
identObjStrThe stored toString of the ident object (may be null)
- 
identObjectIsMutableprotected boolean identObjectIsMutableSet this to true if you want the ident object to be to-stringed for each log message
- 
eventMarkerprotected org.slf4j.Marker eventMarker
- 
mdcContextKV
- 
DEFAULT_TO_STRING_STYLEpublic static final org.apache.commons.lang3.builder.ToStringStyle DEFAULT_TO_STRING_STYLE
 
- 
- 
Constructor Details- 
LoggerExDeprecated.Should be replaced with calls to the builder
- 
LoggerExDeprecated.Should be replaced by using the builder.
 
- 
- 
Method Details- 
newBuilder
- 
getName
- 
createSubLogger
- 
createSubLoggerCreates a child logger that extends from the current name, with the same identity object, event marker, and MDC context.
- 
setStaticMDCContextValuesA set of key/value pairs that will be set and unset in the mdc context around each logging operation. The values can change their toString value, but the keys should not.
- 
setEventMarkerprotected void setEventMarker(org.slf4j.Marker marker) 
- 
setIdentObject
- 
getIdentObject
- 
generateIdentObjStr
- 
setToStringStylepublic void setToStringStyle(org.apache.commons.lang3.builder.ToStringStyle toStringStyle) 
- 
getToStringStylepublic org.apache.commons.lang3.builder.ToStringStyle getToStringStyle()
- 
setIdentObjectIsMutablepublic void setIdentObjectIsMutable(boolean identObjectIsMutable) 
- 
isIdentObjectIsMutablepublic boolean isIdentObjectIsMutable()
- 
createMessage
- 
getLoggerDeprecated.Returns a Log4j logger. Calls to this function should be eliminated.
- 
getLoggerSLF4Jpublic org.slf4j.Logger getLoggerSLF4J()
- 
setLogprotected void setLog(org.slf4j.Logger log) 
- 
tracef
- 
tracef
- 
debugf
- 
debugf
- 
infof
- 
infof
- 
warnf
- 
warnf
- 
errorf
- 
errorf
- 
fatalf
- 
fatalf
- 
traceEventLogs a trace message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
- 
debugEventLogs a debug message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
- 
infoEventLogs an info message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
- 
warnEventLogs a warning message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
- 
errorEventLogs an error message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
- 
log@Deprecated public static void log(Class<?> clazz, LoggerEx.Level level, MDCUtils.MDCDetails mdc, String message, Object... args) Deprecated.This doesn't do anything useful and should not be used.
- 
mdcPutConvenience function that calls MDC put
- 
mdcRemoveConvenience function that calls MDC remove
- 
mdcPutClosable
- 
traceDurationDuration trackers log start and finish times for operations. They return a closable and should be used in the try-with-resources style.- Parameters:
- message- and identifying message for the operation. Will be used for the start and end messages.
 
- 
debugDurationDuration trackers log start and finish times for operations. They return a closable and should be used in the try-with-resources style.- Parameters:
- message- and identifying message for the operation. Will be used for the start and end messages.
 
- 
infoDurationDuration trackers log start and finish times for operations. They return a closable and should be used in the try-with-resources style.- Parameters:
- message- and identifying message for the operation. Will be used for the start and end messages.
 
- 
trace
- 
trace
- 
debug
- 
debug
- 
error
- 
error
- 
fatal
- 
fatal
- 
info
- 
info
- 
warn
- 
warn
- 
isTraceEnabledpublic boolean isTraceEnabled()
- 
isDebugEnabledpublic boolean isDebugEnabled()
- 
isInfoEnabledpublic boolean isInfoEnabled()
- 
mdcSetSets the registered mdc key/value pairs and returns a closable that can be used to unset them. It is important to note how this system works with this class: The registered key/values are set and unset for every logging operation. However, there are times when the values should stay in the context for a longer period of time, when calling into sub functions (which is more of the traditional use of mdc). In that case, this function can be used to set them. Subsequent calls to logging functions, which normally would have set and unset them, won't remove the keys- only calling close on this returned object (or mdcClose()) will unset them.
- 
mdcClosepublic void mdcClose()The complementary function to mdcSet, if the AutoClosable return of the set function wasn't used.
 
-