Constructor
new Loggers(options, levelsopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
object
|
||
levels |
object
|
<optional> |
An object with properties levels and colors, both of which are objects whose keys are level names. This is the same object that is provided when creating Winston loggers. See an example at https://www.npmjs.com/package/winston#using-custom-logging-levels |
Members
ready :boolean
Indicates whether this object and its child loggers are ready to log messages. false when messages can not be logged because the logger is stopping or has been stopped.
Type:
-
boolean
winstonLevels :object
Maps level names to integers where lower values have higher severity
Type:
-
object
(static) defaultLevels
These follow npm levels wich are defined at https://github.com/winstonjs/winston#user-content-logging-levels with the addition of:
- 'fail' : more severe than 'error'
- 'db' : more severe than 'http'
- 'more' : after 'info' ('more' noisy than 'info' but less noisy than 'verbose')
Custom levels can be provided to the Loggers class's constructor; however, the Loggers class assumes there is an 'error' level and the options model (via * the defaults) assumes the following levels exist: error, warn, debug.
See also https://github.com/winstonjs/winston#using-custom-logging-levels
(static) defaultMetaProperties
Default meta properties. Values are either null or a string containing the meta property name. For example, given the tuple a: 'b', property a is copied to meta.b.
Methods
category(categoryopt, backupCategoryopt) → {string}
Checks a category value
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
category |
string
|
<optional> |
|
backupCategory |
string
|
<optional> |
Throws:
When this.options.unitTest is true, throws an exception if the category is not a string
Returns:
- Type:
-
string
Returns the provided category if it is a truthy string; otherwise, returns the default category. Logs a warning when the value is truthy and its type is not a string.
flush() → {Promise}
Flushes transports that support flushing, which is currently only CloudWatch.
Returns:
- Type:
-
Promise
(async) flushCloudWatchTransports() → {Promise}
Flushes Cloudwatch transports
Returns:
- Type:
-
Promise
isLevelEnabled(tagsOrNamedParametersopt, categoryopt) → {object}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tagsOrNamedParameters |
*
|
<optional> |
|
category |
string
|
<optional> |
Returns:
- Type:
-
object
If the message will be logged, returns an object with properties tags, logger, level, transports, and category. Otherwise, returns false.
levelEnabled(…argsopt)
Alias for isLevelEnabled
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Array
|
<optional> <repeatable> |
log(tagsopt, messageopt, dataopt, contextopt, categoryopt)
Sends a log entry to transports.
If tags is an Error object, ['error'] is used as the tags and the error is logged with message and data. If tags is an object with tags, message, data, and/or category properties, those properties are used as follows:
- tags = this.tags(tags.logLevel, tags.tags)
- message = tags.message
- data = tags.data
- context = tags.context
- category = tags.category
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tags |
*
|
<optional> |
See description |
message |
*
|
<optional> |
|
data |
*
|
<optional> |
|
context |
*
|
<optional> |
|
category |
string
|
<optional> |
logger(categoryopt) → {Loggers|object}
Returns a logger associated with a category
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
category |
string
|
<optional> |
Returns:
- Type:
-
Loggers
|object
setLogger(categoryopt, loggeropt) → {Logger|undefined}
Associates a logger with a category
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
category |
string
|
<optional> |
|
logger |
Loggers
|
object
|
<optional> |
If falsy, the category will not be associated with a logger. |
stack(nameopt) → {Stack}
Retrieves a named Stack instance
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string
|
<optional> |
Returns:
- Type:
-
Stack
(async) stop() → {Promise}
Flushes loggers and stops them
Throws:
None
Returns:
- Type:
-
Promise
tags(…argsopt) → {object}
Combines tags into a single tags object
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Array
|
<optional> <repeatable> |
Returns:
- Type:
-
object