Package org.logevents
Class LogEvent
- java.lang.Object
-
- org.logevents.LogEvent
-
- All Implemented Interfaces:
org.slf4j.event.LoggingEvent
public class LogEvent extends Object implements org.slf4j.event.LoggingEvent
The representation of a log event. This class is passed to allLogEventObserver
instances and used internally.When using LogEvent, be aware that
getCallerLocation()
is initialized lazily. This will fail it's not accessed the first time inside a call toLogEventObserver
(for example, if accessed in another thread or afterLogEventObserver.logEvent(LogEvent)
returned).- Author:
- Johannes Brodwall
-
-
Constructor Summary
Constructors Constructor Description LogEvent(String loggerName, org.slf4j.event.Level level, org.slf4j.Marker marker, String messageFormat, Object[] args)
LogEvent(String loggerName, org.slf4j.event.Level level, org.slf4j.Marker marker, String messageFormat, Object[] args, String threadName, Instant timestamp, Map<String,String> mdcProperties, Map<String,DynamicMDC> dynamicMdcProperties)
-
Method Summary
-
-
-
Method Detail
-
getMdcProperties
public Map<String,String> getMdcProperties()
Message Diagnostics Context set withMDC
. Copied whenLogEvent
is created and can be safely used afterLogEventObserver.logEvent(LogEvent)
returns.
-
getDynamicMdcProperties
public Map<String,DynamicMDC> getDynamicMdcProperties()
-
getLevel
public org.slf4j.event.Level getLevel()
- Specified by:
getLevel
in interfaceorg.slf4j.event.LoggingEvent
-
getMarker
public org.slf4j.Marker getMarker()
-
getMarkers
public List<org.slf4j.Marker> getMarkers()
- Specified by:
getMarkers
in interfaceorg.slf4j.event.LoggingEvent
-
getLoggerName
public String getLoggerName()
- Specified by:
getLoggerName
in interfaceorg.slf4j.event.LoggingEvent
-
getAbbreviatedLoggerName
public String getAbbreviatedLoggerName(int maxLength)
Returns the logger name restricted as much as possible to fit maxLength characters. The final component of the name is prioritized, then each part from the beginning. For example "org.example.Logger" will be abbreviated to "o.e.Logger" or "org.e.Logger".
-
getAbbreviatedClassName
public static String getAbbreviatedClassName(String className, int maxLength)
Returns the logger name restricted as much as possible to fit maxLength characters. The final component of the name is prioritized, then each part from the beginning. For example "org.example.Logger" will be abbreviated to "o.e.Logger" or "org.e.Logger".
-
getMessage
public String getMessage()
- Specified by:
getMessage
in interfaceorg.slf4j.event.LoggingEvent
-
getMessage
public String getMessage(MessageFormatter messageFormatter)
-
getThreadName
public String getThreadName()
- Specified by:
getThreadName
in interfaceorg.slf4j.event.LoggingEvent
-
getArguments
public List<Object> getArguments()
- Specified by:
getArguments
in interfaceorg.slf4j.event.LoggingEvent
-
getArgumentArray
public Object[] getArgumentArray()
- Specified by:
getArgumentArray
in interfaceorg.slf4j.event.LoggingEvent
-
getTimeStamp
public long getTimeStamp()
- Specified by:
getTimeStamp
in interfaceorg.slf4j.event.LoggingEvent
-
getThrowable
public Throwable getThrowable()
- Specified by:
getThrowable
in interfaceorg.slf4j.event.LoggingEvent
-
getKeyValuePairs
public List<org.slf4j.event.KeyValuePair> getKeyValuePairs()
- Specified by:
getKeyValuePairs
in interfaceorg.slf4j.event.LoggingEvent
-
getInstant
public Instant getInstant()
-
getZonedDateTime
public ZonedDateTime getZonedDateTime()
-
getLocalTime
public LocalTime getLocalTime()
-
getRootThrowable
public Throwable getRootThrowable()
-
getCallerLocation
public StackTraceElement getCallerLocation()
The StackTraceElement from which a method onLogger
was first called to cause this logging event. Is initialized lazily and must be called first time during the log observation.
-
getSimpleCallerLocation
public String getSimpleCallerLocation()
Returns the logging location in a format that is usually clickable in IntelliJ, e.g. LogEvent.getSimpleCallerLocation(LogEvent.java:259)
-
getStackTrace
public StackTraceElement[] getStackTrace()
-
getCallerLine
public int getCallerLine()
-
getCallerMethodName
public String getCallerMethodName()
-
getCallerClassName
public String getCallerClassName()
-
getCallerFileName
public String getCallerFileName()
-
getMdc
public String getMdc()
-
getKeyValuePairsString
public String getKeyValuePairsString()
-
compareTo
public int compareTo(LogEvent other)
-
isBelowThreshold
public boolean isBelowThreshold(org.slf4j.event.Level threshold)
-
-