You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+32-13Lines changed: 32 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,14 @@ First step is to create a root logger. Its configuration can be specified on cre
8
8
9
9
```js
10
10
constlogger=require('ackee-node-logger');
11
-
//of
11
+
//or
12
12
constlogger=require('ackee-node-logger')();
13
13
```
14
14
15
15
### Create root logger with custom configuration
16
16
17
17
```js
18
-
constlogger=require('ackee-node-logger)({
18
+
constlogger=require('ackee-node-logger')({
19
19
disableFields: ['error.stack'],
20
20
enableFields: ['req.protocol']
21
21
});
@@ -38,12 +38,12 @@ The only difference between root logger and a child logger is that the child log
38
38
Logger itself is an enhanced and specifically configured `pino` instance, so you may use all basic `pino` log methods
39
39
40
40
```js
41
-
pino.info('hello world')
42
-
pino.error('this is at error level')
43
-
pino.info('the answer is %d', 42)
44
-
pino.info({ obj: 42 }, 'hello world')
45
-
pino.info({ obj: 42, b: 2 }, 'hello world')
46
-
pino.info({ obj: { aa: 'bbb' } }, 'another')
41
+
logger.info('hello world')
42
+
logger.error('this is at error level')
43
+
logger.info('the answer is %d', 42)
44
+
logger.info({ obj:42 }, 'hello world')
45
+
logger.info({ obj:42, b:2 }, 'hello world')
46
+
logger.info({ obj: { aa:'bbb' } }, 'another')
47
47
```
48
48
49
49
All `pino` levels are supported and additionaly there is a `warning` level which is equivalent to `warn` level.
@@ -88,11 +88,8 @@ All those log messages will contain request and possibly response, error, time f
88
88
### Testing
89
89
If the `NODE_ENV` environment variable is set to `test`, all logs are turned off (minimal loglevel is set to `silent` which effectively turns logging off).
90
90
91
-
### Production
92
-
If the `NODE_ENV` environment variable is set to `production`, [standard pino log](https://github.com/pinojs/pino#usage) is used.
93
-
94
91
### Otherwise
95
-
In other cases, minimal loglevel is set to `debug`and [pino pretty human-readable logs](https://github.com/pinojs/pino/blob/master/docs/API.md#pretty) are used.
92
+
[Standard pino log](https://github.com/pinojs/pino#usage) is used and it's optimized for Google Stackdriver logging. That means that default log level is `debug`, pretty print is turned off and [pino's `messageKey` option](https://github.com/pinojs/pino/blob/master/docs/API.md#pinooptions-stream) is set to `message`.
96
93
97
94
## Options
98
95
Options override both default logger configuration and environment-specific configuration. However, do not forget to specify it during the **first**`ackee-node-logger`. During it, root logger is created and it cannot be changed later.
@@ -101,7 +98,8 @@ Options override both default logger configuration and environment-specific conf
101
98
-`disableFields` - list of paths which will be omitted from the objects being logged (if any)
102
99
-`enableFields` - list of paths which will not be omitted by default serializers from objects being logged
103
100
-`streams` - list of stream objects, which will be passed directly to [pino-multistream's multistream function](https://github.com/pinojs/pino-multi-stream#pinomsmultistreamstreams) instead of default `ackee-node-logger` stream
-`pretty` - if set to `true`, logger will use [pino pretty human-readable logs](https://github.com/pinojs/pino/blob/master/docs/API.md#pretty). This option can be overriden by `streams`
102
+
-`config` - object, which will be passed to underlying logger object. Right now, underlying logger is [pino](https://github.com/pinojs/pino), so for available options see [pino API docs](https://github.com/pinojs/pino/blob/master/docs/API.md#pinooptions-stream)
105
103
106
104
## Default serializers
107
105
`ackee-node-logger` defines some [pino serializers](https://github.com/pinojs/pino/blob/master/docs/API.md#constructor) on its own
@@ -110,3 +108,24 @@ Options override both default logger configuration and environment-specific conf
110
108
-`processEnv` - logs `NODE_PATH` and `NODE_ENV`
111
109
-`req` - logs `body`, `query`, `url`, `method` and omits `password` and `passwordCheck` from `body` and `query`
112
110
-`res` - logs `out` and `time`
111
+
112
+
113
+
## Tips
114
+
115
+
### VS Code debugging not showing log messages
116
+
117
+
This problem is caused by a way VS Code handles console output. Therefore it appears in Winston and pino (underlying library of ackee-node-logger) as well.
118
+
119
+
However, it can be easily solved by adding eithe
120
+
121
+
```js
122
+
"console":"integratedTerminal",
123
+
```
124
+
125
+
or
126
+
127
+
```js
128
+
"outputCapture":"std"
129
+
```
130
+
131
+
to the debug configuration in your `launch.json` file.
0 commit comments