ChildLogger
ChildLogger forwards the logs to another logger given in the constructor. This is very useful in order to prepend tag message.
Implements
Extends
Constructor
constructor
constructor(logger :LoggerInterface, tag: string): ChildLogger
Name | Type | Required | Default | Description |
---|---|---|---|---|
logger | LoggerInterface | Yes | - | The logger to forward message to |
tag | string | Yes | - | The tag to happen to every logged message |
Overwritten Methods
log
logger.log(level: enum(LogLevels), msg: string, context :object = null): void
It will forward the log message by just doing
log(level, msg, context = null) {
this.logger.log(level, `[${this.tag}]${msg}`, context);
}
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
level | enum(LogLevels) | Yes | - | The level message |
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Inherited Methods
error
logger.error(msg: string, context :object = null): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Internally calls
this.log(LogLevels.ERROR, msg, context)
which is abstract
warn
logger.warn(msg: string, context :object = null): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Internally calls
this.log(LogLevels.WARN, msg, context)
which is abstract
info
logger.info(msg: string, context :object = null): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Internally calls
this.log(LogLevels.INFO, msg, context)
which is abstract
verbose
logger.verbose(msg: string, context :object = null): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Internally calls
this.log(LogLevels.VERBOSE, msg, context)
which is abstract
debug
logger.debug(msg: string, context :object = null): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Internally calls
this.log(LogLevels.DEBUG, msg, context)
which is abstract
silly
logger.silly(msg: string, context :object = null): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
msg | string | Yes | - | The message to log |
context | ?object | No | null | A context object which should be stringify-able |
Returns:
Type: void
Internally calls
this.log(LogLevels.SILLY, msg, context)
which is abstract