Package com.puppycrawl.tools.checkstyle
Class DefaultLogger
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.DefaultLogger
- All Implemented Interfaces:
- AuditListener,- Configurable,- Contextualizable,- EventListener
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:
- 
Nested Class SummaryNested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanAbstractAutomaticBean.OutputStreamOptions
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringA key pointing to the add exception message in the "messages.properties" file.static final StringA key pointing to the finished audit message in the "messages.properties" file.static final StringA key pointing to the started audit message in the "messages.properties" file.private final booleanClose error stream after use.private final booleanClose info stream after use.private final PrintWriterWhere to write error messages.private final AuditEventFormatterFormatter for the log message.private final PrintWriterWhere to write info messages.
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultLogger(OutputStream outputStream, AbstractAutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newDefaultLoggerinstance.DefaultLogger(OutputStream infoStream, AbstractAutomaticBean.OutputStreamOptions infoStreamOptions, OutputStream errorStream, AbstractAutomaticBean.OutputStreamOptions errorStreamOptions) Creates a newDefaultLoggerinstance.DefaultLogger(OutputStream infoStream, AbstractAutomaticBean.OutputStreamOptions infoStreamOptions, OutputStream errorStream, AbstractAutomaticBean.OutputStreamOptions errorStreamOptions, AuditEventFormatter messageFormatter) Creates a newDefaultLoggerinstance.DefaultLogger(OutputStream outputStream, AutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newDefaultLoggerinstance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddError(AuditEvent event) Print an Emacs compliant line on the error stream.voidaddException(AuditEvent event, Throwable throwable) Notify that an exception happened while performing audit.voidauditFinished(AuditEvent event) Notify that the audit is finished.voidauditStarted(AuditEvent event) Notify that the audit is about to start.private voidFlushes the output streams and closes them if needed.voidfileFinished(AuditEvent event) Notify that audit is finished on a specific file.voidfileStarted(AuditEvent event) Notify that audit is about to start on a specific file.protected voidProvides a hook to finish the part of this component's setup that was not handled by the bean introspection.private static StringgetLocalizedMessage(Class<?> caller, String messageKey, Object... args) Extracts localized messages from properties files.Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanconfigure, contextualize, getConfiguration, setupChild
- 
Field Details- 
ADD_EXCEPTION_MESSAGEA key pointing to the add exception message in the "messages.properties" file.- See Also:
 
- 
AUDIT_STARTED_MESSAGEA key pointing to the started audit message in the "messages.properties" file.- See Also:
 
- 
AUDIT_FINISHED_MESSAGEA key pointing to the finished audit message in the "messages.properties" file.- See Also:
 
- 
infoWriterWhere to write info messages.
- 
closeInfoClose info stream after use.
- 
errorWriterWhere to write error messages.
- 
closeErrorClose error stream after use.
- 
formatterFormatter for the log message.
 
- 
- 
Constructor Details- 
DefaultLoggerpublic DefaultLogger(OutputStream outputStream, AutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newDefaultLoggerinstance.- Parameters:
- outputStream- where to log audit events
- outputStreamOptions- if- CLOSEthat should be closed in auditFinished()
 
- 
DefaultLoggerpublic DefaultLogger(OutputStream outputStream, AbstractAutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newDefaultLoggerinstance.- Parameters:
- outputStream- where to log audit events
- outputStreamOptions- if- CLOSEthat should be closed in auditFinished()
 
- 
DefaultLoggerpublic DefaultLogger(OutputStream infoStream, AbstractAutomaticBean.OutputStreamOptions infoStreamOptions, OutputStream errorStream, AbstractAutomaticBean.OutputStreamOptions errorStreamOptions) Creates a newDefaultLoggerinstance.- Parameters:
- infoStream- the- OutputStreamfor info messages.
- infoStreamOptions- if- CLOSEinfo should be closed in auditFinished()
- errorStream- the- OutputStreamfor error messages.
- errorStreamOptions- if- CLOSEerror should be closed in auditFinished()
 
- 
DefaultLoggerpublic DefaultLogger(OutputStream infoStream, AbstractAutomaticBean.OutputStreamOptions infoStreamOptions, OutputStream errorStream, AbstractAutomaticBean.OutputStreamOptions errorStreamOptions, AuditEventFormatter messageFormatter) Creates a newDefaultLoggerinstance.- Parameters:
- infoStream- the- OutputStreamfor info messages
- infoStreamOptions- if- CLOSEinfo should be closed in auditFinished()
- errorStream- the- OutputStreamfor error messages
- errorStreamOptions- if- CLOSEerror should be closed in auditFinished()
- messageFormatter- formatter for the log message.
- Throws:
- IllegalArgumentException- if stream options are null
 
 
- 
- 
Method Details- 
finishLocalSetupDescription copied from class:AbstractAutomaticBeanProvides 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:
- finishLocalSetupin class- AbstractAutomaticBean
 
- 
addErrorPrint an Emacs compliant line on the error stream. If the column number is non-zero, then also display it.- Specified by:
- addErrorin interface- AuditListener
- Parameters:
- event- the event details
- See Also:
 
- 
addExceptionDescription copied from interface:AuditListenerNotify that an exception happened while performing audit.- Specified by:
- addExceptionin interface- AuditListener
- Parameters:
- event- the event details
- throwable- details of the exception
 
- 
auditStartedDescription copied from interface:AuditListenerNotify that the audit is about to start.- Specified by:
- auditStartedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
auditFinishedDescription copied from interface:AuditListenerNotify that the audit is finished.- Specified by:
- auditFinishedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
fileStartedDescription copied from interface:AuditListenerNotify that audit is about to start on a specific file.- Specified by:
- fileStartedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
fileFinishedDescription copied from interface:AuditListenerNotify that audit is finished on a specific file.- Specified by:
- fileFinishedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
closeStreamsFlushes the output streams and closes them if needed.
- 
getLocalizedMessageExtracts localized messages from properties files.- Parameters:
- caller- the- Classused to resolve the resource bundle
- messageKey- the key pointing to localized message in respective properties file.
- args- the arguments of message in respective properties file.
- Returns:
- a string containing extracted localized message
 
 
-