private static JSONObject createJSONObject ( final Logger . LEVEL level , final String pkg , final String message , long timestamp , final JSONObject jsonMetadata , final Throwable t ) { JSONObject jsonObject = new JSONObject ( ) ; try { jsonObject . put ( "timestamp" , timestamp ) ; jsonObject . put ( "level" , level . toString ( ) ) ; jsonObject . put ( "pkg" , pkg ) ; jsonObject . put ( "msg" , message ) ; jsonObject . put ( "threadid" , Thread . currentThread ( ) . getId ( ) ) ; if ( null != jsonMetadata ) { jsonObject . put ( "metadata" , jsonMetadata ) ; } if ( null != t ) { jsonObject . put ( "metadata" , appendFullStackTrace ( jsonMetadata , t ) ) ; } } catch ( JSONException e ) { Log . e ( LOG_TAG_NAME , "Error adding JSONObject key/value pairs" , e ) ; } return jsonObject ; }
Will create JSONObject with the passed parameters and other relevant information . See class - level documentation .