Class 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
    • Field Detail

      • handlers

        protected final java.util.Collection<ILogHandler> handlers
      • logThread

        private final java.lang.Thread logThread
      • level

        protected int level
    • Constructor Detail

      • DefaultAsyncLogger

        public DefaultAsyncLogger()
    • 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 interface ILevelable
      • 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
        Specified by:
        setLevel in interface ILogger
        Parameters:
        level - the level, that should set
        See Also:
        LogLevel
      • 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
        Specified by:
        log in interface ILogger
        Parameters:
        logEntry - the entry, that should be handle
        Returns:
        the current logger 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
        Specified by:
        log in interface ILogger
        Parameters:
        logEntries - the entries, that should be handle
        Returns:
        the current logger instance
      • 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 interface ILogger
        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 interface ILogHandlerProvider<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 interface ILogHandlerProvider<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 interface ILogHandlerProvider<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 interface ILogHandlerProvider<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 interface ILogHandlerProvider<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 interface ILogHandlerProvider<ILogger>
        Parameters:
        logHandlers - the ILogHandler's, which should be removed
        Returns:
        the current implementation of the ILogHandlerProvider
      • hasLogHandler

        public boolean hasLogHandler​(ILogHandler logHandler)
        Description copied from interface: ILogHandlerProvider
        Check that the ILogHandler exists on this provider
        Specified by:
        hasLogHandler in interface ILogHandlerProvider<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 interface ILogHandlerProvider<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 interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • handleLogEntry

        private void handleLogEntry​(LogEntry logEntry)