Members
_lastDelta :number
Last delta time in millisecond since app started. Used for log's time taken feature.
- number
- Source
app :App
Reference to the app instance
- Source
logDir :string
Directory to save log files. Defaults to {dataDir}/log. If log saving is on (see app.config.log.save) and directory does not exist, this directory will be created automatically.
- string
- Source
Methods
debug(prefix, …args)
Display & format message in debug level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Arguments to be passed to the message. See formatMsg for details. |
- Source
(async) dispose() → {Promise.<void>}
Dispose internal references.
- Source
- Type:
- Promise.<void>
error(prefix, …args)
Display & format message in error level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Arguments to be passed to the message. See formatMsg for details. |
- Source
fatal(prefix, …args)
Display & format message in fatal level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Arguments to be passed to the message. See formatMsg for details. |
- Source
formatMsg(level, prefix, …params)
Format & display log message according to the current log level with the following syntax:
levelprefixtextparam 1param 2...param n- Translatetextand interpolate withparamsfor levellevellevelprefix{data}textparam 1param 2...param n- Same as above, but with additional stringifieddataobject to be loggedlevelprefix{error}- Format as Err object. If current log level is trace, dump it on screen
In prod environment, log will be delivered as JSON stringified object. See Log.TJsonOutput for more info
| Name | Type | Attributes | Description |
|---|---|---|---|
level | string | Log level to use | |
prefix | string | Prefix to the message | |
params | * | <repeatable> | See format above |
- Source
getErrorMessage(error) → {string}
Get error message from an Error object. If the error message is empty, return the error code or status code instead.
| Name | Type | Description |
|---|---|---|
error | Error | Error object |
- Source
Error message
- Type:
- string
getRotationPattern(isPrev) → {string}
Calculate pattern used for log rotation. Used by save method to determine the log file name. Rotation pattern is based on the rotation.cycle configuration. See app.config.log.rotation.cycle for more info.
| Name | Type | Description |
|---|---|---|
isPrev | boolean | If |
- Source
Calculated pattern
- Type:
- string
info(prefix, …args)
Display & format message in info level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Arguments to be passed to the message. See formatMsg for details. |
- Source
save(text, prefixopt)
Save log to file in logDir.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text | string | Log message to save | ||
prefix | string | <optional> | 'bajo' | Use prefix as basename. Defaults to |
- Source
silent(prefix, …args)
Display & format message in silent level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Arguments to be passed to the message. See formatMsg for details. |
- Source
trace(prefix, …args)
Display & format message in trace level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Argumets to be passed to the message. See formatMsg for details. |
- Source
warn(prefix, …args)
Display & format message in warn level. See formatMsg for details.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix | |
args | * | <repeatable> | Arguments to be passed to the message. See formatMsg for details. |
- Source
Type Definitions
TJsonOutput
Log output in stringified JSON format. Returned when app run in prod environment.
| Name | Type | Attributes | Description |
|---|---|---|---|
prefix | string | Message prefix. | |
message | string | The message itself. | |
level | string | Log level. | |
time | number | Time in millisecond. | |
pid | number | Process ID. | |
hostname | string | Hostname. | |
data | Object | <optional> | Payload data, if any. |
- Source
TLevels
- Object
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
trace | Object | Properties
| |||||||||||||||
debug | Object | Properties
| |||||||||||||||
info | Object | Properties
| |||||||||||||||
warn | Object | Properties
| |||||||||||||||
error | Object | Properties
| |||||||||||||||
fatal | Object | Properties
| |||||||||||||||
silent | Object | Properties
|
- Source