org.almendra.commons.util.logging
Class Logger
java.lang.Object
org.almendra.commons.util.logging.Logger
- All Implemented Interfaces:
- ILogPrinter
- Direct Known Subclasses:
- Logger, NullLogger
public class Logger
- extends java.lang.Object
- implements ILogPrinter
- Author:
- Oliver Plohmann
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEBUG
public static final int DEBUG
- See Also:
- Constant Field Values
ERROR
public static final int ERROR
- See Also:
- Constant Field Values
FATAL
public static final int FATAL
- See Also:
- Constant Field Values
INFO
public static final int INFO
- See Also:
- Constant Field Values
WARNING
public static final int WARNING
- See Also:
- Constant Field Values
EXCEPTION
public static final int EXCEPTION
- See Also:
- Constant Field Values
FREE_TEXT
public static final int FREE_TEXT
- See Also:
- Constant Field Values
NewSession
public static final java.lang.String NewSession
- See Also:
- Constant Field Values
parent
protected Logger parent
localLogFileMaxSize
protected long localLogFileMaxSize
localLogFileMaxSizeChecked
protected boolean localLogFileMaxSizeChecked
logPrinter
protected ILogPrinter logPrinter
levelLabels
protected java.lang.String[] levelLabels
registeredEvents
protected java.util.HashSet registeredEvents
subscribedEvents
protected java.util.HashSet subscribedEvents
children
protected java.util.List children
localLogFileName
protected java.lang.String localLogFileName
localLogWriter
protected java.io.FileWriter localLogWriter
bufferUnwrittenMsgs
protected boolean bufferUnwrittenMsgs
logBuffer
protected java.util.List logBuffer
listeners
protected java.util.List listeners
lock
protected EDU.oswego.cs.dl.util.concurrent.ReentrantLock lock
- Lock access to log writer when it is being changed since there are
several threads that write to the log which could cause race conditions.
Logger
public Logger()
Logger
public Logger(boolean bufferUnwrittenMsgs,
long localLogFileMaxSize)
Logger
public Logger(ILogPrinter logPrinter)
Logger
public Logger(ILogPrinter logPrinter,
boolean bufferUnwrittenMsgs)
debug
public void debug(LogEntry entry)
debug
public void debug(java.lang.String logEntryLabel)
exception
public void exception(LogEntry entry)
freeText
public void freeText(LogEntry entry)
freeText
public void freeText(java.lang.String freeText)
info
public void info(LogEntry entry)
info
public void info(java.lang.String logEntryLabel)
warn
public void warn(java.lang.String logEntryLabel)
warn
public void warn(LogEntry entry)
error
public void error(java.lang.String logEntryLabel)
error
public void error(LogEntry entry)
fatal
public void fatal(java.lang.String logEntryLabel)
fatalText
public void fatalText(java.lang.String text)
fatal
public void fatal(LogEntry entry)
init
protected void init()
log
protected void log(LogEntry entry)
sendToListeners
protected void sendToListeners(LogEntry entry)
- Parameters:
entry
-
primLog
protected void primLog(LogEntry entry)
isRegistered
public boolean isRegistered(java.lang.String eventName)
isSubscribed
public boolean isSubscribed(java.lang.String eventName)
subscribeForEvents
public void subscribeForEvents(java.util.List stringsOfEventNames)
unsubscribeForEvents
public void unsubscribeForEvents(java.util.List stringsOfEventNames)
registerForEvents
public void registerForEvents(java.util.List stringsOfEventNames)
deregisterForEvents
public void deregisterForEvents(java.util.List stringsOfEventNames)
getPublicAccessor
public LoggerAccessor getPublicAccessor()
log
public void log(java.lang.String msg)
- Description copied from interface:
ILogPrinter
- Write the log string
msg
to the output device.
- Specified by:
log
in interface ILogPrinter
logLocalWriter
protected void logLocalWriter(java.lang.String msg)
getNewLogEntry
public LogEntry getNewLogEntry()
- Returns:
- Return a new
LogEntry
object.
getChildLogger
public static Logger getChildLogger(Logger logger)
- Returns a child logger. A child logger inherits all the attribute values
of the parent logger, but new events can be registered without affecting
the parent logger.
- Parameters:
logger
- the parent logger
- Returns:
- the child logger
getChildLogger
protected static Logger getChildLogger(Logger parentLogger,
Logger childLogger)
- Helper method to allow for logger to be filled from subclass with values
defined in this class.
- Parameters:
parentLogger
- childLogger
-
- Returns:
setLocalLogFileName
public void setLocalLogFileName(java.lang.String filePathName)
throws java.io.IOException
- Throws:
java.io.IOException
checkLocalLogMaxSize
protected void checkLocalLogMaxSize(java.lang.String filePathName)
- Parameters:
filePathName
-
writeBuffer
protected void writeBuffer()
throws java.io.IOException
- Throws:
java.io.IOException
addListener
public void addListener(ILogListener listener)
getLogEntry
protected LogEntry getLogEntry(java.lang.String entryString)
- Parameters:
entry
-
- Returns:
readBuffer
protected java.lang.String[] readBuffer()
- Returns:
primReadBuffer
protected java.lang.String[] primReadBuffer()
primReadNextLogEntry
protected java.lang.String primReadNextLogEntry(java.io.FileReader reader)
throws java.io.IOException
- Throws:
java.io.IOException
closeLocalLogWriter
protected boolean closeLocalLogWriter()
openLocalLogWriter
protected void openLocalLogWriter()
throws java.io.IOException
- Throws:
java.io.IOException
removeListener
public boolean removeListener(ILogListener listener)
removeSubscription
public boolean removeSubscription(java.lang.String eventName)
changeLocalLogFileName
public boolean changeLocalLogFileName(java.lang.String newFilePathName)
throws java.io.IOException
- Throws:
java.io.IOException
close
public void close()