Class DefaultAsyncLogger
- java.lang.Object
-
- de.dytanic.cloudnet.common.logging.DefaultAsyncLogger
-
- All Implemented Interfaces:
ILevelable
,ILogger
,ILogHandlerProvider<ILogger>
,java.lang.AutoCloseable
public class DefaultAsyncLogger extends java.lang.Object implements ILogger
The default implementation of the ILogger interface. The the logger executes the registered logHandlers asynchronously by default or synchronously if the LogLevel disallow async log handling
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DefaultAsyncLogger.LogHandlerRunnable
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.BlockingQueue<DefaultAsyncLogger.LogHandlerRunnable>
entries
protected java.util.Collection<ILogHandler>
handlers
protected int
level
private java.lang.Thread
logThread
-
Constructor Summary
Constructors Constructor Description DefaultAsyncLogger()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ILogger
addLogHandler(ILogHandler logHandler)
Adds a new ILogHandler instance, into the collection by the LogHandlerProvider implementationILogger
addLogHandlers(ILogHandler... logHandlers)
Adds an array of ILogHandler instances, into the collection by the LogHandlerProvider implementationILogger
addLogHandlers(java.lang.Iterable<ILogHandler> logHandlers)
Adds an Iterable of ILogHandler instances, into the collection by the LogHandlerProvider implementationvoid
close()
int
getLevel()
Returns the current configured access level.java.lang.Iterable<ILogHandler>
getLogHandlers()
Returns all registered ILogHandler instances as an Iterableprivate void
handleLogEntry(LogEntry logEntry)
boolean
hasAsyncSupport()
Indicates, that the implementation of the logger has support for asynchronously log handleboolean
hasLogHandler(ILogHandler logHandler)
Check that the ILogHandler exists on this providerboolean
hasLogHandlers(ILogHandler... logHandlers)
Check that the ILogHandler's exists on this providerILogger
log(LogEntry logEntry)
Allows to post one LogEntry object into the logger, which invokes the LogHandlers for this LogEntry instanceILogger
log(LogEntry... logEntries)
Allows to post zero or more LogEntries into the logger, which invokes the LogHandlers for this LogEntry instancesILogger
removeLogHandler(ILogHandler logHandler)
Removes when contains the ILogHandler reference into the internal registryILogger
removeLogHandlers(ILogHandler... logHandlers)
Removes when contains the ILogHandler's reference into the internal registryILogger
removeLogHandlers(java.lang.Iterable<ILogHandler> logHandlers)
Removes when contains the ILogHandler's reference into the internal registryvoid
setLevel(int level)
Set the LogLevel notification level.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.dytanic.cloudnet.common.logging.ILogger
debug, debug, debug, debug, debug, debug, debug, debug, error, error, error, error, error, error, error, error, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, info, info, info, info, log, log, log, log, log, log, log, log, setLevel, warning, warning, warning, warning, warning, warning, warning, warning
-
-
-
-
Field Detail
-
handlers
protected final java.util.Collection<ILogHandler> handlers
-
entries
private final java.util.concurrent.BlockingQueue<DefaultAsyncLogger.LogHandlerRunnable> entries
-
logThread
private final java.lang.Thread logThread
-
level
protected int level
-
-
Method Detail
-
getLevel
public int getLevel()
Description copied from interface:ILevelable
Returns the current configured access level. All log entries under this level can be only noticed- Specified by:
getLevel
in interfaceILevelable
-
setLevel
public void setLevel(int level)
Description copied from interface:ILogger
Set the LogLevel notification level. If the level higher or same than the incoming LogLevel.level. The LogEntry is allowed to handle
-
log
public ILogger log(LogEntry logEntry)
Description copied from interface:ILogger
Allows to post one LogEntry object into the logger, which invokes the LogHandlers for this LogEntry instance
-
log
public ILogger log(LogEntry... logEntries)
Description copied from interface:ILogger
Allows to post zero or more LogEntries into the logger, which invokes the LogHandlers for this LogEntry instances
-
hasAsyncSupport
public boolean hasAsyncSupport()
Description copied from interface:ILogger
Indicates, that the implementation of the logger has support for asynchronously log handle- Specified by:
hasAsyncSupport
in interfaceILogger
- Returns:
- true when the implementation has the support or false if the class doesn't has any async features
-
addLogHandler
public ILogger addLogHandler(ILogHandler logHandler)
Description copied from interface:ILogHandlerProvider
Adds a new ILogHandler instance, into the collection by the LogHandlerProvider implementation- Specified by:
addLogHandler
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandler
- the ILogHandler implementation, which should append- Returns:
- the current implementation of the ILogHandlerProvider
-
addLogHandlers
public ILogger addLogHandlers(ILogHandler... logHandlers)
Description copied from interface:ILogHandlerProvider
Adds an array of ILogHandler instances, into the collection by the LogHandlerProvider implementation- Specified by:
addLogHandlers
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandlers
- the ILogHandler's implementation, which should append- Returns:
- the current implementation of the ILogHandlerProvider
-
addLogHandlers
public ILogger addLogHandlers(java.lang.Iterable<ILogHandler> logHandlers)
Description copied from interface:ILogHandlerProvider
Adds an Iterable of ILogHandler instances, into the collection by the LogHandlerProvider implementation- Specified by:
addLogHandlers
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandlers
- the ILogHandler's implementation, which should append- Returns:
- the current implementation of the ILogHandlerProvider
-
removeLogHandler
public ILogger removeLogHandler(ILogHandler logHandler)
Description copied from interface:ILogHandlerProvider
Removes when contains the ILogHandler reference into the internal registry- Specified by:
removeLogHandler
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandler
- the logHandler, which should be removed- Returns:
- the current implementation of the ILogHandlerProvider
-
removeLogHandlers
public ILogger removeLogHandlers(ILogHandler... logHandlers)
Description copied from interface:ILogHandlerProvider
Removes when contains the ILogHandler's reference into the internal registry- Specified by:
removeLogHandlers
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandlers
- the ILogHandler's, which should be removed- Returns:
- the current implementation of the ILogHandlerProvider
-
removeLogHandlers
public ILogger removeLogHandlers(java.lang.Iterable<ILogHandler> logHandlers)
Description copied from interface:ILogHandlerProvider
Removes when contains the ILogHandler's reference into the internal registry- Specified by:
removeLogHandlers
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandlers
- the ILogHandler's, which should be removed- Returns:
- the current implementation of the ILogHandlerProvider
-
getLogHandlers
public java.lang.Iterable<ILogHandler> getLogHandlers()
Description copied from interface:ILogHandlerProvider
Returns all registered ILogHandler instances as an Iterable- Specified by:
getLogHandlers
in interfaceILogHandlerProvider<ILogger>
-
hasLogHandler
public boolean hasLogHandler(ILogHandler logHandler)
Description copied from interface:ILogHandlerProvider
Check that the ILogHandler exists on this provider- Specified by:
hasLogHandler
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandler
- the ILogHandler, that should test- Returns:
- true if the ILogHandler instance contain on this LogHandlerProvider object
-
hasLogHandlers
public boolean hasLogHandlers(ILogHandler... logHandlers)
Description copied from interface:ILogHandlerProvider
Check that the ILogHandler's exists on this provider- Specified by:
hasLogHandlers
in interfaceILogHandlerProvider<ILogger>
- Parameters:
logHandlers
- the ILogHandler's, that should test- Returns:
- true if the ILogHandler's instances contain on this LogHandlerProvider object
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
handleLogEntry
private void handleLogEntry(LogEntry logEntry)
-
-