public class ExtLogRecord
extends java.util.logging.LogRecord
Modifier and Type | Class and Description |
---|---|
static class |
ExtLogRecord.FormatStyle
The format style to use.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
calculateCaller |
private ExtLogRecord.FormatStyle |
formatStyle |
private java.lang.String |
formattedMessage |
private java.lang.String |
loggerClassName |
private FastCopyHashMap<java.lang.String,java.lang.Object> |
mdcCopy |
private java.lang.String |
ndc |
private java.lang.String |
resourceKey |
private static long |
serialVersionUID |
private java.lang.String |
sourceFileName |
private int |
sourceLineNumber |
private java.lang.String |
threadName |
Constructor and Description |
---|
ExtLogRecord(ExtLogRecord original)
Make a copy of a log record.
|
ExtLogRecord(java.util.logging.Level level,
java.lang.String msg,
ExtLogRecord.FormatStyle formatStyle,
java.lang.String loggerClassName)
Construct a new instance.
|
ExtLogRecord(java.util.logging.Level level,
java.lang.String msg,
java.lang.String loggerClassName)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
calculateCaller()
Find the first stack frame below the call to the logger, and populate the log record with that information.
|
void |
copyAll()
Copy all fields and prepare this object to be passed to another thread or to be serialized.
|
void |
copyMdc()
Copy the MDC.
|
void |
disableCallerCalculation()
Disable caller calculation for this record.
|
private java.lang.String |
formatRecord() |
ExtLogRecord.FormatStyle |
getFormatStyle()
Get the format style for the record.
|
java.lang.String |
getFormattedMessage()
Get the fully formatted log record, with resources resolved and parameters applied.
|
java.lang.String |
getLoggerClassName()
Get the class name of the logger which created this record.
|
java.lang.String |
getMdc(java.lang.String key)
Get the value of an MDC property.
|
java.util.Map<java.lang.String,java.lang.String> |
getMdcCopy()
Get a copy of all the MDC properties for this log record.
|
java.lang.String |
getNdc()
Get the NDC for this log record.
|
java.lang.String |
getResourceKey()
Get the resource key, if any.
|
java.lang.String |
getSourceClassName() |
java.lang.String |
getSourceFileName()
Get the source file name for this log record.
|
int |
getSourceLineNumber()
Get the source line number for this log record.
|
java.lang.String |
getSourceMethodName() |
java.lang.String |
getThreadName()
Get the thread name of this logging event.
|
java.lang.String |
putMdc(java.lang.String key,
java.lang.String value)
Change an MDC value on this record.
|
java.lang.String |
removeMdc(java.lang.String key)
Remove an MDC value on this record.
|
void |
setMdc(java.util.Map<?,?> sourceMap)
Create a new MDC using a copy of the source map.
|
void |
setMessage(java.lang.String message)
Set the raw message.
|
void |
setMessage(java.lang.String message,
ExtLogRecord.FormatStyle formatStyle)
Set the raw message.
|
void |
setNdc(java.lang.String value)
Change the NDC for this log record.
|
void |
setParameters(java.lang.Object[] parameters)
Set the parameters to the log message.
|
void |
setResourceBundle(java.util.ResourceBundle bundle)
Set the localization resource bundle.
|
void |
setResourceBundleName(java.lang.String name)
Set the localization resource bundle name.
|
void |
setSourceClassName(java.lang.String sourceClassName) |
void |
setSourceFileName(java.lang.String sourceFileName)
Set the source file name for this log record.
|
void |
setSourceLineNumber(int sourceLineNumber)
Set the source line number for this log record.
|
void |
setSourceMethodName(java.lang.String sourceMethodName) |
void |
setThreadName(java.lang.String threadName)
Set the thread name of this logging event.
|
private void |
setUnknownCaller() |
static ExtLogRecord |
wrap(java.util.logging.LogRecord rec)
Wrap a JDK log record.
|
private void |
writeObject(java.io.ObjectOutputStream oos) |
private static final long serialVersionUID
private final transient java.lang.String loggerClassName
private transient boolean calculateCaller
private java.lang.String ndc
private ExtLogRecord.FormatStyle formatStyle
private FastCopyHashMap<java.lang.String,java.lang.Object> mdcCopy
private int sourceLineNumber
private java.lang.String sourceFileName
private java.lang.String resourceKey
private java.lang.String formattedMessage
private java.lang.String threadName
public ExtLogRecord(java.util.logging.Level level, java.lang.String msg, java.lang.String loggerClassName)
level
- a logging level valuemsg
- the raw non-localized logging message (may be null)loggerClassName
- the name of the logger classpublic ExtLogRecord(java.util.logging.Level level, java.lang.String msg, ExtLogRecord.FormatStyle formatStyle, java.lang.String loggerClassName)
level
- a logging level valuemsg
- the raw non-localized logging message (may be null)formatStyle
- the parameter format style to useloggerClassName
- the name of the logger classpublic ExtLogRecord(ExtLogRecord original)
original
- the originalpublic static ExtLogRecord wrap(java.util.logging.LogRecord rec)
ExtLogRecord
, it is simply returned. Otherwise
a wrapper record is created and returned.rec
- the original recordprivate void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException
java.io.IOException
public void disableCallerCalculation()
"unknown"
.public void copyAll()
public void copyMdc()
public java.lang.String getMdc(java.lang.String key)
key
- the property keypublic java.util.Map<java.lang.String,java.lang.String> getMdcCopy()
public java.lang.String putMdc(java.lang.String key, java.lang.String value)
key
- the key to setvalue
- the value to set it topublic java.lang.String removeMdc(java.lang.String key)
key
- the key to removepublic void setMdc(java.util.Map<?,?> sourceMap)
sourceMap
- the source man, must not be null
public java.lang.String getNdc()
public void setNdc(java.lang.String value)
value
- the new NDC valuepublic java.lang.String getLoggerClassName()
public ExtLogRecord.FormatStyle getFormatStyle()
private void calculateCaller()
private void setUnknownCaller()
public int getSourceLineNumber()
public void setSourceLineNumber(int sourceLineNumber)
sourceLineNumber
- the source line numberpublic java.lang.String getSourceFileName()
null
if no information could be obtained.public void setSourceFileName(java.lang.String sourceFileName)
sourceFileName
- the source file namepublic java.lang.String getSourceClassName()
getSourceClassName
in class java.util.logging.LogRecord
public void setSourceClassName(java.lang.String sourceClassName)
setSourceClassName
in class java.util.logging.LogRecord
public java.lang.String getSourceMethodName()
getSourceMethodName
in class java.util.logging.LogRecord
public void setSourceMethodName(java.lang.String sourceMethodName)
setSourceMethodName
in class java.util.logging.LogRecord
public java.lang.String getFormattedMessage()
public java.lang.String getResourceKey()
null
.private java.lang.String formatRecord()
public java.lang.String getThreadName()
public void setThreadName(java.lang.String threadName)
threadName
- the thread namepublic void setMessage(java.lang.String message)
MessageFormat
-style.setMessage
in class java.util.logging.LogRecord
message
- the new raw messagepublic void setMessage(java.lang.String message, ExtLogRecord.FormatStyle formatStyle)
message
- the new raw messageformatStyle
- the format style to usepublic void setParameters(java.lang.Object[] parameters)
setParameters
in class java.util.logging.LogRecord
parameters
- the log message parameters. (may be null)public void setResourceBundle(java.util.ResourceBundle bundle)
setResourceBundle
in class java.util.logging.LogRecord
bundle
- localization bundle (may be null)public void setResourceBundleName(java.lang.String name)
setResourceBundleName
in class java.util.logging.LogRecord
name
- localization bundle name (may be null)