nlogs 2.4.4 → 2.5.0
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 +152 -0
- package/dist/abstract.base.logger.d.ts +1 -0
- package/dist/abstract.base.logger.js +37 -50
- package/dist/abstract.base.logger.js.map +1 -1
- package/dist/base.logger.js +35 -39
- package/dist/base.logger.js.map +1 -1
- package/dist/errors/cat.nlogs.error.js +1 -4
- package/dist/errors/cat.nlogs.error.js.map +1 -1
- package/dist/errors/fs.nlogs.error.js +1 -4
- package/dist/errors/fs.nlogs.error.js.map +1 -1
- package/dist/errors/item.nlogs.error.d.ts +1 -1
- package/dist/errors/item.nlogs.error.js +1 -0
- package/dist/errors/item.nlogs.error.js.map +1 -1
- package/dist/errors/msg.nlogs.error.js +1 -4
- package/dist/errors/msg.nlogs.error.js.map +1 -1
- package/dist/errors/param.error.js +2 -1
- package/dist/errors/param.error.js.map +1 -1
- package/dist/helpers/fs.js.map +1 -1
- package/dist/helpers/stack.js +12 -8
- package/dist/helpers/stack.js.map +1 -1
- package/dist/helpers/symbols.d.ts +0 -1
- package/dist/helpers/symbols.js +2 -3
- package/dist/helpers/symbols.js.map +1 -1
- package/dist/helpers/template.d.ts +1 -1
- package/dist/helpers/template.js.map +1 -1
- package/dist/helpers/testHelpers.d.ts +7 -8
- package/dist/helpers/testHelpers.js +17 -7
- package/dist/helpers/testHelpers.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -3
- package/dist/logger.d.ts +8 -8
- package/dist/logger.js +4 -4
- package/dist/logger.js.map +1 -1
- package/dist/logging.rules.js +2 -2
- package/dist/logging.rules.js.map +1 -1
- package/dist/message/details.js +14 -10
- package/dist/message/details.js.map +1 -1
- package/dist/message/error.details.js +3 -0
- package/dist/message/error.details.js.map +1 -1
- package/dist/message/log.info.js +10 -9
- package/dist/message/log.info.js.map +1 -1
- package/dist/message/meta.js +7 -0
- package/dist/message/meta.js.map +1 -1
- package/dist/message/mod.details.js +2 -0
- package/dist/message/mod.details.js.map +1 -1
- package/dist/message/time.details.js +3 -0
- package/dist/message/time.details.js.map +1 -1
- package/dist/message/time.range.js +3 -0
- package/dist/message/time.range.js.map +1 -1
- package/dist/nestjs.logger.js +1 -3
- package/dist/nestjs.logger.js.map +1 -1
- package/dist/options.js.map +1 -1
- package/dist/template.logger.js +1 -0
- package/dist/template.logger.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils/allowed.list.js +4 -5
- package/dist/utils/allowed.list.js.map +1 -1
- package/dist/utils/category.js +2 -1
- package/dist/utils/category.js.map +1 -1
- package/dist/utils/console.out.d.ts +0 -1
- package/dist/utils/console.out.js +2 -0
- package/dist/utils/console.out.js.map +1 -1
- package/dist/utils/dark.string.formatter.js +12 -15
- package/dist/utils/dark.string.formatter.js.map +1 -1
- package/dist/utils/items.counter.d.ts +1 -1
- package/dist/utils/items.counter.js +2 -5
- package/dist/utils/items.counter.js.map +1 -1
- package/dist/utils/items.manager.d.ts +1 -0
- package/dist/utils/items.manager.js +29 -11
- package/dist/utils/items.manager.js.map +1 -1
- package/dist/utils/items.timer.js +2 -5
- package/dist/utils/items.timer.js.map +1 -1
- package/dist/utils/log.reader.d.ts +1 -0
- package/dist/utils/log.reader.js +15 -1
- package/dist/utils/log.reader.js.map +1 -1
- package/dist/utils/mod.js +2 -0
- package/dist/utils/mod.js.map +1 -1
- package/dist/utils/mod.resolver.js +21 -31
- package/dist/utils/mod.resolver.js.map +1 -1
- package/dist/utils/string.formatter.js +6 -8
- package/dist/utils/string.formatter.js.map +1 -1
- package/dist/utils/trace.store.d.ts +0 -1
- package/dist/utils/trace.store.js +2 -4
- package/dist/utils/trace.store.js.map +1 -1
- package/package.json +20 -17
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# nlogs
|
|
2
|
+
|
|
3
|
+
Structured logger for Node.js with category-based filtering, AsyncLocalStorage trace IDs, and built-in timers and counters. Configurable through environment variables - no setup code in most cases.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Requires Node.js 20 or newer.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install nlogs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import Logger from 'nlogs'
|
|
17
|
+
|
|
18
|
+
const logger = new Logger()
|
|
19
|
+
|
|
20
|
+
logger.info('server started', { port: 3000 })
|
|
21
|
+
logger.error(new Error('boom'))
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The `dark` ANSI formatter is used in development and switches to `json` when `NODE_ENV=production`.
|
|
25
|
+
|
|
26
|
+
## Log levels
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
trace -> debug -> log -> info -> warn -> error -> fatal
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`warn`, `error`, and `fatal` are written to stderr; the rest go to stdout. `fatal` is always emitted regardless of filtering.
|
|
33
|
+
|
|
34
|
+
Filter at runtime:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
NLOGS_LEVEL=warn node app.js # warn, error, fatal
|
|
38
|
+
NLOGS_LEVELS=info,error node app.js # exact set
|
|
39
|
+
NLOGS_LEVEL=off node app.js # silence everything except fatal
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Categories
|
|
43
|
+
|
|
44
|
+
Each logger instance has a category. By default it is derived from the source file path. Pass a class, an explicit string, or `module`/`import.meta` to override:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
class UserService {}
|
|
48
|
+
const log = new Logger(UserService)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Filter categories with `NLOGS_CATEGORY` (syntax mirrors `debug`: comma-separated entries, leading `-` for negation, `module:category` for module-scoped rules, `*` for everything):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
NLOGS_CATEGORY="auth, payments, -auth:internal" node app.js
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Trace context
|
|
58
|
+
|
|
59
|
+
`Logger.run` opens an AsyncLocalStorage context. Every log inside the callback - and any async work it spawns - carries the same `traceId` and shared `details`.
|
|
60
|
+
|
|
61
|
+
A string argument sets the `traceId` directly:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
Logger.run(req.headers['x-trace-id'], () => handler(req))
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
An object argument generates a fresh `traceId` and attaches arbitrary fields to `details`:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
Logger.run({ userId: '42' }, async () => {
|
|
71
|
+
logger.info('handling request')
|
|
72
|
+
await processOrder()
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Pass `traceId` explicitly to combine both:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
Logger.run({ traceId: 'abc-123', userId: '42' }, () => handler())
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Nested calls chain: the outer traceId is preserved in `_traceIds`.
|
|
83
|
+
|
|
84
|
+
## Timers and counters
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
logger.time('db')
|
|
88
|
+
await query()
|
|
89
|
+
logger.timeEnd('db')
|
|
90
|
+
|
|
91
|
+
const counter = logger.count('events')
|
|
92
|
+
counter.log() // increments and logs
|
|
93
|
+
counter.log()
|
|
94
|
+
counter.end() // closes the counter
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`logger.time(label)` and `logger.count(label)` return a handle with `.log()` and `.end()` methods. Calling the handle itself (`counter()`) is equivalent to `.end()`. Without a label each call returns a fresh handle. Repeated `logger.count(label)` with the same label keeps incrementing the same counter until `.end()`.
|
|
98
|
+
|
|
99
|
+
## Formatters
|
|
100
|
+
|
|
101
|
+
| Value | When to use |
|
|
102
|
+
|----------|-----------------------------------------|
|
|
103
|
+
| `dark` | Terminal with dark background (default) |
|
|
104
|
+
| `light` | Terminal with light background |
|
|
105
|
+
| `string` | Plain text, no ANSI |
|
|
106
|
+
| `json` | One JSON object per line (prod default) |
|
|
107
|
+
|
|
108
|
+
Override with `NLOGS_FORMATTER`.
|
|
109
|
+
|
|
110
|
+
## Environment variables
|
|
111
|
+
|
|
112
|
+
Naming convention: `NLOGS_*` (preferred), `LOGGER_*` (fallback), unprefixed (compatibility with `DEBUG`, `LEVEL`, `CATEGORY`, ...).
|
|
113
|
+
|
|
114
|
+
| Variable | Purpose |
|
|
115
|
+
|----------------------------|----------------------------------------|
|
|
116
|
+
| `NLOGS_PROJECT` | Project name in meta |
|
|
117
|
+
| `NLOGS_SERVICE` | Service name in meta |
|
|
118
|
+
| `NLOGS_CATEGORY` | Category allow/deny list |
|
|
119
|
+
| `NLOGS_DEBUG` | Same syntax for `debug`/`trace` levels |
|
|
120
|
+
| `NLOGS_LEVEL` | Minimum level (or exact level) |
|
|
121
|
+
| `NLOGS_LEVELS` | Exact set of allowed levels |
|
|
122
|
+
| `NLOGS_FORMATTER` | `json`/`string`/`light`/`dark` |
|
|
123
|
+
| `NLOGS_STRICT_LEVEL_RULES` | Pre-filter by level (bool) |
|
|
124
|
+
|
|
125
|
+
`DEBUG=*` and `NODE_DEBUG=*` are honoured as aliases for `NLOGS_DEBUG`.
|
|
126
|
+
|
|
127
|
+
## NestJS adapter
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { NestjsLogger } from 'nlogs'
|
|
131
|
+
|
|
132
|
+
const app = await NestFactory.create(AppModule, {
|
|
133
|
+
logger: new NestjsLogger(),
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Template logger
|
|
138
|
+
|
|
139
|
+
`TemplateLogger` injects a fixed template applied to every message. Use it as a tagged template literal where each `${...}` can be a plain value or a function that receives the current `LogInfo` and returns the substituted value:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { TemplateLogger } from 'nlogs'
|
|
143
|
+
|
|
144
|
+
const logger = new TemplateLogger('http')
|
|
145
|
+
logger.template`[${info => info.meta.level}] ${info => info.message}`
|
|
146
|
+
|
|
147
|
+
logger.info('request received')
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT - see [LICENSE](./LICENSE).
|
|
@@ -39,6 +39,7 @@ export declare abstract class AbstractBaseLogger<O extends IAbstractBaseLoggerOp
|
|
|
39
39
|
private get loggingShowCategory();
|
|
40
40
|
private get loggingShowDebug();
|
|
41
41
|
private get loggingMainRules();
|
|
42
|
+
protected invalidateRulesCache(): void;
|
|
42
43
|
protected preCheckLoggingRules(level: string): boolean;
|
|
43
44
|
protected postCheckLoggingRules(info: LogInfo): boolean;
|
|
44
45
|
protected logTo(level: string, std: 'out' | 'error', msgs: any[]): void;
|
|
@@ -1,49 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _AbstractBaseLogger_loggingShowCategory, _AbstractBaseLogger_loggingShowDebug, _AbstractBaseLogger_loggingMainRules;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.AbstractBaseLogger = void 0;
|
|
16
4
|
const static_logger_1 = require("./utils/static.logger");
|
|
17
5
|
const logging_rules_1 = require("./logging.rules");
|
|
18
6
|
const constants_1 = require("./constants");
|
|
19
7
|
class AbstractBaseLogger extends static_logger_1.StaticLogger {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.logTo('fatal', 'error', msgs);
|
|
42
|
-
};
|
|
43
|
-
_AbstractBaseLogger_loggingShowCategory.set(this, void 0);
|
|
44
|
-
_AbstractBaseLogger_loggingShowDebug.set(this, void 0);
|
|
45
|
-
_AbstractBaseLogger_loggingMainRules.set(this, void 0);
|
|
46
|
-
}
|
|
8
|
+
log = (...msgs) => {
|
|
9
|
+
this.logTo('log', 'out', msgs);
|
|
10
|
+
};
|
|
11
|
+
debug = (...msgs) => {
|
|
12
|
+
this.logTo('debug', 'out', msgs);
|
|
13
|
+
};
|
|
14
|
+
trace = (...msgs) => {
|
|
15
|
+
this.logTo('trace', 'out', msgs);
|
|
16
|
+
};
|
|
17
|
+
info = (...msgs) => {
|
|
18
|
+
this.logTo('info', 'out', msgs);
|
|
19
|
+
};
|
|
20
|
+
warn = (...msgs) => {
|
|
21
|
+
this.logTo('warn', 'error', msgs);
|
|
22
|
+
};
|
|
23
|
+
error = (...msgs) => {
|
|
24
|
+
this.logTo('error', 'error', msgs);
|
|
25
|
+
};
|
|
26
|
+
fatal = (...msgs) => {
|
|
27
|
+
this.logTo('fatal', 'error', msgs);
|
|
28
|
+
};
|
|
47
29
|
readMessages(level, std, msgs) {
|
|
48
30
|
return this.reader.read(this.meta, [
|
|
49
31
|
static_logger_1.StaticLogger.level(level),
|
|
@@ -63,28 +45,34 @@ class AbstractBaseLogger extends static_logger_1.StaticLogger {
|
|
|
63
45
|
get loggingRulesModule() {
|
|
64
46
|
return this.module.type === 'module' ? this.module.name : false;
|
|
65
47
|
}
|
|
48
|
+
#loggingShowCategory;
|
|
66
49
|
get loggingShowCategory() {
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
return
|
|
50
|
+
if (this.#loggingShowCategory === undefined)
|
|
51
|
+
this.#loggingShowCategory = this.categoriesAllowedList.allow(this.meta.category, this.loggingRulesModule);
|
|
52
|
+
return this.#loggingShowCategory;
|
|
70
53
|
}
|
|
54
|
+
#loggingShowDebug;
|
|
71
55
|
get loggingShowDebug() {
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
return
|
|
56
|
+
if (this.#loggingShowDebug === undefined)
|
|
57
|
+
this.#loggingShowDebug = this.debugAllowedList.allow(this.meta.category, this.loggingRulesModule);
|
|
58
|
+
return this.#loggingShowDebug;
|
|
75
59
|
}
|
|
60
|
+
#loggingMainRules = null;
|
|
76
61
|
get loggingMainRules() {
|
|
77
|
-
if (!
|
|
78
|
-
|
|
62
|
+
if (!this.#loggingMainRules) {
|
|
63
|
+
this.#loggingMainRules = {
|
|
79
64
|
debugLevels: this.options.debugLevels,
|
|
80
65
|
moduleDebugLevels: this.options.moduleDebugLevels,
|
|
81
66
|
allowedLevels: this.options.allowedLevels,
|
|
82
67
|
isDev: this.options.isDev,
|
|
83
68
|
isModule: !!this.loggingRulesModule,
|
|
84
69
|
showLogger: this.options.show,
|
|
85
|
-
}
|
|
70
|
+
};
|
|
86
71
|
}
|
|
87
|
-
return
|
|
72
|
+
return this.#loggingMainRules;
|
|
73
|
+
}
|
|
74
|
+
invalidateRulesCache() {
|
|
75
|
+
this.#loggingMainRules = null;
|
|
88
76
|
}
|
|
89
77
|
preCheckLoggingRules(level) {
|
|
90
78
|
if (!this.options.strictLevelRules)
|
|
@@ -115,5 +103,4 @@ class AbstractBaseLogger extends static_logger_1.StaticLogger {
|
|
|
115
103
|
}
|
|
116
104
|
}
|
|
117
105
|
exports.AbstractBaseLogger = AbstractBaseLogger;
|
|
118
|
-
_AbstractBaseLogger_loggingShowCategory = new WeakMap(), _AbstractBaseLogger_loggingShowDebug = new WeakMap(), _AbstractBaseLogger_loggingMainRules = new WeakMap();
|
|
119
106
|
//# sourceMappingURL=abstract.base.logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.base.logger.js","sourceRoot":"","sources":["../src/abstract.base.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.base.logger.js","sourceRoot":"","sources":["../src/abstract.base.logger.ts"],"names":[],"mappings":";;;AACA,yDAAoD;AAKpD,mDAAgE;AAIhE,2CAA4C;AAY5C,MAAsB,kBAA4E,SAAQ,4BAAY;IAWpH,GAAG,GAAG,CAAC,GAAG,IAAW,EAAQ,EAAE;QAC7B,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAChC,CAAC,CAAA;IAED,KAAK,GAAG,CAAC,GAAG,IAAW,EAAQ,EAAE;QAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC,CAAA;IAED,KAAK,GAAG,CAAC,GAAG,IAAW,EAAQ,EAAE;QAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC,CAAA;IAED,IAAI,GAAG,CAAC,GAAG,IAAW,EAAQ,EAAE;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;IAED,IAAI,GAAG,CAAC,GAAG,IAAW,EAAQ,EAAE;QA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,CAAA;IAC5B,CAAC;CACF;AApID,gDAoIC"}
|
package/dist/base.logger.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.BaseLogger = void 0;
|
|
5
4
|
const abstract_base_logger_1 = require("./abstract.base.logger");
|
|
@@ -17,14 +16,17 @@ const light_string_formatter_1 = require("./utils/light.string.formatter");
|
|
|
17
16
|
const dark_string_formatter_1 = require("./utils/dark.string.formatter");
|
|
18
17
|
const options_1 = require("./options");
|
|
19
18
|
class BaseLogger extends abstract_base_logger_1.AbstractBaseLogger {
|
|
19
|
+
categoriesAllowedList = this.staticLogger.categoriesAllowedList;
|
|
20
|
+
debugAllowedList = this.staticLogger.debugAllowedList;
|
|
21
|
+
formatter = this.staticLogger.formatter;
|
|
22
|
+
reader = this.staticLogger.reader;
|
|
23
|
+
outLogs = this.staticLogger.outLogs;
|
|
24
|
+
traceStore = this.staticLogger.traceStore;
|
|
25
|
+
module;
|
|
26
|
+
meta;
|
|
27
|
+
options;
|
|
20
28
|
constructor(cat, options) {
|
|
21
29
|
super();
|
|
22
|
-
this.categoriesAllowedList = this.staticLogger.categoriesAllowedList;
|
|
23
|
-
this.debugAllowedList = this.staticLogger.debugAllowedList;
|
|
24
|
-
this.formatter = this.staticLogger.formatter;
|
|
25
|
-
this.reader = this.staticLogger.reader;
|
|
26
|
-
this.outLogs = this.staticLogger.outLogs;
|
|
27
|
-
this.traceStore = this.staticLogger.traceStore;
|
|
28
30
|
const pathname = (0, stack_1.getTopStackFile)(this.constructor);
|
|
29
31
|
this.module = this.staticLogger.moduleResolver.resolve(pathname);
|
|
30
32
|
const category = new category_1.Category(this.module, cat || category_1.Category.relativePath(pathname, this.module));
|
|
@@ -42,26 +44,45 @@ class BaseLogger extends abstract_base_logger_1.AbstractBaseLogger {
|
|
|
42
44
|
this.meta.set('index', options.index);
|
|
43
45
|
if (options?.show != null)
|
|
44
46
|
this.options.show = options.show;
|
|
45
|
-
['traceStore', 'categoriesAllowedList', 'debugAllowedList', 'formatter', 'reader', 'outLogs', '
|
|
47
|
+
['traceStore', 'categoriesAllowedList', 'debugAllowedList', 'formatter', 'reader', 'outLogs', 'options'].forEach(key => {
|
|
46
48
|
Object.defineProperty(this, key, {
|
|
47
49
|
value: this[key],
|
|
48
50
|
enumerable: false,
|
|
49
51
|
configurable: true,
|
|
50
52
|
});
|
|
51
53
|
});
|
|
52
|
-
const categoryName = this.meta.category.replace(/\s+/g, '_');
|
|
53
|
-
Object.keys(this)
|
|
54
|
-
.filter(key => typeof this[key] === 'function' && !this[key].name)
|
|
55
|
-
.forEach(key => Object.defineProperty(this[key], 'name', {
|
|
56
|
-
value: `${categoryName}~${key}`,
|
|
57
|
-
}));
|
|
58
54
|
}
|
|
59
55
|
get staticLogger() {
|
|
60
56
|
return this.constructor;
|
|
61
57
|
}
|
|
62
58
|
show(value) {
|
|
63
59
|
this.options.show = !!value;
|
|
60
|
+
this.invalidateRulesCache();
|
|
64
61
|
}
|
|
62
|
+
static moduleResolver = new mod_resolver_1.ModResolver();
|
|
63
|
+
static loggerOptions = (() => {
|
|
64
|
+
const opt = { ...options_1.loggerOptions };
|
|
65
|
+
opt.hiddenDetails._app = this.moduleResolver.app;
|
|
66
|
+
return opt;
|
|
67
|
+
})();
|
|
68
|
+
static categoriesAllowedList = new allowed_list_1.AllowedList(this.loggerOptions.categoriesAllowedList);
|
|
69
|
+
static debugAllowedList = new allowed_list_1.AllowedList(this.loggerOptions.debugAllowedList);
|
|
70
|
+
static formatter = (() => {
|
|
71
|
+
switch (this.loggerOptions.formatterType) {
|
|
72
|
+
case 'json':
|
|
73
|
+
return new json_formatter_1.JsonFormatter();
|
|
74
|
+
case 'string':
|
|
75
|
+
return new string_formatter_1.StringFormatter();
|
|
76
|
+
case 'light':
|
|
77
|
+
return new light_string_formatter_1.LightStringFormatter();
|
|
78
|
+
case 'dark':
|
|
79
|
+
return new dark_string_formatter_1.DarkStringFormatter();
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
static reader = new log_reader_1.LogReader(this.formatter);
|
|
83
|
+
static outLogs = new console_out_1.ConsoleOut(process.stdout, process.stderr);
|
|
84
|
+
static traceStore = new trace_store_1.TraceStore();
|
|
85
|
+
static defaultMeta = new meta_1.Meta(this.loggerOptions.defaultProject, this.loggerOptions.defaultService, this.loggerOptions.defaultCategory, 'log', '', new Date());
|
|
65
86
|
static setTraceDetails(traceDetails) {
|
|
66
87
|
this.traceStore.setDetails(traceDetails);
|
|
67
88
|
}
|
|
@@ -73,29 +94,4 @@ class BaseLogger extends abstract_base_logger_1.AbstractBaseLogger {
|
|
|
73
94
|
}
|
|
74
95
|
}
|
|
75
96
|
exports.BaseLogger = BaseLogger;
|
|
76
|
-
_a = BaseLogger;
|
|
77
|
-
BaseLogger.moduleResolver = new mod_resolver_1.ModResolver();
|
|
78
|
-
BaseLogger.loggerOptions = (() => {
|
|
79
|
-
const opt = { ...options_1.loggerOptions };
|
|
80
|
-
opt.hiddenDetails._app = _a.moduleResolver.app;
|
|
81
|
-
return opt;
|
|
82
|
-
})();
|
|
83
|
-
BaseLogger.categoriesAllowedList = new allowed_list_1.AllowedList(_a.loggerOptions.categoriesAllowedList);
|
|
84
|
-
BaseLogger.debugAllowedList = new allowed_list_1.AllowedList(_a.loggerOptions.debugAllowedList);
|
|
85
|
-
BaseLogger.formatter = (() => {
|
|
86
|
-
switch (_a.loggerOptions.formatterType) {
|
|
87
|
-
case 'json':
|
|
88
|
-
return new json_formatter_1.JsonFormatter();
|
|
89
|
-
case 'string':
|
|
90
|
-
return new string_formatter_1.StringFormatter();
|
|
91
|
-
case 'light':
|
|
92
|
-
return new light_string_formatter_1.LightStringFormatter();
|
|
93
|
-
case 'dark':
|
|
94
|
-
return new dark_string_formatter_1.DarkStringFormatter();
|
|
95
|
-
}
|
|
96
|
-
})();
|
|
97
|
-
BaseLogger.reader = new log_reader_1.LogReader(_a.formatter);
|
|
98
|
-
BaseLogger.outLogs = new console_out_1.ConsoleOut(process.stdout, process.stderr);
|
|
99
|
-
BaseLogger.traceStore = new trace_store_1.TraceStore();
|
|
100
|
-
BaseLogger.defaultMeta = new meta_1.Meta(_a.loggerOptions.defaultProject, _a.loggerOptions.defaultService, _a.loggerOptions.defaultCategory, 'log', '', new Date());
|
|
101
97
|
//# sourceMappingURL=base.logger.js.map
|
package/dist/base.logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../src/base.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../src/base.logger.ts"],"names":[],"mappings":";;;AAAA,iEAAuF;AACvF,yCAAqC;AACrC,uDAAkD;AAClD,+CAAgD;AAChD,mDAA8C;AAE9C,uDAAkD;AAClD,qDAA6D;AAC7D,2CAAiD;AAEjD,qDAAgD;AAChD,2DAAsD;AACtD,+DAA0D;AAC1D,2EAAqE;AACrE,yEAAmE;AACnE,uCAAyC;AAYzC,MAAa,UAAyC,SAAQ,yCAAoD;IACtG,qBAAqB,GAAgB,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAA;IAC5E,gBAAgB,GAAgB,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAA;IAClE,SAAS,GAAe,IAAI,CAAC,YAAY,CAAC,SAAS,CAAA;IACnD,MAAM,GAAc,IAAI,CAAC,YAAY,CAAC,MAAM,CAAA;IAC5C,OAAO,GAAe,IAAI,CAAC,YAAY,CAAC,OAAO,CAAA;IAC/C,UAAU,GAAiC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAA;IAExE,MAAM,CAAK;IACX,IAAI,CAAM;IACT,OAAO,CAAgB;IAIjC,YAAY,GAAgB,EAAE,OAAoB;QAChD,KAAK,EAAE,CAAA;QAEP,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,IAAI,CAAC,WAAW,CAAC,C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AAE,CAAA;QACpC,CAAC;IACH,CAAC,CAAC,EAAE,CAAA;IAEJ,MAAM,CAAC,MAAM,GAAc,IAAI,sBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAExD,MAAM,CAAC,OAAO,GAAe,IAAI,wBAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAE3E,MAAM,CAAC,UAAU,GAAG,IAAI,wBAAU,EAAoB,CAAA;IAEtD,MAAM,CAAC,WAAW,GAAS,IAAI,WAAI,CACjC,IAAI,CAAC,aAAa,CAAC,cAAc,EACjC,IAAI,CAAC,aAAa,CAAC,cAAc,EACjC,IAAI,CAAC,aAAa,CAAC,eAAe,EAClC,KAAK,EACL,EAAE,EACF,IAAI,IAAI,EAAE,CACX,CAAA;IAED,MAAM,CAAC,eAAe,CAAC,YAAiC;QACtD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,YAAiC;QACxD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAC5C,CAAC;IAKD,MAAM,CAAC,GAAG,CAAqD,kBAA0C,EAAE,QAAkB;QAC3H,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,kBAAyB,EAAE,QAAQ,CAAC,CAAA;IACjE,CAAC;;AAvGH,gCAwGC"}
|
|
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CatNlogsError = void 0;
|
|
4
4
|
const nlogs_error_1 = require("./nlogs.error");
|
|
5
5
|
class CatNlogsError extends nlogs_error_1.NlogsError {
|
|
6
|
-
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.code = 'CAT_NLOGS_ERR';
|
|
9
|
-
}
|
|
6
|
+
code = 'CAT_NLOGS_ERR';
|
|
10
7
|
}
|
|
11
8
|
exports.CatNlogsError = CatNlogsError;
|
|
12
9
|
//# sourceMappingURL=cat.nlogs.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/cat.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,aAAc,SAAQ,wBAAU;
|
|
1
|
+
{"version":3,"file":"cat.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/cat.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,aAAc,SAAQ,wBAAU;IAClC,IAAI,GAAG,eAAe,CAAA;CAChC;AAFD,sCAEC"}
|
|
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FsNlogsError = void 0;
|
|
4
4
|
const nlogs_error_1 = require("./nlogs.error");
|
|
5
5
|
class FsNlogsError extends nlogs_error_1.NlogsError {
|
|
6
|
-
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.code = 'FS_NLOGS_ERR';
|
|
9
|
-
}
|
|
6
|
+
code = 'FS_NLOGS_ERR';
|
|
10
7
|
}
|
|
11
8
|
exports.FsNlogsError = FsNlogsError;
|
|
12
9
|
//# sourceMappingURL=fs.nlogs.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/fs.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,YAAa,SAAQ,wBAAU;
|
|
1
|
+
{"version":3,"file":"fs.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/fs.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,YAAa,SAAQ,wBAAU;IACjC,IAAI,GAAG,cAAc,CAAA;CAC/B;AAFD,oCAEC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ItemNlogsError = void 0;
|
|
4
4
|
const nlogs_error_1 = require("./nlogs.error");
|
|
5
5
|
class ItemNlogsError extends nlogs_error_1.NlogsError {
|
|
6
|
+
code = 'ITEM_NLOGS_ERR';
|
|
6
7
|
}
|
|
7
8
|
exports.ItemNlogsError = ItemNlogsError;
|
|
8
9
|
//# sourceMappingURL=item.nlogs.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/item.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,cAAe,SAAQ,wBAAU;
|
|
1
|
+
{"version":3,"file":"item.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/item.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,cAAe,SAAQ,wBAAU;IACnC,IAAI,GAAG,gBAAgB,CAAA;CACjC;AAFD,wCAEC"}
|
|
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MsgNlogsError = void 0;
|
|
4
4
|
const nlogs_error_1 = require("./nlogs.error");
|
|
5
5
|
class MsgNlogsError extends nlogs_error_1.NlogsError {
|
|
6
|
-
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.code = 'MSG_NLOGS_ERR';
|
|
9
|
-
}
|
|
6
|
+
code = 'MSG_NLOGS_ERR';
|
|
10
7
|
}
|
|
11
8
|
exports.MsgNlogsError = MsgNlogsError;
|
|
12
9
|
//# sourceMappingURL=msg.nlogs.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msg.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/msg.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,aAAc,SAAQ,wBAAU;
|
|
1
|
+
{"version":3,"file":"msg.nlogs.error.js","sourceRoot":"","sources":["../../src/errors/msg.nlogs.error.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,MAAa,aAAc,SAAQ,wBAAU;IAClC,IAAI,GAAG,eAAe,CAAA;CAChC;AAFD,sCAEC"}
|
|
@@ -4,10 +4,11 @@ exports.ParamNlogsError = void 0;
|
|
|
4
4
|
const string_1 = require("../helpers/string");
|
|
5
5
|
const nlogs_error_1 = require("./nlogs.error");
|
|
6
6
|
class ParamNlogsError extends nlogs_error_1.NlogsError {
|
|
7
|
+
source;
|
|
8
|
+
code = 'PARAM_NLOGS_ERR';
|
|
7
9
|
constructor(source, params) {
|
|
8
10
|
super(`Not valid parameter ${(0, string_1.prettyList)(params)} for ${(0, string_1.prettyValue)(source)}.`, params);
|
|
9
11
|
this.source = source;
|
|
10
|
-
this.code = 'PARAM_NLOGS_ERR';
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
exports.ParamNlogsError = ParamNlogsError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"param.error.js","sourceRoot":"","sources":["../../src/errors/param.error.ts"],"names":[],"mappings":";;;AAAA,8CAA2D;AAC3D,+CAA0C;AAE1C,MAAa,eAAgB,SAAQ,wBAA6B;
|
|
1
|
+
{"version":3,"file":"param.error.js","sourceRoot":"","sources":["../../src/errors/param.error.ts"],"names":[],"mappings":";;;AAAA,8CAA2D;AAC3D,+CAA0C;AAE1C,MAAa,eAAgB,SAAQ,wBAA6B;IAIrD;IAHF,IAAI,GAAG,iBAAiB,CAAA;IAEjC,YACW,MAAc,EACvB,MAAyB;QAEzB,KAAK,CAAC,uBAAuB,IAAA,mBAAU,EAAC,MAAM,CAAC,QAAQ,IAAA,oBAAW,EAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAH7E,WAAM,GAAN,MAAM,CAAQ;IAIzB,CAAC;CACF;AATD,0CASC"}
|
package/dist/helpers/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/helpers/fs.ts"],"names":[],"mappings":";;;A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AI,KAAK,GAAG,IAAI,IAAI,KAAK,YAAI;QAAE,OAAO,IAAI,CAAA;IACvD,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,6BAAY,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAA;IAC/E,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAA,2BAAmB,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;IACpG,MAAM,EAAE,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAA;IACvB,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACrC,KAAK,CAAC,cAAc,QAAQ,cAAc,IAAI,kBAAkB,UAAU,eAAe,QAAQ,EAAE,CAAC,CAAA;IACpG,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE;QAAE,OAAO,IAAA,2BAAmB,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACxE,IAAI,IAAA,cAAM,EAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAA;IAErC,OAAO,IAAA,2BAAmB,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;AAClD,CAAC,CAAA;AAZY,QAAA,mBAAmB,uBAY/B"}
|
package/dist/helpers/stack.js
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTopStackFile = exports.clearStackPath = exports.stackToArray = exports.filterNotInternalStack = exports.getStackTrace = void 0;
|
|
4
4
|
const rgx = /(node:)?internal\//;
|
|
5
|
+
const STACK_TRACE_LIMIT = 50;
|
|
5
6
|
const getStackTrace = (fn) => {
|
|
6
7
|
const originalLimit = Error.stackTraceLimit;
|
|
7
8
|
const originalPrepare = Error.prepareStackTrace;
|
|
8
9
|
const handleObject = { stack: '' };
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
Error.stackTraceLimit = STACK_TRACE_LIMIT;
|
|
12
|
+
Error.prepareStackTrace = function (_err, _cs) {
|
|
13
|
+
return handleObject.stack;
|
|
14
|
+
};
|
|
15
|
+
Error.captureStackTrace(handleObject, fn || exports.getStackTrace);
|
|
11
16
|
return handleObject.stack;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return stack;
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
Error.stackTraceLimit = originalLimit;
|
|
20
|
+
Error.prepareStackTrace = originalPrepare;
|
|
21
|
+
}
|
|
18
22
|
};
|
|
19
23
|
exports.getStackTrace = getStackTrace;
|
|
20
24
|
const filterNotInternalStack = (stack) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/helpers/stack.ts"],"names":[],"mappings":";;;AAIA,MAAM,GAAG,GAAG,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/helpers/stack.ts"],"names":[],"mappings":";;;AAIA,MAAM,GAAG,GAAG,oBAAoB,CAAA;AAEhC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAErB,MAAM,aAAa,GAAG,CAAC,EAAQ,EAAE,EAAE;IACxC,MAAM,aAAa,GAAG,KAAK,CAAC,eAAe,CAAA;IAC3C,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,CAAA;IAC/C,MAAM,YAAY,GAAa,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IAE5C,IAAI,CAAC;QACH,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAA;QACzC,KAAK,CAAC,iBAAiB,GAAG,UAAU,IAAS,EAAE,GAAQ;YACrD,O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AAA;AAlBY,QAAA,sBAAsB,0BAkBlC;AAEM,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAApG,QAAA,YAAY,gBAAwF;AAE1G,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE,CACpD,GAAG;KACA,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC;IAC/B,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;IAC3B,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAJd,QAAA,cAAc,kBAIA;AAEpB,MAAM,eAAe,GAAG,CAAC,EAAQ,EAAiB,EAAE;IACzD,MAAM,KAAK,GAAG,IAAA,8BAAsB,EAAC,IAAA,oBAAY,EAAC,IAAA,qBAAa,EAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACrE,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAC9B,OAAO,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACjC,CAAC,CAAA;AAJY,QAAA,eAAe,mBAI3B"}
|
package/dist/helpers/symbols.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMetaInfo = exports.toMetaInfo = exports.EMPTY = exports.INTERPOLATE = exports.SHOW = exports.DEPTH = exports.HIDDEN_DETAILS = exports.NO_CONSOLE = exports.DETAILS = exports.TIMESTAMP = exports.INDEX = exports.TRACE_ID = exports.LEVEL = exports.CATEGORY = exports.SERVICE = exports.PROJECT = exports.MODULE = exports.STACKTRACE = exports.HIGHLIGHT = exports.TIMERANGE = exports.TIME = exports.META_VALUE = exports.IS_META_INFO =
|
|
4
|
-
exports.IS_META = Symbol('nlogs(is meta)');
|
|
3
|
+
exports.isMetaInfo = exports.toMetaInfo = exports.EMPTY = exports.INTERPOLATE = exports.SHOW = exports.DEPTH = exports.HIDDEN_DETAILS = exports.NO_CONSOLE = exports.DETAILS = exports.TIMESTAMP = exports.INDEX = exports.TRACE_ID = exports.LEVEL = exports.CATEGORY = exports.SERVICE = exports.PROJECT = exports.MODULE = exports.STACKTRACE = exports.HIGHLIGHT = exports.TIMERANGE = exports.TIME = exports.META_VALUE = exports.IS_META_INFO = void 0;
|
|
5
4
|
exports.IS_META_INFO = Symbol('nlogs(is meta info)');
|
|
6
5
|
exports.META_VALUE = Symbol('nlogs(meta value)');
|
|
7
6
|
exports.TIME = Symbol('nlogs(message:time)');
|
|
@@ -18,7 +17,7 @@ exports.INDEX = Symbol('nlogs(meta:index)');
|
|
|
18
17
|
exports.TIMESTAMP = Symbol('nlogs(meta:timestamp)');
|
|
19
18
|
exports.DETAILS = Symbol('nlogs(details)');
|
|
20
19
|
exports.NO_CONSOLE = Symbol('nlogs(no console)');
|
|
21
|
-
exports.HIDDEN_DETAILS = Symbol('nlogs(
|
|
20
|
+
exports.HIDDEN_DETAILS = Symbol('nlogs(hidden details)');
|
|
22
21
|
exports.DEPTH = Symbol('nlogs(depth)');
|
|
23
22
|
exports.SHOW = Symbol('nlogs(show)');
|
|
24
23
|
exports.INTERPOLATE = Symbol('nlogs(interpolate)');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/helpers/symbols.ts"],"names":[],"mappings":";;;AAEa,QAAA,
|
|
1
|
+
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/helpers/symbols.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAC5C,QAAA,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAGxC,QAAA,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