@ Override public void messageLogged ( final BuildEvent event ) { final int priority = event . getPriority ( ) ; // Filter out messages based on priority if ( priority <= msgOutputLevel ) { final StringBuilder message = new StringBuilder ( ) ; if ( event . getTask ( ) != null && ! emacsMode ) { // Print out the name of the task if we're in one final String name = event . getTask ( ) . getTaskName ( ) ; String label = "[" + name + "] " ; final int size = LEFT_COLUMN_SIZE - label . length ( ) ; final StringBuilder tmp = new StringBuilder ( ) ; for ( int i = 0 ; i < size ; i ++ ) { tmp . append ( " " ) ; } tmp . append ( label ) ; label = tmp . toString ( ) ; BufferedReader r = null ; try { r = new BufferedReader ( new StringReader ( event . getMessage ( ) ) ) ; String line = r . readLine ( ) ; boolean first = true ; do { if ( first ) { if ( line == null ) { message . append ( label ) ; break ; } } else { message . append ( StringUtils . LINE_SEP ) ; } first = false ; message . append ( label ) . append ( line ) ; line = r . readLine ( ) ; } while ( line != null ) ; } catch ( final IOException e ) { // shouldn't be possible message . append ( label ) . append ( event . getMessage ( ) ) ; } finally { if ( r != null ) { FileUtils . close ( r ) ; } } } else { // emacs mode or there is no task message . append ( event . getMessage ( ) ) ; } final Throwable ex = event . getException ( ) ; if ( Project . MSG_DEBUG <= msgOutputLevel && ex != null ) { message . append ( StringUtils . getStackTrace ( ex ) ) ; } final String msg = message . toString ( ) ; if ( priority != Project . MSG_ERR ) { printMessage ( msg , out , priority ) ; } else { printMessage ( msg , err , priority ) ; } log ( msg ) ; } }
Logs a message if the priority is suitable . In non - emacs mode task level messages are prefixed by the task name which is right - justified .