Logger

Class
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

Method Returns Notes
  • debug(message: string, objects: any[])
void

Logs to debug if level is enabled

  • error(message: string, objects: any[])
void

Logs to error if level is enabled

  • info(message: string, objects: any[])
void

Logs to info if level is enabled

  • log(message: string, objects: any[])
void

Logs to debug if level is enabled

void

Sets the global log level

  • warn(message: string, objects: any[])
void

Logs to warn if level is enabled

debug

Static Static Class Method

Logs to debug if level is enabled

  • debug(message: string, objects: any[]) : void

Parameters

Parameter Type Default Notes
message Required string
objects Required any[]

additional objects to log (optional rest parameter)

Returns

void

error

Static Static Class Method

Logs to error if level is enabled

  • error(message: string, objects: any[]) : void

Parameters

Parameter Type Default Notes
message Required string
objects Required any[]

additional objects to log (optional rest parameter)

Returns

void

info

Static Static Class Method

Logs to info if level is enabled

  • info(message: string, objects: any[]) : void

Parameters

Parameter Type Default Notes
message Required string
objects Required any[]

additional objects to log (optional rest parameter)

Returns

void

log

Static Static Class Method

Logs to debug if level is enabled

  • log(message: string, objects: any[]) : void

Parameters

Parameter Type Default Notes
message Required string
objects Required any[]

additional objects to log (optional rest parameter)

Returns

void

setLogLevel

Static Static Class Method

Sets the global log level

  • setLogLevel(level: Level) : void

Parameters

Parameter Type Default Notes
level Required Level

Returns

void

warn

Static Static Class Method

Logs to warn if level is enabled

  • warn(message: string, objects: any[]) : void

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