Logger

@native @JSType
trait Logger extends Object
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Concrete methods

def debug(msg: Any*): Unit

Output debug message to console including appropriate icons

Output debug message to console including appropriate icons

Value parameters:
msg

any data to log to the console

def disableAll(): Unit

This disables all log messages, and is equivalent to log.setLevel("silent").

This disables all log messages, and is equivalent to log.setLevel("silent").

Value parameters:
persist

Where possible the log level will be persisted. LocalStorage will be used if available, falling back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass false as the optional 'persist' second argument, persistence will be skipped.

def disableAll(persist: Boolean): Unit
def enableAll(): Unit

This enables all log messages, and is equivalent to log.setLevel("trace").

This enables all log messages, and is equivalent to log.setLevel("trace").

Value parameters:
persist

Where possible the log level will be persisted. LocalStorage will be used if available, falling back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass false as the optional 'persist' second argument, persistence will be skipped.

def enableAll(persist: Boolean): Unit
def error(msg: Any*): Unit

Output error message to console including appropriate icons

Output error message to console including appropriate icons

Value parameters:
msg

any data to log to the console

def getLevel(): 3 | 2 | 4 | 0 | 5 | 1

Returns the current logging level, as a value from LogLevel. It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin development, and partly to let you optimize logging code as below, where debug data is only generated if the level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling on your code and you have hard numbers telling you that your log data generation is a real performance problem.

Returns the current logging level, as a value from LogLevel. It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin development, and partly to let you optimize logging code as below, where debug data is only generated if the level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling on your code and you have hard numbers telling you that your log data generation is a real performance problem.

def info(msg: Any*): Unit

Output info message to console including appropriate icons

Output info message to console including appropriate icons

Value parameters:
msg

any data to log to the console

def log(msg: Any*): Unit

Output debug message to console including appropriate icons

Output debug message to console including appropriate icons

Value parameters:
msg

any data to log to the console

def methodFactory(methodName: String, level: LogLevelNumbers, loggerName: String): LoggingMethod

Plugin API entry point. This will be called for each enabled method each time the level is set (including initially), and should return a MethodFactory to be used for the given log method, at the given level, for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's recommended that this wraps the initially provided value of log.methodFactory

Plugin API entry point. This will be called for each enabled method each time the level is set (including initially), and should return a MethodFactory to be used for the given log method, at the given level, for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's recommended that this wraps the initially provided value of log.methodFactory

def setDefaultLevel(level: LogLevelDesc): Unit

This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when initializing scripts; if a developer or user has previously called setLevel(), this won’t alter their settings. For example, your application might set the log level to error in a production environment, but when debugging an issue, you might call setLevel("trace") on the console to see all the logs. If that error setting was set using setDefaultLevel(), it will still say as trace on subsequent page loads and refreshes instead of resetting to error.

This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when initializing scripts; if a developer or user has previously called setLevel(), this won’t alter their settings. For example, your application might set the log level to error in a production environment, but when debugging an issue, you might call setLevel("trace") on the console to see all the logs. If that error setting was set using setDefaultLevel(), it will still say as trace on subsequent page loads and refreshes instead of resetting to error.

The level argument takes is the same values that you might pass to setLevel(). Levels set using setDefaultLevel() never persist to subsequent page loads.

Value parameters:
level

as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)

def setLevel(level: LogLevelDesc): Unit

This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something") or log.error("something") will output messages, but log.info("something") will not.

This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something") or log.error("something") will output messages, but log.info("something") will not.

Value parameters:
level

as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)

persist

Where possible the log level will be persisted. LocalStorage will be used if available, falling back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass false as the optional 'persist' second argument, persistence will be skipped.

def setLevel(level: LogLevelDesc, persist: Boolean): Unit
def trace(msg: Any*): Unit

Output trace message to console. This will also include a full stack trace

Output trace message to console. This will also include a full stack trace

Value parameters:
msg

any data to log to the console

def warn(msg: Any*): Unit

Output warn message to console including appropriate icons

Output warn message to console including appropriate icons

Value parameters:
msg

any data to log to the console

Inherited methods

def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object

Concrete fields

Available log levels.

Available log levels.

@JSName("methodFactory")

Plugin API entry point. This will be called for each enabled method each time the level is set (including initially), and should return a MethodFactory to be used for the given log method, at the given level, for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's recommended that this wraps the initially provided value of log.methodFactory

Plugin API entry point. This will be called for each enabled method each time the level is set (including initially), and should return a MethodFactory to be used for the given log method, at the given level, for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's recommended that this wraps the initially provided value of log.methodFactory