public static String format ( String msg , Object ... args ) { if ( args == null || args . length == 0 ) return msg ; StringBuilder sb = new StringBuilder ( ) ; int argId = 0 ; for ( int i = 0 ; i < msg . length ( ) ; i ++ ) { final char c = msg . charAt ( i ) ; if ( c == ' ' && msg . charAt ( i + 1 ) == ' ' ) { if ( args . length > argId ) { Object val = args [ argId ++ ] ; if ( val == null ) sb . append ( "null" ) ; else sb . append ( val . toString ( ) ) ; } else { sb . append ( "{{MISSING ARG}}" ) ; } i ++ ; } else { sb . append ( c ) ; } } return sb . toString ( ) ; }
Similar to Slf4J logger