Class DefaultLogger

  • All Implemented Interfaces:
    AuditListener, Configurable, Contextualizable, java.util.EventListener

    public class DefaultLogger
    extends AutomaticBean
    implements AuditListener
    Simple plain logger for text output. This is maybe not very suitable for a text output into a file since it does not need all 'audit finished' and so on stuff, but it looks good on stdout anyway. If there is really a problem this is what XMLLogger is for. It gives structure.
    See Also:
    XMLLogger
    • Field Detail

      • ADD_EXCEPTION_MESSAGE

        public static final java.lang.String ADD_EXCEPTION_MESSAGE
        A key pointing to the add exception message in the "messages.properties" file.
        See Also:
        Constant Field Values
      • AUDIT_STARTED_MESSAGE

        public static final java.lang.String AUDIT_STARTED_MESSAGE
        A key pointing to the started audit message in the "messages.properties" file.
        See Also:
        Constant Field Values
      • AUDIT_FINISHED_MESSAGE

        public static final java.lang.String AUDIT_FINISHED_MESSAGE
        A key pointing to the finished audit message in the "messages.properties" file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultLogger

        public DefaultLogger​(java.io.OutputStream outputStream,
                             AutomaticBean.OutputStreamOptions outputStreamOptions)
        Creates a new DefaultLogger instance.
        Parameters:
        outputStream - where to log audit events
        outputStreamOptions - if CLOSE that should be closed in auditFinished()
      • DefaultLogger

        public DefaultLogger​(java.io.OutputStream infoStream,
                             AutomaticBean.OutputStreamOptions infoStreamOptions,
                             java.io.OutputStream errorStream,
                             AutomaticBean.OutputStreamOptions errorStreamOptions)
        Creates a new DefaultLogger instance.
        Parameters:
        infoStream - the OutputStream for info messages.
        infoStreamOptions - if CLOSE info should be closed in auditFinished()
        errorStream - the OutputStream for error messages.
        errorStreamOptions - if CLOSE error should be closed in auditFinished()
      • DefaultLogger

        public DefaultLogger​(java.io.OutputStream infoStream,
                             AutomaticBean.OutputStreamOptions infoStreamOptions,
                             java.io.OutputStream errorStream,
                             AutomaticBean.OutputStreamOptions errorStreamOptions,
                             AuditEventFormatter messageFormatter)
        Creates a new DefaultLogger instance.
        Parameters:
        infoStream - the OutputStream for info messages
        infoStreamOptions - if CLOSE info should be closed in auditFinished()
        errorStream - the OutputStream for error messages
        errorStreamOptions - if CLOSE error should be closed in auditFinished()
        messageFormatter - formatter for the log message.
        Throws:
        java.lang.IllegalArgumentException - if stream options are null
    • Method Detail

      • finishLocalSetup

        protected void finishLocalSetup()
        Description copied from class: AutomaticBean
        Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.

        The default implementation does nothing.

        Specified by:
        finishLocalSetup in class AutomaticBean
      • addError

        public void addError​(AuditEvent event)
        Print an Emacs compliant line on the error stream. If the column number is non zero, then also display it.
        Specified by:
        addError in interface AuditListener
        Parameters:
        event - the event details
        See Also:
        AuditListener
      • addException

        public void addException​(AuditEvent event,
                                 java.lang.Throwable throwable)
        Description copied from interface: AuditListener
        Notify that an exception happened while performing audit.
        Specified by:
        addException in interface AuditListener
        Parameters:
        event - the event details
        throwable - details of the exception
      • auditStarted

        public void auditStarted​(AuditEvent event)
        Description copied from interface: AuditListener
        Notify that the audit is about to start.
        Specified by:
        auditStarted in interface AuditListener
        Parameters:
        event - the event details
      • auditFinished

        public void auditFinished​(AuditEvent event)
        Description copied from interface: AuditListener
        Notify that the audit is finished.
        Specified by:
        auditFinished in interface AuditListener
        Parameters:
        event - the event details
      • fileStarted

        public void fileStarted​(AuditEvent event)
        Description copied from interface: AuditListener
        Notify that audit is about to start on a specific file.
        Specified by:
        fileStarted in interface AuditListener
        Parameters:
        event - the event details
      • fileFinished

        public void fileFinished​(AuditEvent event)
        Description copied from interface: AuditListener
        Notify that audit is finished on a specific file.
        Specified by:
        fileFinished in interface AuditListener
        Parameters:
        event - the event details