Skip to content

Commit 81d9f39

Browse files
committed
lib: address review feedback for logger API
1 parent 16da91e commit 81d9f39

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

doc/api/logger.md

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ const logger = new Logger({
101101
added: REPLACEME
102102
-->
103103

104-
* `msg` {string} Log message.
105-
* `obj` {Object} Object containing `msg` property and additional fields.
106-
* `error` {Error} Error object to log.
104+
* `msg` {string} Log message. When called with a string, logs that string
105+
as the message.
107106
* `fields` {Object} Additional fields to include in the log record.
107+
Only used with the string `msg` signature.
108+
* `obj` {Object} Object containing a required `msg` {string} property
109+
and additional fields that will be included in the log record.
110+
* `error` {Error} Error object to log. The error's `message` property
111+
becomes the log message and the error is serialized into the `err` field.
108112

109113
Logs a message at the `trace` level.
110114

@@ -124,10 +128,14 @@ logger.trace({ msg: 'Object format', requestId: 'abc123' });
124128
added: REPLACEME
125129
-->
126130

127-
* `msg` {string} Log message.
128-
* `obj` {Object} Object containing `msg` property and additional fields.
129-
* `error` {Error} Error object to log.
131+
* `msg` {string} Log message. When called with a string, logs that string
132+
as the message.
130133
* `fields` {Object} Additional fields to include in the log record.
134+
Only used with the string `msg` signature.
135+
* `obj` {Object} Object containing a required `msg` {string} property
136+
and additional fields that will be included in the log record.
137+
* `error` {Error} Error object to log. The error's `message` property
138+
becomes the log message and the error is serialized into the `err` field.
131139

132140
Logs a message at the `debug` level.
133141

@@ -146,10 +154,14 @@ logger.debug('Processing request', { requestId: 'abc123' });
146154
added: REPLACEME
147155
-->
148156

149-
* `msg` {string} Log message.
150-
* `obj` {Object} Object containing `msg` property and additional fields.
151-
* `error` {Error} Error object to log.
157+
* `msg` {string} Log message. When called with a string, logs that string
158+
as the message.
152159
* `fields` {Object} Additional fields to include in the log record.
160+
Only used with the string `msg` signature.
161+
* `obj` {Object} Object containing a required `msg` {string} property
162+
and additional fields that will be included in the log record.
163+
* `error` {Error} Error object to log. The error's `message` property
164+
becomes the log message and the error is serialized into the `err` field.
153165

154166
Logs a message at the `info` level.
155167

@@ -169,10 +181,14 @@ logger.info({ msg: 'User logged in', userId: 123 });
169181
added: REPLACEME
170182
-->
171183

172-
* `msg` {string} Log message.
173-
* `obj` {Object} Object containing `msg` property and additional fields.
174-
* `error` {Error} Error object to log.
184+
* `msg` {string} Log message. When called with a string, logs that string
185+
as the message.
175186
* `fields` {Object} Additional fields to include in the log record.
187+
Only used with the string `msg` signature.
188+
* `obj` {Object} Object containing a required `msg` {string} property
189+
and additional fields that will be included in the log record.
190+
* `error` {Error} Error object to log. The error's `message` property
191+
becomes the log message and the error is serialized into the `err` field.
176192

177193
Logs a message at the `warn` level.
178194

@@ -191,10 +207,14 @@ logger.warn('High memory usage', { memoryUsage: process.memoryUsage() });
191207
added: REPLACEME
192208
-->
193209

194-
* `msg` {string} Log message.
195-
* `obj` {Object} Object containing `msg` property and additional fields.
196-
* `error` {Error} Error object to log.
210+
* `msg` {string} Log message. When called with a string, logs that string
211+
as the message.
197212
* `fields` {Object} Additional fields to include in the log record.
213+
Only used with the string `msg` signature.
214+
* `obj` {Object} Object containing a required `msg` {string} property
215+
and additional fields that will be included in the log record.
216+
* `error` {Error} Error object to log. The error's `message` property
217+
becomes the log message and the error is serialized into the `err` field.
198218

199219
Logs a message at the `error` level.
200220

@@ -214,10 +234,14 @@ logger.error(new Error('Request failed'), { requestId: 'abc123' });
214234
added: REPLACEME
215235
-->
216236

217-
* `msg` {string} Log message.
218-
* `obj` {Object} Object containing `msg` property and additional fields.
219-
* `error` {Error} Error object to log.
237+
* `msg` {string} Log message. When called with a string, logs that string
238+
as the message.
220239
* `fields` {Object} Additional fields to include in the log record.
240+
Only used with the string `msg` signature.
241+
* `obj` {Object} Object containing a required `msg` {string} property
242+
and additional fields that will be included in the log record.
243+
* `error` {Error} Error object to log. The error's `message` property
244+
becomes the log message and the error is serialized into the `err` field.
221245

222246
Logs a message at the `fatal` level.
223247

0 commit comments

Comments
 (0)