Logger
import { Logger, Level } from '@esri/hub-common'
Functions share the console interface
Logger.log('My Message');
Logger.warn('Watch out!', { threat: 'Charizard' });
// etc, etc
Available logging levels are specified in the Level enum. The hierarchy is as follows:
off > error > warn > info > debug > all
Logger only sends messages whose level is greater than or equal to the global log level
// Global level is 'warn'
Logger.info('This message won't log');
Logger.error('But this one will!');
Logger's default level is 'off', so set desired level before use
Logger.setLogLevel(Level.all);
Methods
debug
StaticParameters
Parameter | Type | Default | Notes |
---|---|---|---|
message Required | string | ||
objects Required | any[] |
additional objects to log (optional rest parameter) |
Returns
void
error
StaticLogs to error if level is enabled
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
message Required | string | ||
objects Required | any[] |
additional objects to log (optional rest parameter) |
Returns
void
info
StaticLogs to info if level is enabled
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
message Required | string | ||
objects Required | any[] |
additional objects to log (optional rest parameter) |
Returns
void
log
StaticLogs to debug if level is enabled
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
message Required | string | ||
objects Required | any[] |
additional objects to log (optional rest parameter) |
Returns
void
setLogLevel
StaticSets the global log level
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
level Required | Level |
Returns
void
warn
StaticLogs to warn if level is enabled
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
message Required | string | ||
objects Required | any[] |
additional objects to log (optional rest parameter) |
Returns
void
Class defined in common/src/utils/logger.ts:40
Logs to debug if level is enabled