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
-[Adding global metadata](#adding-global-metadata)
22
+
-[Force logging](#force-logging)
23
+
-[Benchmark](#benchmark)
24
+
-[Contributing](#contributing)
24
25
25
26
## Features
27
+
26
28
-**Configurable log levels**: Set log levels globally or per namespace for detailed control.
27
29
-**Flexible output formats**: Supports JSON, Pretty-print, and custom output adapters.
28
30
-**Context ID support**: Optionally track logs across function calls by assigning a unique context ID.
@@ -33,6 +35,7 @@ A lightweight, flexible logger that merges debug-style namespace management, Win
33
35
## Installation
34
36
35
37
Install via npm, yarn or pnpm:
38
+
36
39
```sh
37
40
npm add @ekino/logger
38
41
yarn add @ekino/logger
@@ -41,17 +44,18 @@ pnpm add @ekino/logger
41
44
42
45
## Usage
43
46
44
-
By default, `@ekino/logger` outputs `warn` and `error` levels for all namespaces, with logs written to stdout in JSON format.
47
+
By default, `@ekino/logger` outputs `warn` and `error` levels for all namespaces, with logs written to stdout in JSON format.
45
48
46
49
Adjust the log level globally or per namespace using the `LOG_LEVEL` environment variable or programmatically with `setLevel` and `setNamespaces`.
47
50
48
51
### Basic logging
49
52
50
-
`@ekino/logger` provides five log levels: `trace`, `debug`, `info`, `warn`, and `error`. Setting a specific level enables it and all higher-priority levels.
53
+
`@ekino/logger` provides five log levels: `trace`, `debug`, `info`, `warn`, and `error`. Setting a specific level enables it and all higher-priority levels.
51
54
52
55
By default, setting info will enable `info`, `warn`, and `error`, but not debug or trace. The log levels are defined as:
53
56
54
57
Log level priorities:
58
+
55
59
```js
56
60
{ trace:0, debug:1, info:2, warn:3, error:4 }
57
61
```
@@ -91,6 +95,7 @@ Output example:
91
95
Namespaces offer flexibility for selectively enabling logs. Set a default global log level and configure specific namespaces with unique levels, including `none` to disable.
Override the log level for critical messages by forcing them to be logged:
192
+
186
193
```js
187
-
logger.debug('Will be logged regardless of level', { forceLogging:true });
194
+
logger.debug('Will be logged regardless of level', { forceLogging:true })
188
195
```
189
196
190
197
## Benchmark
191
-
Below is a performance comparison of several popular Node.js logging libraries, including @ekino/logger. Benchmarks were conducted using Node.js v22.10.0, with results measured in operations per second (higher values indicate better performance).
198
+
199
+
Below is a performance comparison of several popular Node.js logging libraries, including @ekino/logger. Benchmarks were conducted using Node.js v23.13.0, with results measured in operations per second (higher values indicate better performance).
200
+
192
201
```bash
193
202
┌─────────┬──────────────────────┬───────────┐
194
203
│ (index) │ library │ ops/sec │
195
204
├─────────┼──────────────────────┼───────────┤
196
-
│ 0 │ 'Pino'│ '124,828' │
197
-
│ 1 │ '@ekino/logger v3.x'│ '118,385' │
198
-
│ 2 │ '@ekino/logger v2.x' │ '104,004' │
199
-
│ 3 │ 'Winston' │ '67,536' │
205
+
│ 0 │ '@ekino/logger v3.x'│ '129,082' │
206
+
│ 1 │ 'Pino'│ '112,727' │
207
+
│ 2 │ '@ekino/logger v2.x' │ '112,423' │
208
+
│ 3 │ 'Winston' │ '55,411' │
200
209
└─────────┴──────────────────────┴───────────┘
201
210
```
211
+
202
212
**Note**: Benchmark results may vary depending on environment and configuration. This table provides a general reference for relative performance between libraries.
203
213
204
214
For more detailed benchmark results, please refer to the [benchmarks](./benchmarks/) folder.
@@ -210,4 +220,5 @@ Contributions are welcome! Please refer to our [CONTRIBUTING.md](CONTRIBUTING.md
0 commit comments