protected static String prependMetadata ( String message , JSONObject metadata ) { try { if ( null != metadata ) { String clazz = "" ; String method = "" ; String file = "" ; String line = "" ; if ( metadata . has ( "$class" ) ) { clazz = metadata . getString ( "$class" ) ; clazz = clazz . substring ( clazz . lastIndexOf ( ' ' ) + 1 , clazz . length ( ) ) ; } if ( metadata . has ( "$method" ) ) { method = metadata . getString ( "$method" ) ; } if ( metadata . has ( "$file" ) ) { file = metadata . getString ( "$file" ) ; } if ( metadata . has ( "$line" ) ) { line = metadata . getString ( "$line" ) ; } if ( ! ( clazz + method + file + line ) . equals ( "" ) ) { // we got something... message = clazz + "." + method + " in " + file + ":" + line + " :: " + message ; } } } catch ( Exception e ) { // ignore... it's best effort anyway } return message ; }
if we have callstack metadata prepend it to the message