Class DefaultAsyncLogger
- java.lang.Object
-
- de.dytanic.cloudnet.common.logging.DefaultAsyncLogger
-
- All Implemented Interfaces:
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
-
-
Field Summary
Fields Modifier and Type Field Description protected LogEntryDispatcherdispatcherprotected java.util.Collection<ILogHandler>handlersprotected java.util.concurrent.atomic.AtomicIntegerlevel
-
Constructor Summary
Constructors Constructor Description DefaultAsyncLogger()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ILoggeraddLogHandler(ILogHandler logHandler)Adds a new ILogHandler instance, into the collection by the LogHandlerProvider implementationILoggeraddLogHandlers(ILogHandler... logHandlers)Adds an array of ILogHandler instances, into the collection by the LogHandlerProvider implementationILoggeraddLogHandlers(java.lang.Iterable<ILogHandler> logHandlers)Adds an Iterable of ILogHandler instances, into the collection by the LogHandlerProvider implementationvoidclose()intgetLevel()java.lang.Iterable<ILogHandler>getLogHandlers()Returns all registered ILogHandler instances as an IterablebooleanhasAsyncSupport()Indicates, that the implementation of the logger has support for asynchronously log handlebooleanhasLogHandler(ILogHandler logHandler)Check that the ILogHandler exists on this providerbooleanhasLogHandlers(ILogHandler... logHandlers)Check that the ILogHandler's exists on this providerILoggerlog(LogEntry logEntry)Allows to post one LogEntry object into the logger, which invokes the LogHandlers for this LogEntry instanceILoggerlog(LogEntry... logEntries)Allows to post zero or more LogEntries into the logger, which invokes the LogHandlers for this LogEntry instancesILoggerremoveLogHandler(ILogHandler logHandler)Removes when contains the ILogHandler reference into the internal registryILoggerremoveLogHandlers(ILogHandler... logHandlers)Removes when contains the ILogHandler's reference into the internal registryILoggerremoveLogHandlers(java.lang.Iterable<ILogHandler> logHandlers)Removes when contains the ILogHandler's reference into the internal registryvoidsetLevel(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, extended, extended, extended, extended, extended, extended, extended, extended, 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
-
level
protected final java.util.concurrent.atomic.AtomicInteger level
-
handlers
protected final java.util.Collection<ILogHandler> handlers
-
dispatcher
protected final LogEntryDispatcher dispatcher
-
-
Method Detail
-
getLevel
public int getLevel()
-
setLevel
public void setLevel(int level)
Description copied from interface:ILoggerSet 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:ILoggerAllows 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:ILoggerAllows 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:ILoggerIndicates, that the implementation of the logger has support for asynchronously log handle- Specified by:
hasAsyncSupportin 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:ILogHandlerProviderAdds a new ILogHandler instance, into the collection by the LogHandlerProvider implementation- Specified by:
addLogHandlerin 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:ILogHandlerProviderAdds an array of ILogHandler instances, into the collection by the LogHandlerProvider implementation- Specified by:
addLogHandlersin 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:ILogHandlerProviderAdds an Iterable of ILogHandler instances, into the collection by the LogHandlerProvider implementation- Specified by:
addLogHandlersin 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:ILogHandlerProviderRemoves when contains the ILogHandler reference into the internal registry- Specified by:
removeLogHandlerin 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:ILogHandlerProviderRemoves when contains the ILogHandler's reference into the internal registry- Specified by:
removeLogHandlersin 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:ILogHandlerProviderRemoves when contains the ILogHandler's reference into the internal registry- Specified by:
removeLogHandlersin 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:ILogHandlerProviderReturns all registered ILogHandler instances as an Iterable- Specified by:
getLogHandlersin interfaceILogHandlerProvider<ILogger>
-
hasLogHandler
public boolean hasLogHandler(ILogHandler logHandler)
Description copied from interface:ILogHandlerProviderCheck that the ILogHandler exists on this provider- Specified by:
hasLogHandlerin 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:ILogHandlerProviderCheck that the ILogHandler's exists on this provider- Specified by:
hasLogHandlersin 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:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
-