-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to turn off logger #2366
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ public enum Level | |
Warn = 1, | ||
Info = 2, | ||
Debug = 3, | ||
Trace = 4 | ||
Trace = 4, | ||
Off = 5, | ||
} | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,13 @@ | |
public final class Logger { | ||
@Getter | ||
public enum Level { | ||
DISABLED(-2), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why changing it and not using the existing code? setting disabled with -2 allows you to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the log, it was already existing the specific check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And about naming, the tracing crate we use, use off so I want to be consistent. |
||
DEFAULT(-1), | ||
ERROR(0), | ||
WARN(1), | ||
INFO(2), | ||
DEBUG(3), | ||
TRACE(4); | ||
TRACE(4), | ||
OFF(5); | ||
|
||
private final int level; | ||
|
||
|
@@ -54,6 +54,8 @@ public static Level fromInt(int i) { | |
return DEBUG; | ||
case 4: | ||
return TRACE; | ||
case 5: | ||
return OFF; | ||
default: | ||
return DEFAULT; | ||
} | ||
|
@@ -63,10 +65,6 @@ public static Level fromInt(int i) { | |
@Getter private static Level loggerLevel; | ||
|
||
private static void initLogger(@NonNull Level level, String fileName) { | ||
if (level == Level.DISABLED) { | ||
loggerLevel = level; | ||
return; | ||
} | ||
loggerLevel = Level.fromInt(initInternal(level.getLevel(), fileName)); | ||
} | ||
|
||
|
@@ -78,7 +76,7 @@ private static void initLogger(@NonNull Level level, String fileName) { | |
* the logs will be written to the console. | ||
* | ||
* @param level Set the logger level to one of <code> | ||
* [DISABLED, DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE] | ||
* [DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE, OFF] | ||
* </code>. If log level isn't provided, the logger will be configured with default | ||
* configuration decided by Glide core. | ||
* @param fileName If provided, the target of the logs will be the file mentioned. Otherwise, logs | ||
|
@@ -140,7 +138,7 @@ public static void log( | |
initLogger(Level.DEFAULT, null); | ||
} | ||
|
||
if (level == Level.DISABLED) { | ||
if (level == Level.OFF) { | ||
Comment on lines
-143
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my comment above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said, it was already there as you see, but even if not, answered above. |
||
return; | ||
} | ||
|
||
|
@@ -163,7 +161,7 @@ public static void log( | |
initLogger(Level.DEFAULT, null); | ||
} | ||
|
||
if (level == Level.DISABLED) { | ||
if (level == Level.OFF) { | ||
return; | ||
} | ||
|
||
|
@@ -222,7 +220,7 @@ private static String prettyPrintException(@NonNull Throwable throwable) { | |
* Creates a new logger instance and configure it with the provided log level and file name. | ||
* | ||
* @param level Set the logger level to one of <code> | ||
* [DISABLED, DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE] | ||
* [DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE, OFF] | ||
* </code>. If log level isn't provided, the logger will be configured with default | ||
* configuration decided by Glide core. | ||
* @param fileName If provided, the target of the logs will be the file mentioned. Otherwise, logs | ||
|
@@ -234,10 +232,10 @@ public static void setLoggerConfig(@NonNull Level level, String fileName) { | |
|
||
/** | ||
* Creates a new logger instance and configure it with the provided log level. The logs will be | ||
* written to stdout. | ||
* written to stdout. To turn off the logger, use <code>setLoggerConfig(Level.OFF)</code>. | ||
* | ||
* @param level Set the logger level to one of <code> | ||
* [DISABLED, DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE] | ||
* [DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE, OFF] | ||
* </code>. If log level isn't provided, the logger will be configured with default | ||
* configuration decided by Glide core. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's more common to use "Disabled"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the built-in naming of the rust logging library we use, I want to keep it consistent