Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.mycompany.listeners
Class MailLogger  view MailLogger download MailLogger.java

java.lang.Object
  extended bycom.mycompany.listeners.MailLogger
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.AuditListener, java.util.EventListener

public class MailLogger
extends java.lang.Object
implements com.puppycrawl.tools.checkstyle.api.AuditListener

Buffers log messages from DefaultLogger, and sends an e-mail with the results. The following Project properties are used to send the mail.

These properties are set using standard property setting mechanisms (command-line -D, ant <property>, etc).Properties can be overridden by specifying the filename of a properties file in the MailLogger.properties.file property . Any properties defined in that file will override properties. Based on org.apache.tools.ant.listener.MailLogger>org.apache.tools.ant.listener.MailLogger


Field Summary
private  int mErrors
          count of the number of errors and exceptions
private  com.puppycrawl.tools.checkstyle.DefaultLogger mLogger
          adapted listener
private  java.io.ByteArrayOutputStream mOutputStream
          output stream for logger
 
Constructor Summary
MailLogger()
          Constructs a MailLogger
 
Method Summary
 void addError(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
          Notify that an audit error was discovered on a specific file.
 void addException(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt, java.lang.Throwable aThrowable)
          Notify that an exception happened while performing audit.
 void auditFinished(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
          Sends an e-mail with the log results.
 void auditStarted(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
          Notify that the audit is about to start.
 void fileFinished(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
          Notify that audit is finished on a specific file.
 void fileStarted(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
          Notify that audit is about to start on a specific file.
private  java.lang.String getValue(java.util.Properties aProperties, java.lang.String aName, java.lang.String aDefaultValue)
          Gets the value of a property.
private  void sendMail(java.lang.String aMailhost, java.lang.String aFrom, java.lang.String aToList, java.lang.String aSubject, java.lang.String aText)
          Send the mail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mOutputStream

private java.io.ByteArrayOutputStream mOutputStream
output stream for logger


mLogger

private com.puppycrawl.tools.checkstyle.DefaultLogger mLogger
adapted listener


mErrors

private int mErrors
count of the number of errors and exceptions

Constructor Detail

MailLogger

public MailLogger()
Constructs a MailLogger

Method Detail

auditStarted

public void auditStarted(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
Description copied from interface: com.puppycrawl.tools.checkstyle.api.AuditListener
Notify that the audit is about to start.

Specified by:
auditStarted in interface com.puppycrawl.tools.checkstyle.api.AuditListener

auditFinished

public void auditFinished(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
Sends an e-mail with the log results.

Specified by:
auditFinished in interface com.puppycrawl.tools.checkstyle.api.AuditListener

fileStarted

public void fileStarted(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
Description copied from interface: com.puppycrawl.tools.checkstyle.api.AuditListener
Notify that audit is about to start on a specific file.

Specified by:
fileStarted in interface com.puppycrawl.tools.checkstyle.api.AuditListener

fileFinished

public void fileFinished(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
Description copied from interface: com.puppycrawl.tools.checkstyle.api.AuditListener
Notify that audit is finished on a specific file.

Specified by:
fileFinished in interface com.puppycrawl.tools.checkstyle.api.AuditListener

addError

public void addError(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt)
Description copied from interface: com.puppycrawl.tools.checkstyle.api.AuditListener
Notify that an audit error was discovered on a specific file.

Specified by:
addError in interface com.puppycrawl.tools.checkstyle.api.AuditListener

addException

public void addException(com.puppycrawl.tools.checkstyle.api.AuditEvent aEvt,
                         java.lang.Throwable aThrowable)
Description copied from interface: com.puppycrawl.tools.checkstyle.api.AuditListener
Notify that an exception happened while performing audit.

Specified by:
addException in interface com.puppycrawl.tools.checkstyle.api.AuditListener

getValue

private java.lang.String getValue(java.util.Properties aProperties,
                                  java.lang.String aName,
                                  java.lang.String aDefaultValue)
                           throws com.puppycrawl.tools.checkstyle.api.CheckstyleException
Gets the value of a property.


sendMail

private void sendMail(java.lang.String aMailhost,
                      java.lang.String aFrom,
                      java.lang.String aToList,
                      java.lang.String aSubject,
                      java.lang.String aText)
               throws java.lang.Exception
Send the mail