Skip to main content

Logger

Overview

A isomorphic logger available in both the browser and worker environments.

const logger = new Logger('Todo API')
logger.info('Fetching todo', todoID)
logger.error('Unexpected error')

Usage

import { Logger } from 'keywork/logger/classes'

Constructors

constructor

new Logger

(logPrefix, level?, color?)

Parameters

NameTypeDefault value
logPrefixstringundefined
levelLogLevelLogLevel.Warning
colorstring'cyan'

Defined in

logger/classes/Logger.ts:95

Properties

debug

debug: (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`

Type declaration

(message?, ...optionalParams): `void`
Parameters
NameType
message?any
...optionalParamsany[]
Returns

void

Defined in

logger/classes/Logger.ts:90

globalConsole

protected globalConsole: `GlobalConsoleLike`

Defined in

logger/classes/Logger.ts:87

info

info: (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`

Type declaration

(message?, ...optionalParams): `void`
Parameters
NameType
message?any
...optionalParamsany[]
Returns

void

Defined in

logger/classes/Logger.ts:92

level

protected level: `LogLevel` = `DEFAULT_LOG_LEVEL`

Defined in

logger/classes/Logger.ts:86

log

log: (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`

Type declaration

(message?, ...optionalParams): `void`
Parameters
NameType
message?any
...optionalParamsany[]
Returns

void

Defined in

logger/classes/Logger.ts:91

logPrefix

protected logPrefix: `string`

Defined in

logger/classes/Logger.ts:85

trace

trace: (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`

Type declaration

(message?, ...optionalParams): `void`
Parameters
NameType
message?any
...optionalParamsany[]
Returns

void

Defined in

logger/classes/Logger.ts:89

warn

warn: (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`

Type declaration

(message?, ...optionalParams): `void`
Parameters
NameType
message?any
...optionalParamsany[]
Returns

void

Defined in

logger/classes/Logger.ts:93

Methods

_createLogMethod

_createLogMethod

(logType, logTypeLabel, color): (...`args`: `any`[]) => `void`

Parameters

NameType
logTypekeyof GlobalConsoleLike
logTypeLabelstring
colorstring

Returns

fn

(...args): `void`
Parameters
NameType
...argsany[]
Returns

void

Defined in

logger/classes/Logger.ts:115

error

error

(error): `void`

Parameters

NameType
errorunknown

Returns

void

Defined in

logger/classes/Logger.ts:128

json

json

(json): `void`

Parameters

NameType
jsonObject

Returns

void

Defined in

logger/classes/Logger.ts:137

jsonEntries

jsonEntries

jsonEntries<T>(label, json, key): `void`

Type parameters

Name
T

Parameters

NameType
labelstring
jsonIterable<T>
keykeyof T

Returns

void

Defined in

logger/classes/Logger.ts:142