Skip to content

Instantly share code, notes, and snippets.

@edengal
Last active August 6, 2019 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edengal/542c8fd3bbebc02d4d745c7469140dc4 to your computer and use it in GitHub Desktop.
Save edengal/542c8fd3bbebc02d4d745c7469140dc4 to your computer and use it in GitHub Desktop.
@TimberLog(name = "main_application")
public static void main(String[] args) {
TimberLogger.logContext("userId", userId);
isUserAuthorized(userId);
String sql = getSqlQuery(args);
List<String> result = runSql(sql);
}
@TimberLog(name = "is_user_authorized")
private static void isUserAuthorized(String userId){
boolean isAuthorized = ...
TimberLogger.logString("isAuthorized", isAuthorized);
}
@TimberLog(name = "get_sql_query")
private static String getSqlQuery(String[] args) {
String sql = createSqlQueryFromArgs(args);
TimberLogger.logText("sql", sql);
validateSql(sql);
return sql;
}
@TimberLog(name = "create_sql_query_from_args")
private static String createSqlQueryFromArgs(String[] args) {
...
}
@TimberLog(name = "validate_sql")
private static void validateSql(String sql) {
...
}
@TimberLog(name = "run_sql")
private static List<String> runSql(String sql){
List<String> result = ...
TimberLogger.logMetric("resultSize", result.size());
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment