@quatrain/log 1.1.7 → 1.1.9
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/README.md +30 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
# @quatrain/log
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A centralized logging system for Quatrain applications, providing flexible log levels, adapter-based outputs, and structured logging capabilities.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Introduction
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
The `@quatrain/log` package acts as the unified logging interface for all components within the Quatrain ecosystem. Rather than scattering `console.log` statements throughout your code, this package offers a structured approach to debugging, warning, and tracing errors, with the ability to route logs to different destinations via custom adapters.
|
|
8
|
+
|
|
9
|
+
## Key Concepts
|
|
10
|
+
|
|
11
|
+
- **`Log`**: The static registry and main interface for logging messages.
|
|
12
|
+
- **`LogLevel`**: Enum defining severity (`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `SILENT`).
|
|
13
|
+
- **`AbstractLoggerAdapter`**: The base class for creating custom log outputs.
|
|
14
|
+
- **`DefaultLoggerAdapter`**: The built-in adapter that outputs colorized logs to the console using `chalk`.
|
|
11
15
|
|
|
12
16
|
## Installation
|
|
13
17
|
|
|
14
18
|
```bash
|
|
15
19
|
npm install @quatrain/log
|
|
20
|
+
# or
|
|
21
|
+
yarn add @quatrain/log
|
|
22
|
+
# or
|
|
23
|
+
bun add @quatrain/log
|
|
16
24
|
```
|
|
17
25
|
|
|
18
|
-
##
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
By default, `@quatrain/log` initializes a `DefaultLoggerAdapter` with the `INFO` level.
|
|
29
|
+
No configuration is required for basic usage.
|
|
30
|
+
|
|
31
|
+
If you need to change the log level globally or register custom loggers, you can do so early in your application lifecycle:
|
|
19
32
|
|
|
20
33
|
```typescript
|
|
21
34
|
import { Log, LogLevel } from '@quatrain/log'
|
|
22
|
-
import { ConsoleLoggerAdapter } from '@quatrain/log' // Example adapter
|
|
23
|
-
|
|
24
|
-
const logger = Log.addLogger('api', new ConsoleLoggerAdapter(), true)
|
|
25
|
-
logger.info('Server has started.', { port: 3000 })
|
|
26
35
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
subLogger.debug('Connection pool initialized.') // Output prefix: [api][db]
|
|
36
|
+
// Set the default logger level to DEBUG
|
|
37
|
+
Log.getLogger().setLevel(LogLevel.DEBUG)
|
|
30
38
|
```
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
For concrete examples and usage guides, please refer to the [How-To Guide](HOWTO.md).
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
AGPL-3.0-only
|