pretty-logx 0.0.0-stage → 0.1.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/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/README.md +119 -2
- package/dist/index.d.mts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +453 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +440 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +72 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `pretty-logx` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2024-01-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of `pretty-logx`
|
|
13
|
+
- Six log levels: `trace`, `debug`, `info`, `warn`, `error`, `fatal`
|
|
14
|
+
- Beautiful colored terminal output with ANSI colors
|
|
15
|
+
- Short (`HH:MM:SS.mmm`) and ISO 8601 timestamp formats
|
|
16
|
+
- JSON mode for structured production logging
|
|
17
|
+
- Namespace support for tagging log sources
|
|
18
|
+
- Child loggers with inherited bindings
|
|
19
|
+
- Pretty error stack trace formatting
|
|
20
|
+
- Structured logging with object bindings (bindings-first calling convention)
|
|
21
|
+
- Level predicates (`isDebugEnabled`, `isInfoEnabled`, etc.)
|
|
22
|
+
- Runtime configuration via `configure()` and `level` setter
|
|
23
|
+
- Safe circular reference detection and serialization
|
|
24
|
+
- BigInt serialization support
|
|
25
|
+
- `NO_COLOR` environment variable support (https://no-color.org/)
|
|
26
|
+
- `FORCE_COLOR` environment variable support
|
|
27
|
+
- Automatic TTY color detection
|
|
28
|
+
- Custom write function support
|
|
29
|
+
- Error routing: `error`/`fatal` → `stderr`, rest → `stdout`
|
|
30
|
+
- ESM and CommonJS dual package
|
|
31
|
+
- Full TypeScript types and autocomplete
|
|
32
|
+
- Zero runtime dependencies
|
|
33
|
+
- Node.js 18+ compatibility
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 pretty-logx contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,120 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pretty-logx
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A clean, lightweight logger for Node.js with colored dev output, structured JSON for production, and zero dependencies.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install pretty-logx
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Why
|
|
10
|
+
|
|
11
|
+
Most loggers are either too heavy (Pino, Winston) or too barebones (Console). `pretty-logx` gives you formatted terminal output in development, fast structured JSON in production, child loggers with context, and safe circular JSON handling — all in under 5KB with zero runtime dependencies.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createLogger } from 'pretty-logx';
|
|
19
|
+
|
|
20
|
+
const log = createLogger();
|
|
21
|
+
|
|
22
|
+
log.info('Server started on port 3000');
|
|
23
|
+
log.warn('Disk space low', { remaining: '1.2GB' });
|
|
24
|
+
log.error('Database connection failed', new Error('ECONNREFUSED'));
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Context & Child Loggers
|
|
28
|
+
|
|
29
|
+
Pass request metadata or create scoped child loggers:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// Bindings first (structured)
|
|
33
|
+
log.info({ userId: 'u_123', action: 'checkout' }, 'Order placed');
|
|
34
|
+
|
|
35
|
+
// Scoped child logger
|
|
36
|
+
const authLog = log.child({ scope: 'auth' });
|
|
37
|
+
authLog.debug('Verifying JWT');
|
|
38
|
+
authLog.info({ userId: 'u_123' }, 'Session created');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Production JSON Mode
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const log = createLogger({
|
|
45
|
+
level: 'info',
|
|
46
|
+
json: process.env.NODE_ENV === 'production',
|
|
47
|
+
namespace: 'api',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
log.info({ path: '/api/v1/users', status: 200 }, 'Request completed');
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Output:
|
|
54
|
+
```json
|
|
55
|
+
{"level":"info","levelValue":30,"time":"2026-11-23T17:15:00.000Z","msg":"Request completed","namespace":"api","path":"/api/v1/users","status":200}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Error Handling
|
|
59
|
+
|
|
60
|
+
Pass standard errors and get formatted stack traces in dev, or serialized error objects in JSON mode:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
try {
|
|
64
|
+
throw new Error('Something broke');
|
|
65
|
+
} catch (err) {
|
|
66
|
+
log.error('Operation failed', err);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Circular Objects
|
|
71
|
+
|
|
72
|
+
Circular references are caught and serialized as `[Circular]` instead of crashing your app:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const obj: any = { name: 'app' };
|
|
76
|
+
obj.self = obj;
|
|
77
|
+
|
|
78
|
+
log.info({ config: obj }, 'Loaded configuration');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Options
|
|
82
|
+
|
|
83
|
+
`createLogger(options)` accepts:
|
|
84
|
+
|
|
85
|
+
| Option | Type | Default | Description |
|
|
86
|
+
| --- | --- | --- | --- |
|
|
87
|
+
| `level` | `string` | `'info'` | `'trace'`, `'debug'`, `'info'`, `'warn'`, `'error'`, `'fatal'`, `'silent'` |
|
|
88
|
+
| `json` | `boolean` | `false` | Enable structured JSON output |
|
|
89
|
+
| `namespace` | `string` | `undefined` | Optional prefix tag (e.g. `api`, `worker`) |
|
|
90
|
+
| `timestamp` | `boolean` | `true` | Show timestamp in dev logs |
|
|
91
|
+
| `timestampFormat` | `string` | `'short'` | `'short'` (`HH:MM:SS.mmm`), `'iso'`, or `'none'` |
|
|
92
|
+
| `colors` | `boolean` | `auto` | Auto-detected. Supports `NO_COLOR` and `FORCE_COLOR` |
|
|
93
|
+
| `write` | `function` | `stdout/stderr` | Custom write handler `(output, level) => void` |
|
|
94
|
+
|
|
95
|
+
## Log Levels
|
|
96
|
+
|
|
97
|
+
- `trace` (10)
|
|
98
|
+
- `debug` (20)
|
|
99
|
+
- `info` (30)
|
|
100
|
+
- `warn` (40)
|
|
101
|
+
- `error` (50) — writes to `stderr`
|
|
102
|
+
- `fatal` (60) — writes to `stderr`
|
|
103
|
+
- `silent` (Infinity)
|
|
104
|
+
|
|
105
|
+
Check active levels before running expensive operations:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
if (log.isDebugEnabled) {
|
|
109
|
+
log.debug('Debug payload', getExpensiveMetrics());
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Environment Flags
|
|
114
|
+
|
|
115
|
+
- `NO_COLOR=1` — disables ANSI colors ([no-color.org](https://no-color.org))
|
|
116
|
+
- `FORCE_COLOR=1` — forces ANSI colors even in non-TTY environments
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT © [Rudransh](https://github.com/rayrudr1817)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log levels for pretty-logx.
|
|
3
|
+
* Lower numbers = more verbose.
|
|
4
|
+
*/
|
|
5
|
+
declare const LogLevel: {
|
|
6
|
+
readonly trace: 10;
|
|
7
|
+
readonly debug: 20;
|
|
8
|
+
readonly info: 30;
|
|
9
|
+
readonly warn: 40;
|
|
10
|
+
readonly error: 50;
|
|
11
|
+
readonly fatal: 60;
|
|
12
|
+
readonly silent: number;
|
|
13
|
+
};
|
|
14
|
+
type LogLevelName = keyof typeof LogLevel;
|
|
15
|
+
type LogLevelValue = (typeof LogLevel)[LogLevelName];
|
|
16
|
+
declare function isLogLevelName(value: unknown): value is LogLevelName;
|
|
17
|
+
declare function getLevelValue(level: LogLevelName): number;
|
|
18
|
+
declare function getLevelName(value: number): LogLevelName | undefined;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Detect whether colors should be enabled.
|
|
22
|
+
* Checks: NO_COLOR env var, FORCE_COLOR env var, TTY availability.
|
|
23
|
+
*/
|
|
24
|
+
declare function detectColorSupport(): boolean;
|
|
25
|
+
declare function isColorsEnabled(): boolean;
|
|
26
|
+
declare function setColorsEnabled(enabled: boolean): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Configuration for creating a logger.
|
|
30
|
+
*/
|
|
31
|
+
interface LoggerConfig {
|
|
32
|
+
/** Minimum level to log. Defaults to 'info'. */
|
|
33
|
+
level?: LogLevelName;
|
|
34
|
+
/** Enable JSON mode (structured logging for production). */
|
|
35
|
+
json?: boolean;
|
|
36
|
+
/** Namespace/name prefix for this logger. */
|
|
37
|
+
namespace?: string | undefined;
|
|
38
|
+
/** Whether to include timestamps. Defaults to true. */
|
|
39
|
+
timestamp?: boolean;
|
|
40
|
+
/** Timestamp format. Defaults to 'short'. */
|
|
41
|
+
timestampFormat?: 'iso' | 'short' | 'none';
|
|
42
|
+
/** Enable/disable colors. Auto-detected by default. */
|
|
43
|
+
colors?: boolean;
|
|
44
|
+
/** Custom write function. Defaults to process.stdout/stderr. */
|
|
45
|
+
write?: (output: string, level: LogLevelName) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Structured log record for JSON mode.
|
|
49
|
+
*/
|
|
50
|
+
interface LogRecord {
|
|
51
|
+
level: LogLevelName;
|
|
52
|
+
levelValue: LogLevelValue;
|
|
53
|
+
time: string;
|
|
54
|
+
msg: string;
|
|
55
|
+
namespace?: string;
|
|
56
|
+
err?: unknown;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Arguments to a log method: message + optional bindings.
|
|
61
|
+
*/
|
|
62
|
+
type LogArgs = [message: string] | [message: string, ...meta: unknown[]] | [bindings: object, message: string];
|
|
63
|
+
/**
|
|
64
|
+
* Core Logger class.
|
|
65
|
+
*/
|
|
66
|
+
declare class Logger {
|
|
67
|
+
private _level;
|
|
68
|
+
private _levelValue;
|
|
69
|
+
private _json;
|
|
70
|
+
private _namespace;
|
|
71
|
+
private _timestamp;
|
|
72
|
+
private _timestampFormat;
|
|
73
|
+
private _write;
|
|
74
|
+
private _bindings;
|
|
75
|
+
constructor(config?: LoggerConfig, parentBindings?: Record<string, unknown>);
|
|
76
|
+
get level(): LogLevelName;
|
|
77
|
+
set level(level: LogLevelName);
|
|
78
|
+
get levelValue(): number;
|
|
79
|
+
get namespace(): string | undefined;
|
|
80
|
+
get isJsonMode(): boolean;
|
|
81
|
+
get isTraceEnabled(): boolean;
|
|
82
|
+
get isDebugEnabled(): boolean;
|
|
83
|
+
get isInfoEnabled(): boolean;
|
|
84
|
+
get isWarnEnabled(): boolean;
|
|
85
|
+
get isErrorEnabled(): boolean;
|
|
86
|
+
get isFatalEnabled(): boolean;
|
|
87
|
+
private _log;
|
|
88
|
+
private _writeJson;
|
|
89
|
+
private _writePretty;
|
|
90
|
+
trace(...args: unknown[]): void;
|
|
91
|
+
debug(...args: unknown[]): void;
|
|
92
|
+
info(...args: unknown[]): void;
|
|
93
|
+
warn(...args: unknown[]): void;
|
|
94
|
+
error(...args: unknown[]): void;
|
|
95
|
+
fatal(...args: unknown[]): void;
|
|
96
|
+
/**
|
|
97
|
+
* Create a child logger with additional bindings and optional config overrides.
|
|
98
|
+
*/
|
|
99
|
+
child(bindingsOrConfig: Record<string, unknown>, config?: Omit<LoggerConfig, 'namespace'>): Logger;
|
|
100
|
+
/**
|
|
101
|
+
* Create a namespaced child logger.
|
|
102
|
+
*/
|
|
103
|
+
ns(namespace: string): Logger;
|
|
104
|
+
/**
|
|
105
|
+
* Configure this logger instance.
|
|
106
|
+
*/
|
|
107
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create a new logger instance.
|
|
111
|
+
*/
|
|
112
|
+
declare function createLogger(config?: LoggerConfig): Logger;
|
|
113
|
+
/**
|
|
114
|
+
* Default logger instance.
|
|
115
|
+
*/
|
|
116
|
+
declare const logger: Logger;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Safe JSON serialization with circular reference handling.
|
|
120
|
+
*/
|
|
121
|
+
declare function safeStringify(value: unknown, indent?: number): string;
|
|
122
|
+
/**
|
|
123
|
+
* Format an Error object for structured logging.
|
|
124
|
+
*/
|
|
125
|
+
interface SerializedError {
|
|
126
|
+
name: string;
|
|
127
|
+
message: string;
|
|
128
|
+
stack?: string;
|
|
129
|
+
cause?: SerializedError | unknown;
|
|
130
|
+
[key: string]: unknown;
|
|
131
|
+
}
|
|
132
|
+
declare function serializeError(err: unknown): SerializedError;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Color configuration per log level.
|
|
136
|
+
*/
|
|
137
|
+
interface LevelStyle {
|
|
138
|
+
label: string;
|
|
139
|
+
color: string;
|
|
140
|
+
badge: string;
|
|
141
|
+
}
|
|
142
|
+
interface FormatOptions {
|
|
143
|
+
timestamp: boolean;
|
|
144
|
+
timestampFormat: 'iso' | 'short' | 'none';
|
|
145
|
+
namespace?: string | undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { type FormatOptions, type LevelStyle, type LogArgs, LogLevel, type LogLevelName, type LogLevelValue, type LogRecord, Logger, type LoggerConfig, type SerializedError, createLogger, detectColorSupport, getLevelName, getLevelValue, isColorsEnabled, isLogLevelName, logger, safeStringify, serializeError, setColorsEnabled };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log levels for pretty-logx.
|
|
3
|
+
* Lower numbers = more verbose.
|
|
4
|
+
*/
|
|
5
|
+
declare const LogLevel: {
|
|
6
|
+
readonly trace: 10;
|
|
7
|
+
readonly debug: 20;
|
|
8
|
+
readonly info: 30;
|
|
9
|
+
readonly warn: 40;
|
|
10
|
+
readonly error: 50;
|
|
11
|
+
readonly fatal: 60;
|
|
12
|
+
readonly silent: number;
|
|
13
|
+
};
|
|
14
|
+
type LogLevelName = keyof typeof LogLevel;
|
|
15
|
+
type LogLevelValue = (typeof LogLevel)[LogLevelName];
|
|
16
|
+
declare function isLogLevelName(value: unknown): value is LogLevelName;
|
|
17
|
+
declare function getLevelValue(level: LogLevelName): number;
|
|
18
|
+
declare function getLevelName(value: number): LogLevelName | undefined;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Detect whether colors should be enabled.
|
|
22
|
+
* Checks: NO_COLOR env var, FORCE_COLOR env var, TTY availability.
|
|
23
|
+
*/
|
|
24
|
+
declare function detectColorSupport(): boolean;
|
|
25
|
+
declare function isColorsEnabled(): boolean;
|
|
26
|
+
declare function setColorsEnabled(enabled: boolean): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Configuration for creating a logger.
|
|
30
|
+
*/
|
|
31
|
+
interface LoggerConfig {
|
|
32
|
+
/** Minimum level to log. Defaults to 'info'. */
|
|
33
|
+
level?: LogLevelName;
|
|
34
|
+
/** Enable JSON mode (structured logging for production). */
|
|
35
|
+
json?: boolean;
|
|
36
|
+
/** Namespace/name prefix for this logger. */
|
|
37
|
+
namespace?: string | undefined;
|
|
38
|
+
/** Whether to include timestamps. Defaults to true. */
|
|
39
|
+
timestamp?: boolean;
|
|
40
|
+
/** Timestamp format. Defaults to 'short'. */
|
|
41
|
+
timestampFormat?: 'iso' | 'short' | 'none';
|
|
42
|
+
/** Enable/disable colors. Auto-detected by default. */
|
|
43
|
+
colors?: boolean;
|
|
44
|
+
/** Custom write function. Defaults to process.stdout/stderr. */
|
|
45
|
+
write?: (output: string, level: LogLevelName) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Structured log record for JSON mode.
|
|
49
|
+
*/
|
|
50
|
+
interface LogRecord {
|
|
51
|
+
level: LogLevelName;
|
|
52
|
+
levelValue: LogLevelValue;
|
|
53
|
+
time: string;
|
|
54
|
+
msg: string;
|
|
55
|
+
namespace?: string;
|
|
56
|
+
err?: unknown;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Arguments to a log method: message + optional bindings.
|
|
61
|
+
*/
|
|
62
|
+
type LogArgs = [message: string] | [message: string, ...meta: unknown[]] | [bindings: object, message: string];
|
|
63
|
+
/**
|
|
64
|
+
* Core Logger class.
|
|
65
|
+
*/
|
|
66
|
+
declare class Logger {
|
|
67
|
+
private _level;
|
|
68
|
+
private _levelValue;
|
|
69
|
+
private _json;
|
|
70
|
+
private _namespace;
|
|
71
|
+
private _timestamp;
|
|
72
|
+
private _timestampFormat;
|
|
73
|
+
private _write;
|
|
74
|
+
private _bindings;
|
|
75
|
+
constructor(config?: LoggerConfig, parentBindings?: Record<string, unknown>);
|
|
76
|
+
get level(): LogLevelName;
|
|
77
|
+
set level(level: LogLevelName);
|
|
78
|
+
get levelValue(): number;
|
|
79
|
+
get namespace(): string | undefined;
|
|
80
|
+
get isJsonMode(): boolean;
|
|
81
|
+
get isTraceEnabled(): boolean;
|
|
82
|
+
get isDebugEnabled(): boolean;
|
|
83
|
+
get isInfoEnabled(): boolean;
|
|
84
|
+
get isWarnEnabled(): boolean;
|
|
85
|
+
get isErrorEnabled(): boolean;
|
|
86
|
+
get isFatalEnabled(): boolean;
|
|
87
|
+
private _log;
|
|
88
|
+
private _writeJson;
|
|
89
|
+
private _writePretty;
|
|
90
|
+
trace(...args: unknown[]): void;
|
|
91
|
+
debug(...args: unknown[]): void;
|
|
92
|
+
info(...args: unknown[]): void;
|
|
93
|
+
warn(...args: unknown[]): void;
|
|
94
|
+
error(...args: unknown[]): void;
|
|
95
|
+
fatal(...args: unknown[]): void;
|
|
96
|
+
/**
|
|
97
|
+
* Create a child logger with additional bindings and optional config overrides.
|
|
98
|
+
*/
|
|
99
|
+
child(bindingsOrConfig: Record<string, unknown>, config?: Omit<LoggerConfig, 'namespace'>): Logger;
|
|
100
|
+
/**
|
|
101
|
+
* Create a namespaced child logger.
|
|
102
|
+
*/
|
|
103
|
+
ns(namespace: string): Logger;
|
|
104
|
+
/**
|
|
105
|
+
* Configure this logger instance.
|
|
106
|
+
*/
|
|
107
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create a new logger instance.
|
|
111
|
+
*/
|
|
112
|
+
declare function createLogger(config?: LoggerConfig): Logger;
|
|
113
|
+
/**
|
|
114
|
+
* Default logger instance.
|
|
115
|
+
*/
|
|
116
|
+
declare const logger: Logger;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Safe JSON serialization with circular reference handling.
|
|
120
|
+
*/
|
|
121
|
+
declare function safeStringify(value: unknown, indent?: number): string;
|
|
122
|
+
/**
|
|
123
|
+
* Format an Error object for structured logging.
|
|
124
|
+
*/
|
|
125
|
+
interface SerializedError {
|
|
126
|
+
name: string;
|
|
127
|
+
message: string;
|
|
128
|
+
stack?: string;
|
|
129
|
+
cause?: SerializedError | unknown;
|
|
130
|
+
[key: string]: unknown;
|
|
131
|
+
}
|
|
132
|
+
declare function serializeError(err: unknown): SerializedError;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Color configuration per log level.
|
|
136
|
+
*/
|
|
137
|
+
interface LevelStyle {
|
|
138
|
+
label: string;
|
|
139
|
+
color: string;
|
|
140
|
+
badge: string;
|
|
141
|
+
}
|
|
142
|
+
interface FormatOptions {
|
|
143
|
+
timestamp: boolean;
|
|
144
|
+
timestampFormat: 'iso' | 'short' | 'none';
|
|
145
|
+
namespace?: string | undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { type FormatOptions, type LevelStyle, type LogArgs, LogLevel, type LogLevelName, type LogLevelValue, type LogRecord, Logger, type LoggerConfig, type SerializedError, createLogger, detectColorSupport, getLevelName, getLevelValue, isColorsEnabled, isLogLevelName, logger, safeStringify, serializeError, setColorsEnabled };
|