Various logging cleanups (#65)

* Various logging cleanups

* Move device info to string, apply spotless
This commit is contained in:
Banks T
2020-07-28 21:20:54 -04:00
committed by GitHub
parent a349f1cee6
commit 48851470ae
10 changed files with 49 additions and 48 deletions

View File

@@ -141,12 +141,25 @@ public class Logger {
}
}
private void log(String message, LogLevel messageLevel, LogLevel conditionalLevel) {
if (shouldLog(conditionalLevel)) {
log(message, messageLevel, group, className);
}
}
private void log(Supplier<String> messageSupplier, LogLevel level) {
if (shouldLog(level)) {
log(messageSupplier.get(), level, group, className);
}
}
private void log(
Supplier<String> messageSupplier, LogLevel messageLevel, LogLevel conditionalLevel) {
if (shouldLog(conditionalLevel)) {
log(messageSupplier.get(), messageLevel, group, className);
}
}
public void error(Supplier<String> messageSupplier) {
log(messageSupplier, LogLevel.ERROR);
}
@@ -155,9 +168,16 @@ public class Logger {
log(message, LogLevel.ERROR);
}
/**
* Logs an error message with the stack trace of a Throwable. The stacktrace will only be printed
* if the current LogLevel is TRACE
*
* @param message
* @param t
*/
public void error(String message, Throwable t) {
log(message, LogLevel.ERROR);
log(convertStackTraceToString(t), LogLevel.ERROR);
log(convertStackTraceToString(t), LogLevel.ERROR, LogLevel.TRACE);
}
public void warn(Supplier<String> messageSupplier) {