@lakutata/logger 0.0.0-stage → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +137 -2
- package/THIRD_PARTY_NOTICES.md +158 -0
- package/dist/cjs/Logger.d.ts +291 -0
- package/dist/cjs/Logger.js +185 -0
- package/dist/cjs/exports/Logger.d.ts +2 -0
- package/dist/cjs/exports/Logger.js +20 -0
- package/dist/cjs/lib/Colors.d.ts +8 -0
- package/dist/cjs/lib/Colors.js +48 -0
- package/dist/cjs/lib/Destination.d.ts +38 -0
- package/dist/cjs/lib/Destination.js +103 -0
- package/dist/cjs/lib/Format.d.ts +7 -0
- package/dist/cjs/lib/Format.js +106 -0
- package/dist/cjs/lib/Pretty.d.ts +9 -0
- package/dist/cjs/lib/Pretty.js +265 -0
- package/dist/cjs/lib/Record.d.ts +25 -0
- package/dist/cjs/lib/Record.js +139 -0
- package/dist/cjs/lib/Serializers.d.ts +26 -0
- package/dist/cjs/lib/Serializers.js +150 -0
- package/dist/cjs/lib/Stringify.d.ts +5 -0
- package/dist/cjs/lib/Stringify.js +110 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Logger.js +182 -0
- package/dist/esm/exports/Logger.js +1 -0
- package/dist/esm/lib/Colors.js +45 -0
- package/dist/esm/lib/Destination.js +99 -0
- package/dist/esm/lib/Format.js +103 -0
- package/dist/esm/lib/Pretty.js +262 -0
- package/dist/esm/lib/Record.js +134 -0
- package/dist/esm/lib/Serializers.js +143 -0
- package/dist/esm/lib/Stringify.js +107 -0
- package/dist/types/Logger.d.ts +291 -0
- package/dist/types/exports/Logger.d.ts +2 -0
- package/dist/types/lib/Colors.d.ts +8 -0
- package/dist/types/lib/Destination.d.ts +38 -0
- package/dist/types/lib/Format.d.ts +7 -0
- package/dist/types/lib/Pretty.d.ts +9 -0
- package/dist/types/lib/Record.d.ts +25 -0
- package/dist/types/lib/Serializers.d.ts +26 -0
- package/dist/types/lib/Stringify.d.ts +5 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Lakutata
|
|
4
|
+
|
|
5
|
+
All rights reserved
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lakutata/logger
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The logger component of the lakutata framework: it writes the log format of pino (one JSON object per line) or
|
|
4
|
+
readable, colored lines, to stdout or any writable streams, buffered for speed and flushed when the process exits. The
|
|
5
|
+
umbrella package `lakutata` presets it as the `log` component of every application (created first, so the framework
|
|
6
|
+
logs through it too) and re-exports it as `lakutata/com/logger`.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
npm install lakutata
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It has no optional dependencies.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Configuring the preset logger
|
|
19
|
+
|
|
20
|
+
An application of `lakutata` already has its logger, named `log`: configure it through the `log` entry of its
|
|
21
|
+
`components` (no `class` needed), and get it with `@Inject('log')` or `getObject('log')`; it is a singleton.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {createWriteStream} from 'node:fs'
|
|
25
|
+
import {Application, Component} from 'lakutata'
|
|
26
|
+
import {Inject} from 'lakutata/decorator/di'
|
|
27
|
+
import {Logger} from 'lakutata/com/logger'
|
|
28
|
+
|
|
29
|
+
class Orders extends Component {
|
|
30
|
+
@Inject('log')
|
|
31
|
+
protected readonly log: Logger
|
|
32
|
+
|
|
33
|
+
public pay(orderId: number, amount: number): void {
|
|
34
|
+
this.log.info({orderId: orderId, amount: amount}, 'order %d paid', orderId)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Application
|
|
39
|
+
.run(() => ({
|
|
40
|
+
id: 'shop.app',
|
|
41
|
+
name: 'Shop',
|
|
42
|
+
components: {
|
|
43
|
+
log: {
|
|
44
|
+
//trace, debug, info, warn, error, fatal or silent
|
|
45
|
+
level: 'info',
|
|
46
|
+
//JSON lines for a log collector
|
|
47
|
+
pretty: false,
|
|
48
|
+
destinations: [process.stdout, createWriteStream('shop.log', {flags: 'a'})]
|
|
49
|
+
},
|
|
50
|
+
orders: {class: Orders}
|
|
51
|
+
}
|
|
52
|
+
}))
|
|
53
|
+
.onLaunched(async (app: Application): Promise<void> => {
|
|
54
|
+
const orders: Orders = await app.getObject('orders')
|
|
55
|
+
orders.pay(42, 9.9)
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Option | Default | What it does |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `level` | `'trace'` | The lowest level written: `'trace'` (10), `'debug'` (20), `'info'` (30), `'warn'` (40), `'error'` (50), `'fatal'` (60, only `fatal()`) or `'silent'` (nothing) |
|
|
62
|
+
| `pretty` | `true` | Readable lines when `true`, pino's JSON lines when `false` |
|
|
63
|
+
| `colorize` | `true` | Colors the readable lines written to `process.stdout` (never the other streams, nor the JSON) |
|
|
64
|
+
| `sync` | `false` | Writes each line at once; otherwise the lines are buffered until the next turn of the event loop (or 16 KB) |
|
|
65
|
+
| `destinations` | `[process.stdout]` | The writable streams receiving every line; not closed by the logger |
|
|
66
|
+
| `redactedHeaders` | `['authorization', 'cookie', 'set-cookie', 'proxy-authorization']` | The headers of a logged request or response written as `[Redacted]` (case-insensitive); the list replaces the default one, `[]` redacts none |
|
|
67
|
+
|
|
68
|
+
### Logging
|
|
69
|
+
|
|
70
|
+
Each method (`error`, `warn`, `info`, `debug`, `trace`) takes the arguments of pino: an optional object of properties,
|
|
71
|
+
then a message with printf-style placeholders, then their values.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import {Logger} from 'lakutata/com/logger'
|
|
75
|
+
|
|
76
|
+
declare const log: Logger
|
|
77
|
+
|
|
78
|
+
//A message, with placeholders: %s string, %d / %f number, %i integer, %o / %O / %j JSON, %% a percent sign
|
|
79
|
+
log.info('user %s signed in from %s', 'alice', '10.0.0.7')
|
|
80
|
+
//Properties added to the line, then the message
|
|
81
|
+
log.warn({orderId: 42, retries: 3}, 'payment retried %d times', 3)
|
|
82
|
+
//An error: written under "err" (type, message, stack, causes, own properties); its message is the default message
|
|
83
|
+
log.error(new Error('connection refused'), 'payment failed')
|
|
84
|
+
log.debug({query: 'SELECT 1', durationMs: 2.4})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The JSON line of the second call:
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
{"level":40,"time":1791117611866,"pid":4242,"hostname":"api-1","name":"Shop","orderId":42,"retries":3,"msg":"payment retried 3 times"}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
and its readable line:
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
[14:20:11.866] WARN (Shop/4242): payment retried 3 times
|
|
97
|
+
orderId: 42
|
|
98
|
+
retries: 3
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- **Errors**: an `Error` (or an `err` property) is serialized with its type, its message followed by the messages of
|
|
102
|
+
its causes, its stack followed by its causes' stacks, its aggregated errors and its own enumerable properties.
|
|
103
|
+
- **HTTP**: a request (`IncomingMessage`) is written under `req` (method, URL, query, params, headers, remote address
|
|
104
|
+
and port), a response under `res` (status code, headers).
|
|
105
|
+
- **Redaction**: the `Authorization`, `Cookie`, `Set-Cookie` and `Proxy-Authorization` headers of a logged request or
|
|
106
|
+
response are written as `[Redacted]` (the `redactedHeaders` option). Nothing else is redacted: log the fields you
|
|
107
|
+
need, not tokens, passwords or whole objects holding them.
|
|
108
|
+
- **Fatal errors**: `fatal()` logs at level 60, above `error`, and writes the pending lines at once, before the process
|
|
109
|
+
exits.
|
|
110
|
+
- **No child loggers**: add the context (a request ID) to the object of each call.
|
|
111
|
+
- **Buffering**: unless `sync` is on, the lines are written at the next turn of the event loop; `flush()` writes them
|
|
112
|
+
at once, and the logger flushes when the process exits or the component is destroyed. A stream with a file
|
|
113
|
+
descriptor (stdout, stderr, a file) is written synchronously, so the lines keep their order.
|
|
114
|
+
|
|
115
|
+
## API
|
|
116
|
+
|
|
117
|
+
| Export | What it is |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `Logger` | The component: `fatal()`, `error()`, `warn()`, `info()`, `debug()`, `trace()`, `flush()`; the options `level`, `pretty`, `colorize`, `sync`, `destinations`, `redactedHeaders` |
|
|
120
|
+
| `ILogger` | The interface of the application loggers (from `@lakutata/core`): the five log methods `error()` to `trace()` (not `fatal()`, which only `Logger` has) |
|
|
121
|
+
| `ILogMethod` | The signatures of a log method: `(obj, msg?, ...args)` or `(msg, ...args)` |
|
|
122
|
+
|
|
123
|
+
All are exported by `lakutata/com/logger` and `@lakutata/logger`. The typings document each declaration with examples.
|
|
124
|
+
|
|
125
|
+
## Errors
|
|
126
|
+
|
|
127
|
+
| Exception | When |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `InvalidObjectOptionsException` (from `lakutata`) | The application starts with invalid logger options: an unknown `level`, a destination that is not a stream (`InvalidValueException` when the logger is created outside the checked options, as in a bare `Container`) |
|
|
130
|
+
|
|
131
|
+
A log method never throws for what it logs: the values that cannot be serialized (functions, symbols) are left out,
|
|
132
|
+
and the circular references are replaced.
|
|
133
|
+
|
|
134
|
+
## See also
|
|
135
|
+
|
|
136
|
+
- `doc/en/Core.md` of the package `lakutata` (Chinese in `doc/zh`): the components and the application lifecycle.
|
|
137
|
+
- `@lakutata/core` (`lakutata`): `Application`, the components and the console logger of core.
|
|
138
|
+
- `@lakutata/monitor` (`lakutata/com/monitor`): the process monitors, whose statistics the logger can report.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Parts of `@lakutata/logger` are derived from the third-party projects listed below: the log line format, the
|
|
4
|
+
message formatting, the serializers and the pretty format reproduce their behavior (the format of lakutata 2.x).
|
|
5
|
+
They are rewritten in TypeScript and modified; the original copyright notices and license terms are reproduced
|
|
6
|
+
here as required.
|
|
7
|
+
|
|
8
|
+
## pino 10.1.0
|
|
9
|
+
|
|
10
|
+
Used in `src/lib/Record.ts` (log lines).
|
|
11
|
+
|
|
12
|
+
The MIT License (MIT)
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2016-2025 Matteo Collina, David Mark Clements and the Pino contributors listed at <https://github.com/pinojs/pino#the-team> and in the README file.
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
|
|
34
|
+
## pino-pretty 13.1.2
|
|
35
|
+
|
|
36
|
+
Used in `src/lib/Pretty.ts` and `src/lib/Colors.ts` (pretty format).
|
|
37
|
+
|
|
38
|
+
The MIT License (MIT)
|
|
39
|
+
|
|
40
|
+
Copyright (c) 2019 the Pino team listed at https://github.com/pinojs/pino#the-team
|
|
41
|
+
|
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
43
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
44
|
+
in the Software without restriction, including without limitation the rights
|
|
45
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
46
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
47
|
+
furnished to do so, subject to the following conditions:
|
|
48
|
+
|
|
49
|
+
The above copyright notice and this permission notice shall be included in all
|
|
50
|
+
copies or substantial portions of the Software.
|
|
51
|
+
|
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
54
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
55
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
56
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
57
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
58
|
+
SOFTWARE.
|
|
59
|
+
|
|
60
|
+
## pino-std-serializers 7.0.0
|
|
61
|
+
|
|
62
|
+
Used in `src/lib/Serializers.ts`.
|
|
63
|
+
|
|
64
|
+
Copyright Mateo Collina, David Mark Clements, James Sumners
|
|
65
|
+
|
|
66
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
67
|
+
|
|
68
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
69
|
+
|
|
70
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
71
|
+
|
|
72
|
+
## quick-format-unescaped 4.0.4
|
|
73
|
+
|
|
74
|
+
Used in `src/lib/Format.ts`.
|
|
75
|
+
|
|
76
|
+
The MIT License (MIT)
|
|
77
|
+
|
|
78
|
+
Copyright (c) 2016-2019 David Mark Clements
|
|
79
|
+
|
|
80
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
81
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
82
|
+
in the Software without restriction, including without limitation the rights
|
|
83
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
84
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
85
|
+
furnished to do so, subject to the following conditions:
|
|
86
|
+
|
|
87
|
+
The above copyright notice and this permission notice shall be included in all
|
|
88
|
+
copies or substantial portions of the Software.
|
|
89
|
+
|
|
90
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
91
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
92
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
93
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
94
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
95
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
96
|
+
SOFTWARE.
|
|
97
|
+
|
|
98
|
+
## safe-stable-stringify 2.5.0
|
|
99
|
+
|
|
100
|
+
Used in `src/lib/Stringify.ts`.
|
|
101
|
+
|
|
102
|
+
The MIT License (MIT)
|
|
103
|
+
|
|
104
|
+
Copyright (c) Ruben Bridgewater
|
|
105
|
+
|
|
106
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
107
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
108
|
+
in the Software without restriction, including without limitation the rights
|
|
109
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
110
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
111
|
+
furnished to do so, subject to the following conditions:
|
|
112
|
+
|
|
113
|
+
The above copyright notice and this permission notice shall be included in all
|
|
114
|
+
copies or substantial portions of the Software.
|
|
115
|
+
|
|
116
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
117
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
118
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
119
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
120
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
121
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
122
|
+
SOFTWARE.
|
|
123
|
+
|
|
124
|
+
## colorette 2.0.20
|
|
125
|
+
|
|
126
|
+
Used in `src/lib/Colors.ts`.
|
|
127
|
+
|
|
128
|
+
Copyright © Jorge Bucaran <<https://jorgebucaran.com>>
|
|
129
|
+
|
|
130
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
131
|
+
|
|
132
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
133
|
+
|
|
134
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
135
|
+
|
|
136
|
+
## secure-json-parse 4.1.0
|
|
137
|
+
|
|
138
|
+
Used in `src/lib/Pretty.ts` (prototype properties).
|
|
139
|
+
|
|
140
|
+
Copyright (c) 2019, Sideway Inc, and project contributors
|
|
141
|
+
Copyright (c) 2019-present The Fastify team
|
|
142
|
+
All rights reserved.
|
|
143
|
+
|
|
144
|
+
The Fastify team members are listed at https://github.com/fastify/fastify#team.
|
|
145
|
+
|
|
146
|
+
The complete list of contributors can be found at:
|
|
147
|
+
- https://github.com/hapijs/bourne/graphs/contributors
|
|
148
|
+
- https://github.com/fastify/secure-json-parse/graphs/contributors
|
|
149
|
+
|
|
150
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
151
|
+
|
|
152
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
153
|
+
|
|
154
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
155
|
+
|
|
156
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
157
|
+
|
|
158
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { Component } from '@lakutata/core';
|
|
2
|
+
import type { ILogger } from '@lakutata/core/com/logger';
|
|
3
|
+
/**
|
|
4
|
+
* The logger component of the applications built with `lakutata`: the package presets it as the `log` component (and
|
|
5
|
+
* creates it first), so the framework and the application log through it. It writes the pino log format: one JSON
|
|
6
|
+
* object per line, with `level` (10 trace, 20 debug, 30 info, 40 warn, 50 error, 60 fatal), `time` (milliseconds since the epoch),
|
|
7
|
+
* `pid`, `hostname`, `name` (the application's name), the properties of the logged object and `msg`; with `pretty` on
|
|
8
|
+
* (the default), it writes readable lines instead: `[HH:MM:ss.SSS] LEVEL (name/pid): message`, then one indented line
|
|
9
|
+
* per property, in the local time zone.
|
|
10
|
+
*
|
|
11
|
+
* Configure it through the `log` entry of the application's `components` (no `class` needed:
|
|
12
|
+
* `log: {level: 'info', pretty: false}`), and get it with `@Inject('log')` or `getObject('log')`; it is a singleton.
|
|
13
|
+
* The lines are buffered and written at the next turn of the event loop (or once 16 KB are pending), and the pending
|
|
14
|
+
* lines are written synchronously when the process exits or the component is destroyed; `sync: true` writes each line
|
|
15
|
+
* at once instead. A stream with a file descriptor (stdout, stderr, an opened file) is written synchronously through
|
|
16
|
+
* it, so the lines keep their order.
|
|
17
|
+
*
|
|
18
|
+
* An HTTP request or response logged as the object of a line is written under `req` or `res` with the values of its
|
|
19
|
+
* credential headers (`Authorization`, `Cookie`, `Set-Cookie`, `Proxy-Authorization`) replaced by `[Redacted]` (see
|
|
20
|
+
* the `redactedHeaders` option). Nothing else is redacted and there are no child loggers: the other properties are
|
|
21
|
+
* written as is, so log the fields you need rather than secrets or whole objects holding them.
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import {Application, Component} from 'lakutata'
|
|
25
|
+
* import {Inject} from 'lakutata/decorator/di'
|
|
26
|
+
* import {Logger} from 'lakutata/com/logger'
|
|
27
|
+
*
|
|
28
|
+
* class Orders extends Component {
|
|
29
|
+
* @Inject('log')
|
|
30
|
+
* protected readonly log: Logger
|
|
31
|
+
*
|
|
32
|
+
* public pay(orderId: number, amount: number): void {
|
|
33
|
+
* //{"level":30,...,"orderId":42,"msg":"order 42 paid: 9.90"}
|
|
34
|
+
* this.log.info({orderId: orderId}, 'order %d paid: %s', orderId, amount.toFixed(2))
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* public fail(error: Error): void {
|
|
38
|
+
* //The error serialized under "err", its message as the message unless one is given
|
|
39
|
+
* this.log.error(error, 'payment failed')
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* Application.run(() => ({
|
|
44
|
+
* id: 'shop.app',
|
|
45
|
+
* name: 'Shop',
|
|
46
|
+
* components: {
|
|
47
|
+
* //The preset logger: JSON lines from the info level in production
|
|
48
|
+
* log: {level: 'info', pretty: process.env.NODE_ENV !== 'production'},
|
|
49
|
+
* orders: {class: Orders}
|
|
50
|
+
* }
|
|
51
|
+
* }))
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare class Logger extends Component implements ILogger {
|
|
55
|
+
#private;
|
|
56
|
+
/**
|
|
57
|
+
* Write readable lines (`[HH:MM:ss.SSS] LEVEL (name/pid): message`, then the properties) when `true`, the JSON lines
|
|
58
|
+
* of pino when `false` (for a log collector).
|
|
59
|
+
* @default true
|
|
60
|
+
* @protected
|
|
61
|
+
*/
|
|
62
|
+
protected readonly pretty: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The lowest level written: `'trace'`, `'debug'`, `'info'`, `'warn'`, `'error'`, `'fatal'` (only the lines of
|
|
65
|
+
* {@link Logger.fatal}) or `'silent'` (nothing); the lines of lower levels are dropped.
|
|
66
|
+
* @default 'trace'
|
|
67
|
+
* @protected
|
|
68
|
+
*/
|
|
69
|
+
protected readonly level: string;
|
|
70
|
+
/**
|
|
71
|
+
* Color the readable lines written to `process.stdout` (the level, the message, the properties); the other
|
|
72
|
+
* destinations and the JSON lines are never colored.
|
|
73
|
+
* @default true
|
|
74
|
+
* @protected
|
|
75
|
+
*/
|
|
76
|
+
protected readonly colorize: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Write each line at once when `true`; when `false`, the lines are buffered and written at the next turn of the
|
|
79
|
+
* event loop (or once 16 KB are pending), which costs less per line. The pending lines are written synchronously when
|
|
80
|
+
* the process exits either way.
|
|
81
|
+
* @default false
|
|
82
|
+
* @protected
|
|
83
|
+
*/
|
|
84
|
+
protected readonly sync: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The streams the lines are written to, each receiving every line: `process.stdout`, `process.stderr`, a file
|
|
87
|
+
* (`fs.createWriteStream(path, {flags: 'a'})`) or any writable stream. The streams are not closed by the logger.
|
|
88
|
+
* @default [process.stdout]
|
|
89
|
+
* @protected
|
|
90
|
+
*/
|
|
91
|
+
protected readonly destinations: NodeJS.WritableStream[];
|
|
92
|
+
/**
|
|
93
|
+
* The headers whose values are written as `[Redacted]` when an HTTP request or response (of `node:http`, Express,
|
|
94
|
+
* Fastify) is logged as the object of a line, by name (case-insensitive). The list replaces the default one: to
|
|
95
|
+
* redact another header, list the default ones with it; `[]` writes every header as is. The headers of the request
|
|
96
|
+
* or response are not changed.
|
|
97
|
+
* @default ['authorization', 'cookie', 'set-cookie', 'proxy-authorization']
|
|
98
|
+
* @protected
|
|
99
|
+
*/
|
|
100
|
+
protected readonly redactedHeaders: string[];
|
|
101
|
+
/**
|
|
102
|
+
* Set up the destinations and the level, and register the logger to flush its pending lines when the process exits.
|
|
103
|
+
* @protected
|
|
104
|
+
*/
|
|
105
|
+
protected init(): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Write the pending lines and stop flushing at the process exit.
|
|
108
|
+
* @protected
|
|
109
|
+
*/
|
|
110
|
+
protected destroy(): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Build a log line and write it to every destination, unless its level is below the configured `level`.
|
|
113
|
+
* @param level The numeric level of the line: 10 trace, 20 debug, 30 info, 40 warn, 50 error, 60 fatal.
|
|
114
|
+
* @param args The arguments of the log method: `[obj, msg, ...args]` or `[msg, ...args]`.
|
|
115
|
+
* @protected
|
|
116
|
+
*/
|
|
117
|
+
protected write(level: number, args: unknown[]): void;
|
|
118
|
+
/**
|
|
119
|
+
* Write the buffered lines now, synchronously for the streams with a file descriptor (before a `process.exit()`
|
|
120
|
+
* in a signal handler, for instance). Does nothing with `sync: true`.
|
|
121
|
+
*/
|
|
122
|
+
flush(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Log a fatal error (a failure the application cannot continue after, logged before it exits) at the `fatal`
|
|
125
|
+
* level (60), unless the configured `level` is `'silent'`. The line and the pending ones are written at once, as
|
|
126
|
+
* by {@link Logger.flush}.
|
|
127
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
128
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
129
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
130
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
131
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
132
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
133
|
+
*/
|
|
134
|
+
fatal<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
135
|
+
/**
|
|
136
|
+
* Log a fatal error (a failure the application cannot continue after, logged before it exits) at the `fatal`
|
|
137
|
+
* level (60), unless the configured `level` is `'silent'`. The line and the pending ones are written at once, as
|
|
138
|
+
* by {@link Logger.flush}.
|
|
139
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
140
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
141
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
142
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
143
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
144
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
145
|
+
*/
|
|
146
|
+
fatal(obj: unknown, msg?: string, ...args: any[]): void;
|
|
147
|
+
/**
|
|
148
|
+
* Log a fatal error (a failure the application cannot continue after, logged before it exits) at the `fatal`
|
|
149
|
+
* level (60), unless the configured `level` is `'silent'`. The line and the pending ones are written at once, as
|
|
150
|
+
* by {@link Logger.flush}.
|
|
151
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
152
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
153
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
154
|
+
*/
|
|
155
|
+
fatal(msg: string, ...args: any[]): void;
|
|
156
|
+
/**
|
|
157
|
+
* Log an error (a failure the application needs to act on) at the `error` level (50), unless the configured `level` is higher.
|
|
158
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
159
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
160
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
161
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
162
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
163
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
164
|
+
*/
|
|
165
|
+
error<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
166
|
+
/**
|
|
167
|
+
* Log an error (a failure the application needs to act on) at the `error` level (50), unless the configured `level` is higher.
|
|
168
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
169
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
170
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
171
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
172
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
173
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
174
|
+
*/
|
|
175
|
+
error(obj: unknown, msg?: string, ...args: any[]): void;
|
|
176
|
+
/**
|
|
177
|
+
* Log an error (a failure the application needs to act on) at the `error` level (50), unless the configured `level` is higher.
|
|
178
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
179
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
180
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
181
|
+
*/
|
|
182
|
+
error(msg: string, ...args: any[]): void;
|
|
183
|
+
/**
|
|
184
|
+
* Log a warning (an unexpected event the application recovers from) at the `warn` level (40), unless the configured `level` is higher.
|
|
185
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
186
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
187
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
188
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
189
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
190
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
191
|
+
*/
|
|
192
|
+
warn<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
193
|
+
/**
|
|
194
|
+
* Log a warning (an unexpected event the application recovers from) at the `warn` level (40), unless the configured `level` is higher.
|
|
195
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
196
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
197
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
198
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
199
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
200
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
201
|
+
*/
|
|
202
|
+
warn(obj: unknown, msg?: string, ...args: any[]): void;
|
|
203
|
+
/**
|
|
204
|
+
* Log a warning (an unexpected event the application recovers from) at the `warn` level (40), unless the configured `level` is higher.
|
|
205
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
206
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
207
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
208
|
+
*/
|
|
209
|
+
warn(msg: string, ...args: any[]): void;
|
|
210
|
+
/**
|
|
211
|
+
* Log an information (the normal course of the application) at the `info` level (30), unless the configured `level` is higher.
|
|
212
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
213
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
214
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
215
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
216
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
217
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
218
|
+
*/
|
|
219
|
+
info<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
220
|
+
/**
|
|
221
|
+
* Log an information (the normal course of the application) at the `info` level (30), unless the configured `level` is higher.
|
|
222
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
223
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
224
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
225
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
226
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
227
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
228
|
+
*/
|
|
229
|
+
info(obj: unknown, msg?: string, ...args: any[]): void;
|
|
230
|
+
/**
|
|
231
|
+
* Log an information (the normal course of the application) at the `info` level (30), unless the configured `level` is higher.
|
|
232
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
233
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
234
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
235
|
+
*/
|
|
236
|
+
info(msg: string, ...args: any[]): void;
|
|
237
|
+
/**
|
|
238
|
+
* Log a debugging detail at the `debug` level (20), unless the configured `level` is higher.
|
|
239
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
240
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
241
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
242
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
243
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
244
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
245
|
+
*/
|
|
246
|
+
debug<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
247
|
+
/**
|
|
248
|
+
* Log a debugging detail at the `debug` level (20), unless the configured `level` is higher.
|
|
249
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
250
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
251
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
252
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
253
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
254
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
255
|
+
*/
|
|
256
|
+
debug(obj: unknown, msg?: string, ...args: any[]): void;
|
|
257
|
+
/**
|
|
258
|
+
* Log a debugging detail at the `debug` level (20), unless the configured `level` is higher.
|
|
259
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
260
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
261
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
262
|
+
*/
|
|
263
|
+
debug(msg: string, ...args: any[]): void;
|
|
264
|
+
/**
|
|
265
|
+
* Log a tracing detail, finer than debug at the `trace` level (10), unless the configured `level` is higher.
|
|
266
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
267
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
268
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
269
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
270
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
271
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
272
|
+
*/
|
|
273
|
+
trace<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
274
|
+
/**
|
|
275
|
+
* Log a tracing detail, finer than debug at the `trace` level (10), unless the configured `level` is higher.
|
|
276
|
+
* @param obj The properties added to the line (`{orderId: 42}`). An `Error` is written under `err` (its type,
|
|
277
|
+
* message, stack, causes and own properties), its message becoming the message when `msg` is omitted; an HTTP
|
|
278
|
+
* request or response of `node:http` is written under `req` or `res`, its credential headers redacted.
|
|
279
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
280
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
281
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
282
|
+
*/
|
|
283
|
+
trace(obj: unknown, msg?: string, ...args: any[]): void;
|
|
284
|
+
/**
|
|
285
|
+
* Log a tracing detail, finer than debug at the `trace` level (10), unless the configured `level` is higher.
|
|
286
|
+
* @param msg The message, with printf-style placeholders replaced by `args`: `%s` (string), `%d` and `%f` (number),
|
|
287
|
+
* `%i` (integer), `%o`, `%O` and `%j` (JSON), `%%` (a percent sign).
|
|
288
|
+
* @param args The values of the placeholders of `msg`, in order; the values without a placeholder are dropped.
|
|
289
|
+
*/
|
|
290
|
+
trace(msg: string, ...args: any[]): void;
|
|
291
|
+
}
|