@Test public void testFormat() { LogRecord record = new LogRecord( Level.FINER, "This is an error log message." ); record.setLoggerName( "my.logger.name" ); record.setSourceClassName( "my.package.Class" ); record.setSourceMethodName( "myMethod" ); record.setMillis( new Date().getTime()); String s = new RoboconfLogFormatter().format( record ); Assert.assertEquals( 2, s.split( "\n" ).length ); Assert.assertTrue( s.contains( "\n" + record.getMessage())); Assert.assertTrue( s.startsWith( "[" )); String fullName = record.getSourceClassName() + "#" + record.getSourceMethodName() + "\n"; Assert.assertTrue( s.contains( fullName )); }
@Override public String format( LogRecord record ) { int totalSpaces = LEVEL_SPAN - record.getLevel().toString().length(); StringBuilder sbLevel = new StringBuilder(); for( int i=0; i<totalSpaces/2; i++ ) sbLevel.append( " " ); sbLevel.append( record.getLevel()); for( int i=sbLevel.toString().length(); i<LEVEL_SPAN; i++ ) sbLevel.append( " " ); StringBuilder sb = new StringBuilder(); sb.append( "[ " ).append( this.df.format( new Date( record.getMillis()))).append(" ]" ); sb.append( "[ ").append( sbLevel ).append( " ] " ); sb.append( record.getSourceClassName()).append("#"); sb.append( record.getSourceMethodName()); sb.append( "\n" ); sb.append( formatMessage( record )); sb.append( "\n" ); return sb.toString(); }
RoboconfLogFormatter extends Formatter { @Override public String format( LogRecord record ) { int totalSpaces = LEVEL_SPAN - record.getLevel().toString().length(); StringBuilder sbLevel = new StringBuilder(); for( int i=0; i<totalSpaces/2; i++ ) sbLevel.append( " " ); sbLevel.append( record.getLevel()); for( int i=sbLevel.toString().length(); i<LEVEL_SPAN; i++ ) sbLevel.append( " " ); StringBuilder sb = new StringBuilder(); sb.append( "[ " ).append( this.df.format( new Date( record.getMillis()))).append(" ]" ); sb.append( "[ ").append( sbLevel ).append( " ] " ); sb.append( record.getSourceClassName()).append("#"); sb.append( record.getSourceMethodName()); sb.append( "\n" ); sb.append( formatMessage( record )); sb.append( "\n" ); return sb.toString(); } }
RoboconfLogFormatter extends Formatter { @Override public String format( LogRecord record ) { int totalSpaces = LEVEL_SPAN - record.getLevel().toString().length(); StringBuilder sbLevel = new StringBuilder(); for( int i=0; i<totalSpaces/2; i++ ) sbLevel.append( " " ); sbLevel.append( record.getLevel()); for( int i=sbLevel.toString().length(); i<LEVEL_SPAN; i++ ) sbLevel.append( " " ); StringBuilder sb = new StringBuilder(); sb.append( "[ " ).append( this.df.format( new Date( record.getMillis()))).append(" ]" ); sb.append( "[ ").append( sbLevel ).append( " ] " ); sb.append( record.getSourceClassName()).append("#"); sb.append( record.getSourceMethodName()); sb.append( "\n" ); sb.append( formatMessage( record )); sb.append( "\n" ); return sb.toString(); }  }
RoboconfLogFormatter extends Formatter { @Override public String format( LogRecord record ) { int totalSpaces = LEVEL_SPAN - record.getLevel().toString().length(); StringBuilder sbLevel = new StringBuilder(); for( int i=0; i<totalSpaces/2; i++ ) sbLevel.append( " " ); sbLevel.append( record.getLevel()); for( int i=sbLevel.toString().length(); i<LEVEL_SPAN; i++ ) sbLevel.append( " " ); StringBuilder sb = new StringBuilder(); sb.append( "[ " ).append( this.df.format( new Date( record.getMillis()))).append(" ]" ); sb.append( "[ ").append( sbLevel ).append( " ] " ); sb.append( record.getSourceClassName()).append("#"); sb.append( record.getSourceMethodName()); sb.append( "\n" ); sb.append( formatMessage( record )); sb.append( "\n" ); return sb.toString(); }  @Override String format( LogRecord record ); }
RoboconfLogFormatter extends Formatter { @Override public String format( LogRecord record ) { int totalSpaces = LEVEL_SPAN - record.getLevel().toString().length(); StringBuilder sbLevel = new StringBuilder(); for( int i=0; i<totalSpaces/2; i++ ) sbLevel.append( " " ); sbLevel.append( record.getLevel()); for( int i=sbLevel.toString().length(); i<LEVEL_SPAN; i++ ) sbLevel.append( " " ); StringBuilder sb = new StringBuilder(); sb.append( "[ " ).append( this.df.format( new Date( record.getMillis()))).append(" ]" ); sb.append( "[ ").append( sbLevel ).append( " ] " ); sb.append( record.getSourceClassName()).append("#"); sb.append( record.getSourceMethodName()); sb.append( "\n" ); sb.append( formatMessage( record )); sb.append( "\n" ); return sb.toString(); }  @Override String format( LogRecord record );  }