Constructs a new Logger
.
A set of LoggerOptions
or name to use with the default options.
Throws SfError{ name: 'RedundantRootLoggerError' } More than one attempt is made to construct the root
Logger
.
Static
Readonly
DEFAULT_The default LoggerLevel
when constructing new Logger
instances.
Static
Readonly
LEVEL_A list of all lower case LoggerLevel
names.
See LoggerLevel
Static
Readonly
ROOT_The name of the root sfdx Logger
.
Add a field to all log lines for this logger. For convenience this
object is returned.
The name of the field to add.
The value of the field to be logged.
Create a child logger, typically to add a few log record fields. For convenience this object is returned.
The name of the child logger that is emitted w/ log line. Will be prefixed with the parent logger name and :
Additional fields included in all log lines for the child logger.
Set the logging level of all streams for this logger. If a specific level
is not provided, this method will
attempt to read it from the environment variable SFDX_LOG_LEVEL
, and if not found,
Logger.DEFAULT_LOG_LEVEL will be used instead. For convenience this
object is returned.
Optional
level: numberThe logger level.
Throws SfError{ name: 'UnrecognizedLoggerLevelNameError' } A value of level
read from SFDX_LOG_LEVEL
was invalid.
// Sets the level from the environment or default value
logger.setLevel()
// Set the level from the INFO enum
logger.setLevel(LoggerLevel.INFO)
// Sets the level case-insensitively from a string value
logger.setLevel(Logger.getLevelByName('info'))
Static
childStatic
childStatic
getGets a numeric LoggerLevel
value by string name.
The level name to convert to a LoggerLevel
enum value.
Throws SfError{ name: 'UnrecognizedLoggerLevelNameError' } The level name was not case-insensitively recognized as a valid LoggerLevel
value.
{@Link LoggerLevel}
Static
getStatic
getStatic
root
A logging abstraction powered by Pino that provides both a default logger configuration that will log to the default path, and a way to create custom loggers based on the same foundation.
See https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_log_messages.htm