Package glide.api.logging
Class Logger
- java.lang.Object
-
- glide.api.logging.Logger
-
public final class Logger extends java.lang.ObjectA singleton class that allows logging which is consistent with logs from the internal GLIDE core. The logger can be set up in 2 ways -- By calling
Logger.init, which configures the logger only if it wasn't previously configured. - By calling
Logger.setLoggerConfig, which replaces the existing configuration, and means that new logs will not be saved with the logs that were sent before the call.
- By calling
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLogger.Level
-
Constructor Summary
Constructors Constructor Description Logger()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Logger.LevelgetLoggerLevel()static voidinit()Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger.static voidinit(@NonNull Logger.Level level)Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger.static voidinit(@NonNull Logger.Level level, java.lang.String fileName)Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger.static voidinit(@NonNull java.lang.String fileName)Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger.static voidlog(@NonNull Logger.Level level, @NonNull java.lang.String logIdentifier, @NonNull java.lang.String message)Logs the provided message if the provided log level is lower than the logger level.static voidlog(@NonNull Logger.Level level, @NonNull java.lang.String logIdentifier, @NonNull java.lang.String message, @NonNull java.lang.Throwable throwable)Logs the provided exception or error if the provided log level is lower than the logger level.static voidlog(@NonNull Logger.Level level, @NonNull java.lang.String logIdentifier, @NonNull java.util.function.Supplier<java.lang.String> messageSupplier)Logs the provided message if the provided log level is lower than the logger level.static voidlog(@NonNull Logger.Level level, @NonNull java.lang.String logIdentifier, @NonNull java.util.function.Supplier<java.lang.String> messageSupplier, @NonNull java.lang.Throwable throwable)Logs the provided exception or error if the provided log level is lower than the logger level.static voidsetLoggerConfig()Creates a new logger instance.static voidsetLoggerConfig(@NonNull Logger.Level level)Creates a new logger instance and configure it with the provided log level.static voidsetLoggerConfig(@NonNull Logger.Level level, java.lang.String fileName)Creates a new logger instance and configure it with the provided log level and file name.static voidsetLoggerConfig(java.lang.String fileName)Creates a new logger instance and configure it with the provided file name and default log level.
-
-
-
Method Detail
-
init
public static void init(@NonNull @NonNull Logger.Level level, java.lang.String fileName)Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger. The logger will filter all logs with a level lower than the given level.- Parameters:
level- Set the logger level to one of[DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE, OFF]. To turn off logging completely, set the level toLogger.Level.OFF.fileName- The target of the logs will be the file mentioned.
-
init
public static void init(@NonNull @NonNull java.lang.String fileName)Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger. The logger will filter all logs with a level lower than the default level decided by Glide core. All logs will be printed to the console.- Parameters:
fileName- The target of the logs will be the file mentioned.
-
init
public static void init()
Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger. The logger will filter all logs with a level lower than the default level decided by Glide core. The logs will be written to the console.
-
init
public static void init(@NonNull @NonNull Logger.Level level)Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger. The logger will filter all logs with a level lower than the given level. The logs will be written to the console.- Parameters:
level- Set the logger level to one of[DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE]. To turn off logging completely, set the level toLogger.Level.OFF.
-
log
public static void log(@NonNull @NonNull Logger.Level level, @NonNull @NonNull java.lang.String logIdentifier, @NonNull @NonNull java.util.function.Supplier<java.lang.String> messageSupplier)Logs the provided message if the provided log level is lower than the logger level. This overload takes aSupplierto lazily construct the message.- Parameters:
level- The log level of the provided message.logIdentifier- The log identifier should give the log a context.messageSupplier- TheSupplierof the message to log.
-
log
public static void log(@NonNull @NonNull Logger.Level level, @NonNull @NonNull java.lang.String logIdentifier, @NonNull @NonNull java.lang.String message)Logs the provided message if the provided log level is lower than the logger level.- Parameters:
level- The log level of the provided message.logIdentifier- The log identifier should give the log a context.message- The message to log.
-
log
public static void log(@NonNull @NonNull Logger.Level level, @NonNull @NonNull java.lang.String logIdentifier, @NonNull @NonNull java.lang.String message, @NonNull @NonNull java.lang.Throwable throwable)Logs the provided exception or error if the provided log level is lower than the logger level.- Parameters:
level- The log level of the provided message.logIdentifier- The log identifier should give the log a context.message- The message to log with the exception.throwable- The exception or error to log.
-
log
public static void log(@NonNull @NonNull Logger.Level level, @NonNull @NonNull java.lang.String logIdentifier, @NonNull @NonNull java.util.function.Supplier<java.lang.String> messageSupplier, @NonNull @NonNull java.lang.Throwable throwable)Logs the provided exception or error if the provided log level is lower than the logger level. This overload takes aSupplierto lazily construct the message.- Parameters:
level- The log level of the provided message.logIdentifier- The log identifier should give the log a context.messageSupplier- TheSupplierof the message to log.throwable- The exception or error to log.
-
setLoggerConfig
public static void setLoggerConfig(@NonNull @NonNull Logger.Level level, java.lang.String fileName)Creates a new logger instance and configure it with the provided log level and file name.- Parameters:
level- Set the logger level to one of[DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE, OFF]. If log level isn't provided, the logger will be configured with default configuration decided by Glide core.fileName- If provided, the target of the logs will be the file mentioned. Otherwise, logs will be printed to stdout.
-
setLoggerConfig
public static void setLoggerConfig(@NonNull @NonNull Logger.Level level)Creates a new logger instance and configure it with the provided log level. The logs will be written to stdout. To turn off the logger, usesetLoggerConfig(Level.OFF).- Parameters:
level- Set the logger level to one of[DEFAULT, ERROR, WARN, INFO, DEBUG, TRACE, OFF]. If log level isn't provided, the logger will be configured with default configuration decided by Glide core.
-
setLoggerConfig
public static void setLoggerConfig(java.lang.String fileName)
Creates a new logger instance and configure it with the provided file name and default log level. The logger will filter all logs with a level lower than the default level decided by the Glide core.- Parameters:
fileName- If provided, the target of the logs will be the file mentioned. Otherwise, logs will be printed to stdout.
-
setLoggerConfig
public static void setLoggerConfig()
Creates a new logger instance. The logger will filter all logs with a level lower than the default level decided by Glide core. The logs will be written to stdout.
-
getLoggerLevel
public static Logger.Level getLoggerLevel()
-
-