1 | # logger
|
2 |
|
3 | [![NPM](https://nodei.co/npm/pelias-logger.png)](https://nodei.co/npm/pelias-logger/)
|
4 |
|
5 | The centralized logger package for Pelias, which wraps [winston](https://github.com/winstonjs/winston) with
|
6 | Pelias-specific transports and default configurations.
|
7 |
|
8 | ### config
|
9 | The logger will set its log levels to the `logger.level` property in `pelias-config`, which should be set to any of the
|
10 | default winston [options](https://github.com/winstonjs/winston#logging-levels). `logger.timestamp` and
|
11 | `logger.colorize` take boolean values (defaulting to `true`) that indicate whether log lines should have a
|
12 | timestamp/be colorized.
|
13 |
|
14 | ### API
|
15 | ##### `get( name, loggerOpts )`
|
16 | Retrieve a logger with a specific name or, if none is found, create a new one.
|
17 |
|
18 | * `name`: the name to search for/assign to the logger
|
19 | * `loggerOpts`: if a new logger has to be created, the options to pass to
|
20 | [`winston.Logger()`](https://github.com/winstonjs/winston#instantiating-your-own-logger)
|
21 |
|
22 | ##### `winston`
|
23 | The winston package is exposed via this option, to provide access to any items needed in custom `loggerOpts` passed to
|
24 | `get()` (like `winston.transports.*` classes).
|
25 |
|
26 | ### example
|
27 | ```javascript
|
28 | var peliasLogger = require( 'pelias-logger' );
|
29 | var logger1 = peliasLogger.get( 'logger1' );
|
30 | var logger2 = peliasLogger.get( 'logger2', {
|
31 | transports: [
|
32 | new peliasLogger.winston.transports.File( {
|
33 | filename: 'output.txt',
|
34 | timestamp: true
|
35 | })
|
36 | ]
|
37 | });
|
38 | logger1.warn( 'hello' );
|
39 | ```
|