@@ -12,6 +12,14 @@ JSON logger for Node.js.
1212 * [ Prepending context using the global state] ( #prepending-context-using-the-global-state )
1313 * [ Filtering logs] ( #filtering-logs )
1414 * [ jq primer] ( #jq-primer )
15+ * [ API] ( #api )
16+ * [ ` child ` ] ( #child )
17+ * [ ` trace ` ] ( #trace )
18+ * [ ` debug ` ] ( #debug )
19+ * [ ` info ` ] ( #info )
20+ * [ ` warn ` ] ( #warn )
21+ * [ ` error ` ] ( #error )
22+ * [ ` fatal ` ] ( #fatal )
1523* [ Transports] ( #transports )
1624* [ Environment variables] ( #environment-variables )
1725* [ Conventions] ( #conventions )
@@ -26,56 +34,13 @@ ROARR_LOG=true node ./index.js
2634
2735```
2836
29- ` roarr ` package exports a function that accepts the following API:
30-
31- ``` js
32- export type LoggerType =
33- (
34- context: MessageContextType,
35- message: string,
36- c?: SprintfArgumentType,
37- d?: SprintfArgumentType,
38- e?: SprintfArgumentType,
39- f?: SprintfArgumentType,
40- g?: SprintfArgumentType,
41- h?: SprintfArgumentType,
42- i?: SprintfArgumentType,
43- k?: SprintfArgumentType
44- ) => void |
45- (
46- message: string,
47- b?: SprintfArgumentType,
48- c?: SprintfArgumentType,
49- d?: SprintfArgumentType,
50- e?: SprintfArgumentType,
51- f?: SprintfArgumentType,
52- g?: SprintfArgumentType,
53- h?: SprintfArgumentType,
54- i?: SprintfArgumentType,
55- k?: SprintfArgumentType
56- ) => void ;
57-
58- ```
59-
60- Put it into words:
61-
62- 1 . First parameter can be either a string (message) or an object.
63- * If first parameter is an object (context), the second parameter must be a string (message).
64- 1 . Arguments after the message parameter are used to enable [ printf message formatting] ( https://en.wikipedia.org/wiki/Printf_format_string ) .
65- * Printf arguments must be of a primitive type (` string | number | boolean | null ` ).
66- * There can be up to 9 printf arguments (or 8 if the first parameter is the context object).
67-
68- <!-- -->
69-
7037``` js
7138import log from ' roarr' ;
7239
7340log (' foo' );
7441
7542log (' bar %s' , ' baz' );
7643
77- // Creates a child logger appending the provided `context` object
78- // to the previous logger context.
7944const debug = log .child ({
8045 level: ' debug'
8146});
@@ -184,6 +149,81 @@ ROARR_LOG=true node ./index.js | jq 'select(.context.level == "warning" or .cont
184149
185150```
186151
152+ ## API
153+
154+ ` roarr ` package exports a function that accepts the following API:
155+
156+ ``` js
157+ export type LoggerType =
158+ (
159+ context: MessageContextType,
160+ message: string,
161+ c?: SprintfArgumentType,
162+ d?: SprintfArgumentType,
163+ e?: SprintfArgumentType,
164+ f?: SprintfArgumentType,
165+ g?: SprintfArgumentType,
166+ h?: SprintfArgumentType,
167+ i?: SprintfArgumentType,
168+ k?: SprintfArgumentType
169+ ) => void |
170+ (
171+ message: string,
172+ b?: SprintfArgumentType,
173+ c?: SprintfArgumentType,
174+ d?: SprintfArgumentType,
175+ e?: SprintfArgumentType,
176+ f?: SprintfArgumentType,
177+ g?: SprintfArgumentType,
178+ h?: SprintfArgumentType,
179+ i?: SprintfArgumentType,
180+ k?: SprintfArgumentType
181+ ) => void ;
182+
183+ ```
184+
185+ Put it into words:
186+
187+ 1 . First parameter can be either a string (message) or an object.
188+ * If first parameter is an object (context), the second parameter must be a string (message).
189+ 1 . Arguments after the message parameter are used to enable [ printf message formatting] ( https://en.wikipedia.org/wiki/Printf_format_string ) .
190+ * Printf arguments must be of a primitive type (` string | number | boolean | null ` ).
191+ * There can be up to 9 printf arguments (or 8 if the first parameter is the context object).
192+
193+ Refer to the [ Usage] ( #usage ) documentation for common usage examples.
194+
195+ ### ` child `
196+
197+ Creates a child logger appending the provided ` context ` object to the previous logger context.
198+
199+ ``` js
200+ type ChildType = (context : MessageContextType ) => LoggerType;
201+
202+ ```
203+
204+ ### ` trace `
205+ ### ` debug `
206+ ### ` info `
207+ ### ` warn `
208+ ### ` error `
209+ ### ` fatal `
210+
211+ Convenience methods for logging a message with ` logLevel ` context property value set to the name of the convenience method, e.g.
212+
213+ ``` js
214+ import log from ' roarr' ;
215+
216+ log .debug (' foo' );
217+
218+ ```
219+
220+ Produces output:
221+
222+ ```
223+ {"context":{"logLevel":"debug"},"message":"foo","sequence":0,"time":1506776210001,"version":"1.0.0"}
224+
225+ ```
226+
187227## Transports
188228
189229A transport in most logging libraries is something that runs in-process to perform some operation with the finalised log line. For example, a transport might send the log line to a standard syslog server after processing the log line and reformatting it.
0 commit comments