Skip to content

Instantly share code, notes, and snippets.

@edengal
Last active Aug 6, 2019
Embed
What would you like to do?
@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