@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.
Files changed (2) hide show
  1. package/README.md +30 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,30 +1,46 @@
1
1
  # @quatrain/log
2
2
 
3
- A structured logging package for Quatrain applications. It uses an adapter pattern to allow for different logging backends, such as the console, file, or a cloud logging service.
3
+ A centralized logging system for Quatrain applications, providing flexible log levels, adapter-based outputs, and structured logging capabilities.
4
4
 
5
- ## Features
5
+ ## Introduction
6
6
 
7
- - **Multiple Log Levels**: Supports `DEBUG`, `INFO`, `WARN`, `ERROR`, and `CRITICAL`.
8
- - **Adapter Pattern**: Pluggable adapters for various logging outputs.
9
- - **Domain-specific Loggers**: Create separate logger instances for different parts of your application.
10
- - **Structured JSON Output**: Logs can be formatted as JSON for easy parsing by log management systems.
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
- ## Usage
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
- // Instantiating a sub-logger using clone()
28
- const subLogger = logger.clone('db') // Inherits configuration, suffixing prefix with ][db
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/log",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Logger for business apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",