Class ExtensionsLog
java.lang.Object
net.sf.basedb.util.extensions.logging.ExtensionsLog
public class ExtensionsLog extends Object
Instances hold the log entries for a single extension.
- Since:
- 3.19.8
- Author:
- nicklas
-
Field Summary
Fields Modifier and Type Field Description private boolean
copyToStdout
private String
extensionId
private boolean
isDebugEnabled
private ReadWriteLock
lock
private Deque<LogEntry>
logEntries
private static Map<String,ExtensionsLog>
logs
private int
maxEntries
private int
numEntries
private int
numErrors
private int
numWarnings
-
Constructor Summary
Constructors Modifier Constructor Description private
ExtensionsLog(String extensionId)
-
Method Summary
Modifier and Type Method Description (package private) void
add(LogEntry entry)
Add a log entry.void
clearLog()
Clear the log.ExtensionsLogger
createLogger()
Create a logger that adds messages to this log.static ExtensionsLogger
createLogger(String extensionId)
Create a logger that can add entries to the log for the given extension.String
getExtensionId()
Get the extension id of the log.static ExtensionsLog
getLog(String extensionId, boolean create)
Get the service log for the given extension.Iterator<LogEntry>
getLogEntries()
Get an iterator that is returning all entries in the log.static ExtensionsLogger
getLogger(String extensionId, boolean create)
Get a logger that can add entries to the log for the given extension.int
getMaxEntries()
Get the max number of entries to keep in the log.int
getNumEntries()
Get the current number of entries in the log.int
getNumErrors()
Get the current number of error entries in the log.int
getNumWarnings()
Get the current number of warning entries in the log.boolean
isCopyingToStdout()
Are log entries copied to standard output?boolean
isDebugEnabled()
Is the debug-level enabled?void
setCopyToStdout(boolean copyToStdout)
Enable or disable copies of log entries to standard output.void
setDebugEnabled(boolean debugEnabled)
Enable or disable debug-level logging.
-
Field Details
-
logs
-
extensionId
-
logEntries
-
lock
-
maxEntries
private int maxEntries -
numEntries
private volatile int numEntries -
numWarnings
private volatile int numWarnings -
numErrors
private volatile int numErrors -
isDebugEnabled
private boolean isDebugEnabled -
copyToStdout
private boolean copyToStdout
-
-
Constructor Details
-
ExtensionsLog
-
-
Method Details
-
getLog
Get the service log for the given extension. If the log doens't exists yet it can optionally be created. -
getLogger
Get a logger that can add entries to the log for the given extension. If the log doesn't exists yet, it can optionally be created. -
createLogger
Create a logger that can add entries to the log for the given extension. If the log doesn't exists yet, it is be created. -
getExtensionId
Get the extension id of the log. -
isDebugEnabled
public boolean isDebugEnabled()Is the debug-level enabled? -
setDebugEnabled
public void setDebugEnabled(boolean debugEnabled)Enable or disable debug-level logging. -
isCopyingToStdout
public boolean isCopyingToStdout()Are log entries copied to standard output? -
setCopyToStdout
public void setCopyToStdout(boolean copyToStdout)Enable or disable copies of log entries to standard output. When enabled, TRACE-level log entries are also written if debugging is enabled. -
getMaxEntries
public int getMaxEntries()Get the max number of entries to keep in the log. -
getNumEntries
public int getNumEntries()Get the current number of entries in the log. -
getNumWarnings
public int getNumWarnings()Get the current number of warning entries in the log. -
getNumErrors
public int getNumErrors()Get the current number of error entries in the log. -
clearLog
public void clearLog()Clear the log. -
createLogger
Create a logger that adds messages to this log. -
add
Add a log entry. DEBUG level messages are skipped unless debug-level is enabled. TRACE level messages are always skipped but can be written to standard output if that option and debugging is enabled. -
getLogEntries
Get an iterator that is returning all entries in the log. The returned iterator is read-only and theIterator.remove()
method will throw an exception.
-