@venizia/ignis-docs 0.2.0 → 0.2.1-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 +14 -14
- package/content/best-practices/api-usage-examples.md +39 -19
- package/content/best-practices/architectural-patterns.md +22 -11
- package/content/best-practices/architecture-decisions.md +29 -16
- package/content/best-practices/code-style-standards/advanced-patterns.md +43 -31
- package/content/best-practices/code-style-standards/constants-configuration.md +19 -4
- package/content/best-practices/code-style-standards/control-flow.md +33 -1
- package/content/best-practices/code-style-standards/documentation.md +28 -8
- package/content/best-practices/code-style-standards/function-patterns.md +15 -4
- package/content/best-practices/code-style-standards/index.md +7 -2
- package/content/best-practices/code-style-standards/naming-conventions.md +26 -2
- package/content/best-practices/code-style-standards/route-definitions.md +9 -5
- package/content/best-practices/code-style-standards/tooling.md +14 -1
- package/content/best-practices/code-style-standards/type-safety.md +39 -6
- package/content/best-practices/common-pitfalls.md +59 -35
- package/content/best-practices/contribution-workflow.md +6 -2
- package/content/best-practices/data-modeling.md +78 -62
- package/content/best-practices/deployment-strategies.md +56 -19
- package/content/best-practices/error-handling.md +182 -93
- package/content/best-practices/index.md +6 -0
- package/content/best-practices/performance-optimization.md +26 -13
- package/content/best-practices/security-guidelines.md +35 -9
- package/content/best-practices/testing-strategies.md +7 -2
- package/content/best-practices/troubleshooting-tips.md +27 -17
- package/content/extensions/components/api-reference.md +107 -322
- package/content/extensions/components/authentication/api.md +454 -603
- package/content/extensions/components/authentication/errors.md +121 -498
- package/content/extensions/components/authentication/index.md +88 -801
- package/content/extensions/components/authentication/usage.md +207 -956
- package/content/extensions/components/authorization/api.md +736 -656
- package/content/extensions/components/authorization/errors.md +168 -206
- package/content/extensions/components/authorization/index.md +82 -797
- package/content/extensions/components/authorization/usage.md +194 -527
- package/content/extensions/components/health-check.md +71 -243
- package/content/extensions/components/mail/api.md +504 -287
- package/content/extensions/components/mail/errors.md +73 -61
- package/content/extensions/components/mail/index.md +96 -467
- package/content/extensions/components/mail/usage.md +130 -172
- package/content/extensions/components/request-tracker.md +66 -173
- package/content/extensions/components/socket-io/api.md +195 -13
- package/content/extensions/components/socket-io/errors.md +3 -3
- package/content/extensions/components/socket-io/index.md +50 -337
- package/content/extensions/components/socket-io/usage.md +143 -26
- package/content/extensions/components/static-asset/api.md +410 -142
- package/content/extensions/components/static-asset/errors.md +110 -53
- package/content/extensions/components/static-asset/index.md +79 -608
- package/content/extensions/components/static-asset/usage.md +180 -300
- package/content/extensions/components/websocket/api.md +275 -399
- package/content/extensions/components/websocket/errors.md +47 -56
- package/content/extensions/components/websocket/index.md +74 -407
- package/content/extensions/components/websocket/usage.md +110 -341
- package/content/extensions/helpers/cron/index.md +51 -160
- package/content/extensions/helpers/crypto/index.md +62 -483
- package/content/extensions/helpers/crypto/reference.md +456 -0
- package/content/extensions/helpers/env/index.md +60 -178
- package/content/extensions/helpers/error/index.md +221 -207
- package/content/extensions/helpers/inversion/index.md +65 -556
- package/content/extensions/helpers/inversion/reference.md +522 -0
- package/content/extensions/helpers/kafka/admin.md +20 -1
- package/content/extensions/helpers/kafka/compile-binary.md +41 -35
- package/content/extensions/helpers/kafka/consumer.md +54 -20
- package/content/extensions/helpers/kafka/examples.md +21 -16
- package/content/extensions/helpers/kafka/index.md +80 -610
- package/content/extensions/helpers/kafka/producer.md +134 -5
- package/content/extensions/helpers/kafka/schema-registry.md +45 -70
- package/content/extensions/helpers/logger/hf-logger.md +193 -0
- package/content/extensions/helpers/logger/index.md +64 -563
- package/content/extensions/helpers/logger/pino.md +85 -0
- package/content/extensions/helpers/logger/reference.md +746 -0
- package/content/extensions/helpers/network/api.md +241 -195
- package/content/extensions/helpers/network/index.md +72 -530
- package/content/extensions/helpers/queue/index.md +72 -900
- package/content/extensions/helpers/queue/reference.md +467 -0
- package/content/extensions/helpers/redis/index.md +73 -645
- package/content/extensions/helpers/redis/reference.md +727 -0
- package/content/extensions/helpers/secrets/index.md +66 -0
- package/content/extensions/helpers/socket-io/api.md +305 -203
- package/content/extensions/helpers/socket-io/index.md +66 -432
- package/content/extensions/helpers/storage/api.md +564 -462
- package/content/extensions/helpers/storage/index.md +77 -573
- package/content/extensions/helpers/types/index.md +66 -499
- package/content/extensions/helpers/types/reference.md +650 -0
- package/content/extensions/helpers/uid/index.md +58 -227
- package/content/extensions/helpers/websocket/api.md +329 -216
- package/content/extensions/helpers/websocket/index.md +65 -503
- package/content/extensions/helpers/worker-thread/index.md +58 -396
- package/content/extensions/helpers/worker-thread/reference.md +428 -0
- package/content/guides/core-concepts/persistent/models.md +1 -1
- package/content/guides/core-concepts/persistent/search-typesense.md +3 -3
- package/content/guides/core-concepts/persistent/transactions.md +1 -1
- package/content/guides/core-concepts/secrets-vault.md +177 -0
- package/content/guides/core-concepts/services.md +1 -1
- package/content/guides/migrations/redis-helpers-migration.md +1 -1
- package/content/guides/migrations/unified-connectors-migration.md +2 -2
- package/content/guides/tutorials/ecommerce-api.md +3 -8
- package/content/references/base/application.md +1 -1
- package/content/references/base/connectors.md +79 -136
- package/content/references/base/datasources-reference.md +599 -0
- package/content/references/base/datasources.md +84 -444
- package/content/references/base/dependency-injection.md +17 -39
- package/content/references/base/filter-system/application-usage.md +69 -121
- package/content/references/base/filter-system/array-operators.md +12 -0
- package/content/references/base/filter-system/comparison-operators.md +12 -0
- package/content/references/base/filter-system/default-filter.md +136 -348
- package/content/references/base/filter-system/fields-order-pagination.md +38 -16
- package/content/references/base/filter-system/index.md +106 -257
- package/content/references/base/filter-system/json-filtering.md +12 -2
- package/content/references/base/filter-system/list-operators.md +16 -2
- package/content/references/base/filter-system/logical-operators.md +13 -0
- package/content/references/base/filter-system/null-operators.md +13 -0
- package/content/references/base/filter-system/pattern-matching.md +12 -0
- package/content/references/base/filter-system/quick-reference.md +11 -2
- package/content/references/base/filter-system/range-operators.md +12 -0
- package/content/references/base/filter-system/tips.md +70 -133
- package/content/references/base/filter-system/use-cases.md +156 -233
- package/content/references/base/middlewares.md +35 -21
- package/content/references/base/models-reference.md +886 -0
- package/content/references/base/models.md +80 -1452
- package/content/references/base/repositories/advanced.md +156 -192
- package/content/references/base/repositories/index.md +77 -650
- package/content/references/base/repositories/mixins.md +22 -18
- package/content/references/base/repositories/relations.md +123 -171
- package/content/references/base/repositories/soft-deletable.md +58 -56
- package/content/references/base/secrets.md +263 -0
- package/content/references/base/services.md +2 -2
- package/content/references/configuration/environment-variables.md +48 -4
- package/content/references/configuration/index.md +49 -31
- package/content/references/quick-reference.md +3 -16
- package/content/references/utilities/crypto.md +35 -76
- package/content/references/utilities/date.md +33 -73
- package/content/references/utilities/index.md +1 -1
- package/content/references/utilities/jsx-reference.md +298 -0
- package/content/references/utilities/jsx.md +82 -525
- package/content/references/utilities/module.md +29 -62
- package/content/references/utilities/parse.md +34 -64
- package/content/references/utilities/performance.md +33 -58
- package/content/references/utilities/promise.md +28 -62
- package/content/references/utilities/request.md +57 -218
- package/content/references/utilities/schema.md +43 -137
- package/content/references/utilities/statuses-reference.md +361 -0
- package/content/references/utilities/statuses.md +63 -667
- package/package.json +8 -8
|
@@ -1,173 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Winston
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
---
|
|
2
|
+
title: Logger
|
|
3
|
+
description: Scoped, cached Winston logging with console, daily-rotating file, and UDP transports
|
|
4
|
+
difficulty: beginner
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|-------|---------|----------|
|
|
9
|
-
| `Logger` | -- | General-purpose scoped logger with caching |
|
|
10
|
-
| `LoggerFactory` | -- | Factory that builds `Logger` instances from scope arrays |
|
|
11
|
-
| `HfLogger` | -- | Zero-allocation ring-buffer logger for hot paths (~100-300ns) |
|
|
12
|
-
| `HfLogFlusher` | -- | Background flusher for `HfLogger` entries |
|
|
13
|
-
| `DgramTransport` | `winston-transport.Transport` | Custom Winston transport that sends logs over UDP |
|
|
14
|
-
|
|
15
|
-
#### Import Paths
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
// Core classes
|
|
19
|
-
import { Logger, LoggerFactory, ApplicationLogger } from '@venizia/ignis-helpers';
|
|
20
|
-
|
|
21
|
-
// High-frequency logger
|
|
22
|
-
import { HfLogger, HfLogFlusher } from '@venizia/ignis-helpers';
|
|
23
|
-
|
|
24
|
-
// Constants & types
|
|
25
|
-
import { LogLevels, LoggerFormats } from '@venizia/ignis-helpers';
|
|
26
|
-
import type { TLogLevel, TLoggerFormat } from '@venizia/ignis-helpers';
|
|
27
|
-
|
|
28
|
-
// Custom logger utilities
|
|
29
|
-
import {
|
|
30
|
-
defineCustomLogger,
|
|
31
|
-
defineLogFormatter,
|
|
32
|
-
defineJsonLoggerFormatter,
|
|
33
|
-
definePrettyLoggerFormatter,
|
|
34
|
-
applicationLogFormatter,
|
|
35
|
-
applicationLogger,
|
|
36
|
-
} from '@venizia/ignis-helpers';
|
|
37
|
-
import type { IFileTransportOptions, ICustomLoggerOptions } from '@venizia/ignis-helpers';
|
|
38
|
-
|
|
39
|
-
// UDP transport
|
|
40
|
-
import { DgramTransport } from '@venizia/ignis-helpers';
|
|
41
|
-
import type { IDgramTransportOptions } from '@venizia/ignis-helpers';
|
|
42
|
-
```
|
|
7
|
+
# Logger
|
|
43
8
|
|
|
44
|
-
|
|
9
|
+
The logger helper wraps Winston in a scoped, cached `Logger` class with console, daily-rotating file, and UDP transports built in.
|
|
45
10
|
|
|
46
|
-
|
|
11
|
+
## In one example
|
|
47
12
|
|
|
48
|
-
|
|
13
|
+
The smallest real use: get a scoped logger and log with it.
|
|
49
14
|
|
|
50
15
|
```typescript
|
|
51
16
|
import { LoggerFactory } from '@venizia/ignis-helpers';
|
|
52
17
|
|
|
53
|
-
const logger = LoggerFactory.getLogger(['
|
|
54
|
-
logger.info('
|
|
55
|
-
// Output: [
|
|
56
|
-
|
|
57
|
-
const scopedLogger = LoggerFactory.getLogger(['Payment', 'Stripe']);
|
|
58
|
-
scopedLogger.info('Charge created');
|
|
59
|
-
// Output: [Payment-Stripe] Charge created
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
> [!TIP]
|
|
63
|
-
> `LoggerFactory` is how `BaseHelper` creates its internal logger. Every helper in the framework gets a scoped logger automatically through this path.
|
|
64
|
-
|
|
65
|
-
### Using Logger.get() Directly
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import { Logger } from '@venizia/ignis-helpers';
|
|
69
|
-
|
|
70
|
-
const logger = Logger.get('MyService');
|
|
71
|
-
logger.info('Direct logger access');
|
|
72
|
-
// Output: [MyService] Direct logger access
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Pass a custom Winston logger instance as the second parameter to use your own transport configuration:
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
import { Logger, defineCustomLogger, applicationLogFormatter } from '@venizia/ignis-helpers';
|
|
79
|
-
|
|
80
|
-
const customWinstonLogger = defineCustomLogger({
|
|
81
|
-
loggerFormatter: applicationLogFormatter,
|
|
82
|
-
transports: {
|
|
83
|
-
info: { file: { prefix: 'custom', folder: './logs' } },
|
|
84
|
-
error: { file: { prefix: 'custom-error', folder: './logs' } },
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const logger = Logger.get('MyService', customWinstonLogger);
|
|
18
|
+
const logger = LoggerFactory.getLogger(['UserService']);
|
|
19
|
+
logger.info('User created');
|
|
20
|
+
// Output: [UserService] User created
|
|
89
21
|
```
|
|
90
22
|
|
|
91
|
-
|
|
23
|
+
`LoggerFactory` is how `BaseHelper` creates its internal logger, so every helper in the framework gets a scoped logger the same way, for free.
|
|
92
24
|
|
|
93
|
-
|
|
25
|
+
## How it works
|
|
94
26
|
|
|
95
|
-
|
|
27
|
+
- **Typed against `ILogger`.** Every consumer, including `BaseHelper.logger`, receives the `ILogger` interface, not a concrete class - Winston is the built-in provider behind it today, selected in `factory.ts`.
|
|
28
|
+
- **Provider-based.** `LoggerFactory.use({ provider })` selects the app's logger engine once at the entrypoint - Winston by default, [pino](/extensions/helpers/logger/pino) for throughput. Every factory-issued logger (including ones captured at import time) follows the registration.
|
|
29
|
+
- **Scoped and cached.** `LoggerFactory.getLogger(scopes)` joins the scopes with `-` and caches per scope - the same scope returns the same instance. `BaseHelper` calls this in its constructor, so every helper gets `this.logger` scoped automatically. (Custom-backed winston loggers - `Logger.get(scope, customWinstonLogger)` from the `/winston` sub-path - are NOT cached: each call is a fresh wrapper over the given instance.)
|
|
30
|
+
- **Method scoping.** `.for(methodName)` returns a child logger scoped to `<scope>-<methodName>` (also cached), so each line shows where it came from.
|
|
31
|
+
- **Level floor.** `APP_ENV_LOGGER_LEVEL` (default `debug`) sets the logger-level floor; transports without their own level inherit it.
|
|
32
|
+
- **`debug()` is gated.** It emits only when `DEBUG=true` and `NODE_ENV` is unset or in `Environment.COMMON_ENVS` (extend via `APP_ENV_EXTRA_LOG_ENVS`). The check runs once at module load - runtime env changes need a restart.
|
|
96
33
|
|
|
97
|
-
|
|
98
|
-
const logger1 = Logger.get('MyService');
|
|
99
|
-
const logger2 = Logger.get('MyService');
|
|
100
|
-
// logger1 === logger2 (same instance)
|
|
101
|
-
```
|
|
34
|
+
**Log levels**
|
|
102
35
|
|
|
103
|
-
|
|
36
|
+
Five levels, each with a direct method: `debug`, `info`, `warn`, `error`, `emerg`. The generic `.log(level, ...)` remains for picking the level dynamically. What each level MEANS and when to use it is in the [level guide](/extensions/helpers/logger/reference#what-each-level-means).
|
|
104
37
|
|
|
105
|
-
|
|
38
|
+
**Transports**
|
|
106
39
|
|
|
107
|
-
|
|
108
|
-
|
|
40
|
+
| Transport | Turns on when |
|
|
41
|
+
|-----------|---------------|
|
|
42
|
+
| Console | Always |
|
|
43
|
+
| Daily-rotating file | `APP_ENV_LOGGER_FOLDER_PATH` is set |
|
|
44
|
+
| UDP (`DgramTransport`) | All four UDP `APP_ENV_LOGGER_DGRAM_*` variables are set |
|
|
109
45
|
|
|
110
|
-
|
|
111
|
-
```
|
|
46
|
+
Output shape (plain text or JSON) follows `APP_ENV_LOGGER_FORMAT`. Color codes appear only on the console - file and UDP output never carries ANSI escapes. For extreme hot paths, `HfLogger` is a separate ring-buffer logger outside this pipeline - it has its own [usage guide](/extensions/helpers/logger/hf-logger). The [Full reference](/extensions/helpers/logger/reference) covers everything else, including the `ApplicationLogger` facade.
|
|
112
47
|
|
|
113
|
-
##
|
|
48
|
+
## Common tasks
|
|
114
49
|
|
|
115
|
-
###
|
|
50
|
+
### Get a scoped logger
|
|
116
51
|
|
|
117
|
-
|
|
52
|
+
Use `LoggerFactory.getLogger` with an array of scope segments, or `ApplicationLogger.get` with a single string. Both cache by scope and follow the registered provider.
|
|
118
53
|
|
|
119
54
|
```typescript
|
|
120
|
-
|
|
121
|
-
logger.warn('Rate limit approaching');
|
|
122
|
-
logger.error('Failed to process payment');
|
|
123
|
-
logger.emerg('System out of memory');
|
|
124
|
-
logger.debug('Query took 12ms'); // Requires DEBUG=true
|
|
125
|
-
logger.log('alert', 'Threshold exceeded'); // Generic method for any level
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
The `LogLevels` class defines all available levels and provides validation:
|
|
55
|
+
import { ApplicationLogger, LoggerFactory } from '@venizia/ignis-helpers';
|
|
129
56
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
import type { TLogLevel } from '@venizia/ignis-helpers';
|
|
133
|
-
|
|
134
|
-
LogLevels.ERROR; // 'error'
|
|
135
|
-
LogLevels.ALERT; // 'alert'
|
|
136
|
-
LogLevels.EMERG; // 'emerg'
|
|
137
|
-
LogLevels.WARN; // 'warn'
|
|
138
|
-
LogLevels.INFO; // 'info'
|
|
139
|
-
LogLevels.HTTP; // 'http'
|
|
140
|
-
LogLevels.VERBOSE; // 'verbose'
|
|
141
|
-
LogLevels.DEBUG; // 'debug'
|
|
142
|
-
LogLevels.SILLY; // 'silly'
|
|
143
|
-
|
|
144
|
-
LogLevels.isValid('info'); // true
|
|
145
|
-
LogLevels.isValid('unknown'); // false
|
|
146
|
-
|
|
147
|
-
const level: TLogLevel = 'info';
|
|
57
|
+
const scoped = LoggerFactory.getLogger(['Payment', 'Stripe']); // [Payment-Stripe]
|
|
58
|
+
const direct = ApplicationLogger.get('MyService'); // [MyService]
|
|
148
59
|
```
|
|
149
60
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
The `defineCustomLogger` function configures Winston with these numeric priorities by default:
|
|
61
|
+
### Scope logs to a method
|
|
153
62
|
|
|
154
|
-
|
|
155
|
-
|-------|----------|-------|
|
|
156
|
-
| `error` | 0 | red |
|
|
157
|
-
| `alert` | 0 | red |
|
|
158
|
-
| `emerg` | 0 | red |
|
|
159
|
-
| `warn` | 1 | yellow |
|
|
160
|
-
| `info` | 2 | green |
|
|
161
|
-
| `http` | 3 | magenta |
|
|
162
|
-
| `verbose` | 4 | gray |
|
|
163
|
-
| `debug` | 5 | blue |
|
|
164
|
-
| `silly` | 6 | gray |
|
|
165
|
-
|
|
166
|
-
Lower numeric values have higher priority. `error`, `alert`, and `emerg` share priority `0`.
|
|
167
|
-
|
|
168
|
-
### Method-Scoped Logging
|
|
169
|
-
|
|
170
|
-
The `.for()` method creates a sub-scoped logger for specific methods, appending the method name to the scope with a `-` separator. The resulting logger is also cached.
|
|
63
|
+
`.for()` appends a method name to the current scope so every line in that method self-identifies.
|
|
171
64
|
|
|
172
65
|
```typescript
|
|
173
66
|
class UserService {
|
|
@@ -176,455 +69,63 @@ class UserService {
|
|
|
176
69
|
async createUser(data: CreateUserDto) {
|
|
177
70
|
this.logger.for('createUser').info('Creating user: %j', data);
|
|
178
71
|
// Output: [UserService-createUser] Creating user: {...}
|
|
179
|
-
|
|
180
|
-
try {
|
|
181
|
-
const user = await this.userRepo.create({ data });
|
|
182
|
-
this.logger.for('createUser').info('User created: %s', user.id);
|
|
183
|
-
return user;
|
|
184
|
-
} catch (error) {
|
|
185
|
-
this.logger.for('createUser').error('Failed to create user: %s', error);
|
|
186
|
-
throw error;
|
|
187
|
-
}
|
|
188
72
|
}
|
|
189
73
|
}
|
|
190
74
|
```
|
|
191
75
|
|
|
192
|
-
###
|
|
76
|
+
### Log an Error with `%s`, never `%j`
|
|
193
77
|
|
|
194
|
-
`message` and `stack` are non-enumerable
|
|
78
|
+
`message` and `stack` are non-enumerable on a native `Error`. `%j` formats via `JSON.stringify`, which only visits enumerable own properties, so it silently drops both. Always pair an `Error` argument with `%s`.
|
|
195
79
|
|
|
196
80
|
```typescript
|
|
197
|
-
|
|
198
|
-
logger.error('Failed to create user: %s', error);
|
|
199
|
-
|
|
200
|
-
// ❌ Bad - %j drops message and stack (non-enumerable on Error)
|
|
201
|
-
logger.error('Failed to create user: %j', error);
|
|
81
|
+
logger.error('Failed to create user: %s', error); // prints message + stack
|
|
202
82
|
```
|
|
203
83
|
|
|
204
|
-
###
|
|
84
|
+
### Switch the output format
|
|
205
85
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
logger.error('Failed: %s', error); // nested `error.cause` is now visible, not `[Object]`
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
The inspection depth defaults to `5` and is configurable via `APP_ENV_LOGGER_INSPECT_DEPTH`:
|
|
86
|
+
`APP_ENV_LOGGER_FORMAT` controls plain text (default) vs. JSON output.
|
|
213
87
|
|
|
214
88
|
```bash
|
|
215
|
-
|
|
89
|
+
APP_ENV_LOGGER_FORMAT=text # 2024-01-11T10:30:00.000Z [APP] info: [UserService] User created
|
|
90
|
+
APP_ENV_LOGGER_FORMAT=json # {"level":"info","message":"[UserService] User created", ...}
|
|
216
91
|
```
|
|
217
92
|
|
|
218
|
-
The
|
|
219
|
-
|
|
220
|
-
### Log Formats
|
|
93
|
+
The `[APP]` label comes from `APP_ENV_APPLICATION_NAME` (defaults to `'APP'`).
|
|
221
94
|
|
|
222
|
-
|
|
95
|
+
### Enable daily file rotation
|
|
223
96
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
import { LoggerFormats } from '@venizia/ignis-helpers';
|
|
228
|
-
import type { TLoggerFormat } from '@venizia/ignis-helpers';
|
|
229
|
-
|
|
230
|
-
LoggerFormats.JSON; // 'json'
|
|
231
|
-
LoggerFormats.TEXT; // 'text'
|
|
232
|
-
LoggerFormats.isValid('json'); // true
|
|
233
|
-
|
|
234
|
-
const fmt: TLoggerFormat = 'text';
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
#### JSON Format
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
APP_ENV_LOGGER_FORMAT=json
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
Output:
|
|
244
|
-
|
|
245
|
-
```json
|
|
246
|
-
{"level":"info","message":"[UserService] User created","timestamp":"2024-01-11T10:30:00.000Z","label":"APP"}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
#### Pretty Text Format (Default)
|
|
97
|
+
Point `APP_ENV_LOGGER_FOLDER_PATH` at a directory; rotation frequency, size cap, and retention are also env-driven. Without this variable no log files are written - console (and UDP, if configured) remain the only outputs.
|
|
250
98
|
|
|
251
99
|
```bash
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
Output:
|
|
256
|
-
|
|
257
|
-
```
|
|
258
|
-
2024-01-11T10:30:00.000Z [APP] info: [UserService] User created
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
> [!NOTE]
|
|
262
|
-
> The label shown in log output (e.g. `APP`) comes from `APP_ENV_APPLICATION_NAME` (defaults to `'APP'`). Set this env var to customize the label for your application.
|
|
263
|
-
|
|
264
|
-
#### Custom Formatters
|
|
265
|
-
|
|
266
|
-
Build formatters directly using the exported helper functions:
|
|
267
|
-
|
|
268
|
-
```typescript
|
|
269
|
-
import {
|
|
270
|
-
defineLogFormatter,
|
|
271
|
-
defineJsonLoggerFormatter,
|
|
272
|
-
definePrettyLoggerFormatter,
|
|
273
|
-
} from '@venizia/ignis-helpers';
|
|
274
|
-
|
|
275
|
-
// Auto-detect from APP_ENV_LOGGER_FORMAT (or override with format option)
|
|
276
|
-
const formatter = defineLogFormatter({ label: 'my-app' });
|
|
277
|
-
const jsonFmt = defineLogFormatter({ label: 'my-app', format: 'json' });
|
|
278
|
-
|
|
279
|
-
// Or use specific formatters directly
|
|
280
|
-
const jsonFormatter = defineJsonLoggerFormatter({ label: 'my-app' });
|
|
281
|
-
const prettyFormatter = definePrettyLoggerFormatter({ label: 'my-app' });
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### Transports
|
|
285
|
-
|
|
286
|
-
Every logger created by `defineCustomLogger` always includes a **Console** transport at the `debug` level. File and UDP transports are optional.
|
|
287
|
-
|
|
288
|
-
#### File Rotation (DailyRotateFile)
|
|
289
|
-
|
|
290
|
-
Configure file rotation through environment variables or programmatically via `IFileTransportOptions`.
|
|
291
|
-
|
|
292
|
-
**Environment variables:**
|
|
293
|
-
|
|
294
|
-
| Variable | Default | Description |
|
|
295
|
-
|----------|---------|-------------|
|
|
296
|
-
| `APP_ENV_LOGGER_FOLDER_PATH` | `./` | Log files directory |
|
|
297
|
-
| `APP_ENV_LOGGER_FILE_FREQUENCY` | `1h` | Rotation frequency |
|
|
298
|
-
| `APP_ENV_LOGGER_FILE_MAX_SIZE` | `100m` | Max file size before rotation |
|
|
299
|
-
| `APP_ENV_LOGGER_FILE_MAX_FILES` | `5d` | Retention period |
|
|
300
|
-
| `APP_ENV_LOGGER_FILE_DATE_PATTERN` | `YYYYMMDD_HH` | Date pattern in filename |
|
|
301
|
-
|
|
302
|
-
**Programmatic configuration:**
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
import { defineCustomLogger, applicationLogFormatter } from '@venizia/ignis-helpers';
|
|
306
|
-
|
|
307
|
-
const customLogger = defineCustomLogger({
|
|
308
|
-
loggerFormatter: applicationLogFormatter,
|
|
309
|
-
transports: {
|
|
310
|
-
info: {
|
|
311
|
-
file: {
|
|
312
|
-
prefix: 'my-app',
|
|
313
|
-
folder: './logs',
|
|
314
|
-
frequency: '24h',
|
|
315
|
-
maxSize: '500m',
|
|
316
|
-
maxFiles: '30d',
|
|
317
|
-
datePattern: 'YYYYMMDD',
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
error: {
|
|
321
|
-
file: {
|
|
322
|
-
prefix: 'my-app-error',
|
|
323
|
-
folder: './logs',
|
|
324
|
-
maxFiles: '90d',
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
Generated filename pattern: `{folder}/{prefix}-info-{DATE}.log` or `{folder}/{prefix}-error-{DATE}.log`.
|
|
332
|
-
|
|
333
|
-
#### IFileTransportOptions
|
|
334
|
-
|
|
335
|
-
```typescript
|
|
336
|
-
interface IFileTransportOptions {
|
|
337
|
-
prefix: string; // Filename prefix (required)
|
|
338
|
-
folder: string; // Output directory (required)
|
|
339
|
-
frequency?: string; // Rotation frequency (default: '1h')
|
|
340
|
-
maxSize?: string; // Max file size (default: '100m')
|
|
341
|
-
maxFiles?: string; // Retention period (default: '5d')
|
|
342
|
-
datePattern?: string; // Date pattern in filename (default: 'YYYYMMDD_HH')
|
|
343
|
-
}
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
#### UDP Transport (DgramTransport)
|
|
347
|
-
|
|
348
|
-
The `DgramTransport` is a custom Winston transport that sends log entries over UDP. It supports level-based filtering -- only messages matching the configured `levels` set are forwarded.
|
|
349
|
-
|
|
350
|
-
```typescript
|
|
351
|
-
import { DgramTransport } from '@venizia/ignis-helpers';
|
|
352
|
-
|
|
353
|
-
const transport = new DgramTransport({
|
|
354
|
-
label: 'my-app',
|
|
355
|
-
host: '127.0.0.1',
|
|
356
|
-
port: 5000,
|
|
357
|
-
levels: ['error', 'warn', 'info'],
|
|
358
|
-
socketOptions: { type: 'udp4' },
|
|
359
|
-
});
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
**Static factory with validation** -- returns `null` if any required field is missing:
|
|
363
|
-
|
|
364
|
-
```typescript
|
|
365
|
-
const transport = DgramTransport.fromPartial({
|
|
366
|
-
label: 'my-app',
|
|
367
|
-
host: '127.0.0.1',
|
|
368
|
-
port: 5000,
|
|
369
|
-
levels: ['error', 'warn'],
|
|
370
|
-
socketOptions: { type: 'udp4' },
|
|
371
|
-
});
|
|
372
|
-
// Returns null if label, host, port, levels (non-empty), or socketOptions is missing
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
The transport automatically re-establishes the UDP socket if it encounters an error.
|
|
376
|
-
|
|
377
|
-
**Environment variables for the default application logger:**
|
|
378
|
-
|
|
379
|
-
| Variable | Description |
|
|
380
|
-
|----------|-------------|
|
|
381
|
-
| `APP_ENV_LOGGER_DGRAM_HOST` | UDP log aggregator host |
|
|
382
|
-
| `APP_ENV_LOGGER_DGRAM_PORT` | UDP log aggregator port |
|
|
383
|
-
| `APP_ENV_LOGGER_DGRAM_LABEL` | Label to identify log source |
|
|
384
|
-
| `APP_ENV_LOGGER_DGRAM_LEVELS` | Comma-separated levels to send via UDP |
|
|
385
|
-
|
|
386
|
-
#### IDgramTransportOptions
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
interface IDgramTransportOptions extends Transport.TransportStreamOptions {
|
|
390
|
-
label: string; // Label to identify log source
|
|
391
|
-
host: string; // UDP host
|
|
392
|
-
port: number; // UDP port
|
|
393
|
-
levels: Array<string>; // Levels to forward over UDP
|
|
394
|
-
socketOptions: dgram.SocketOptions; // Node.js dgram socket options
|
|
395
|
-
}
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
#### ICustomLoggerOptions
|
|
399
|
-
|
|
400
|
-
```typescript
|
|
401
|
-
interface ICustomLoggerOptions {
|
|
402
|
-
logLevels?: { [name: string | symbol]: number };
|
|
403
|
-
logColors?: { [name: string | symbol]: string };
|
|
404
|
-
loggerFormatter?: ReturnType<typeof winston.format.combine>;
|
|
405
|
-
transports: {
|
|
406
|
-
info: {
|
|
407
|
-
file?: IFileTransportOptions;
|
|
408
|
-
dgram?: Partial<IDgramTransportOptions>;
|
|
409
|
-
};
|
|
410
|
-
error: {
|
|
411
|
-
file?: IFileTransportOptions;
|
|
412
|
-
dgram?: Partial<IDgramTransportOptions>;
|
|
413
|
-
};
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
Both `info` and `error` transport groups support optional `file` (DailyRotateFile) and `dgram` (UDP) transports. A console transport is always included. Error file transports are also registered as exception handlers.
|
|
419
|
-
|
|
420
|
-
### Debug Logging Behavior
|
|
421
|
-
|
|
422
|
-
Debug logs require **both** conditions to be met:
|
|
423
|
-
|
|
424
|
-
1. `DEBUG=true` environment variable is set (parsed via `toBoolean`)
|
|
425
|
-
2. `NODE_ENV` is either unset **or** is present in the `Environment.COMMON_ENVS` set
|
|
426
|
-
|
|
427
|
-
The `COMMON_ENVS` set includes: `local`, `debug`, `development`, `dev`, `sit`, `uat`, `alpha`, `beta`, `staging`, `production`. You can extend this set with `APP_ENV_EXTRA_LOG_ENVS`:
|
|
428
|
-
|
|
429
|
-
```bash
|
|
430
|
-
DEBUG=true
|
|
431
|
-
NODE_ENV=development
|
|
432
|
-
APP_ENV_EXTRA_LOG_ENVS=qa,preview # Comma-separated additional environments
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
> [!IMPORTANT]
|
|
436
|
-
> The debug flag check is pre-computed at module load time. Changing `DEBUG` or `NODE_ENV` at runtime has no effect -- the values are captured once when the module is first imported.
|
|
437
|
-
|
|
438
|
-
### High-Frequency Logger (HfLogger)
|
|
439
|
-
|
|
440
|
-
For performance-critical applications (e.g., HFT systems, game servers), `HfLogger` provides zero-allocation logging via a lock-free ring buffer backed by `SharedArrayBuffer`.
|
|
441
|
-
|
|
442
|
-
```typescript
|
|
443
|
-
import { HfLogger, HfLogFlusher } from '@venizia/ignis-helpers';
|
|
444
|
-
|
|
445
|
-
// At initialization time (once):
|
|
446
|
-
const logger = HfLogger.get('OrderEngine');
|
|
447
|
-
const MSG_ORDER_SENT = HfLogger.encodeMessage('Order sent');
|
|
448
|
-
const MSG_ORDER_FILLED = HfLogger.encodeMessage('Order filled');
|
|
449
|
-
|
|
450
|
-
// Start background flusher
|
|
451
|
-
const flusher = new HfLogFlusher();
|
|
452
|
-
flusher.start(100); // Flush every 100ms
|
|
453
|
-
|
|
454
|
-
// In hot path (~100-300ns, zero allocation):
|
|
455
|
-
logger.log('info', MSG_ORDER_SENT);
|
|
456
|
-
logger.log('info', MSG_ORDER_FILLED);
|
|
100
|
+
APP_ENV_LOGGER_FOLDER_PATH=./app_data/logs
|
|
101
|
+
APP_ENV_LOGGER_FILE_MAX_FILES=30d
|
|
457
102
|
```
|
|
458
103
|
|
|
459
|
-
|
|
104
|
+
Defaults: `1h` rotation frequency, `100m` max size per file, `5d` retention. Programmatic configuration (per-transport prefixes, custom retention) is in the [Full reference](/extensions/helpers/logger/reference).
|
|
460
105
|
|
|
461
|
-
|
|
462
|
-
|--------|-----------|-------------|
|
|
463
|
-
| `HfLogger.get` | `(scope: string) => HfLogger` | Get or create a cached logger instance |
|
|
464
|
-
| `HfLogger.encodeMessage` | `(msg: string) => Uint8Array` | Pre-encode a message string to bytes (cached) |
|
|
465
|
-
| `logger.log` | `(level: THfLogLevel, messageBytes: Uint8Array) => void` | Write entry to ring buffer |
|
|
106
|
+
### Forward logs over UDP
|
|
466
107
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
#### HfLogFlusher API
|
|
470
|
-
|
|
471
|
-
| Method | Signature | Description |
|
|
472
|
-
|--------|-----------|-------------|
|
|
473
|
-
| `flusher.flush` | `() => Promise<void>` | Flush all buffered entries to output |
|
|
474
|
-
| `flusher.start` | `(intervalMs?: number) => void` | Start background flush loop (default: `100`ms) |
|
|
475
|
-
|
|
476
|
-
#### Ring Buffer Entry Format
|
|
477
|
-
|
|
478
|
-
Each entry occupies exactly 256 bytes in a 64K-entry (16MB) `SharedArrayBuffer`:
|
|
479
|
-
|
|
480
|
-
| Offset | Size | Field |
|
|
481
|
-
|--------|------|-------|
|
|
482
|
-
| 0-7 | 8 bytes | Timestamp (`BigInt64`, nanosecond precision) |
|
|
483
|
-
| 8 | 1 byte | Level (`0`=debug, `1`=info, `2`=warn, `3`=error, `4`=emerg) |
|
|
484
|
-
| 9-40 | 32 bytes | Scope (fixed-width, padded) |
|
|
485
|
-
| 41-255 | 215 bytes | Message (fixed-width, truncated if longer) |
|
|
486
|
-
|
|
487
|
-
The buffer wraps around at 65,536 entries using bitwise AND masking (`writeIndex & (BUFFER_SIZE - 1)`).
|
|
488
|
-
|
|
489
|
-
> [!WARNING]
|
|
490
|
-
> Pre-encode messages at initialization time using `HfLogger.encodeMessage()`. Calling it in the hot path defeats the zero-allocation purpose because it triggers string encoding on every log call.
|
|
491
|
-
|
|
492
|
-
### Environment Variables
|
|
493
|
-
|
|
494
|
-
#### Core Configuration
|
|
495
|
-
|
|
496
|
-
| Variable | Default | Description |
|
|
497
|
-
|----------|---------|-------------|
|
|
498
|
-
| `APP_ENV_APPLICATION_NAME` | `APP` | Label prefix shown in all log output |
|
|
499
|
-
| `DEBUG` | `false` | Enable debug-level logging |
|
|
500
|
-
| `NODE_ENV` | _(unset)_ | Must be in `COMMON_ENVS` or unset for debug to activate |
|
|
501
|
-
| `APP_ENV_EXTRA_LOG_ENVS` | _(empty)_ | Comma-separated additional environments to allow debug |
|
|
502
|
-
| `APP_ENV_LOGGER_FORMAT` | `text` | Output format (`json` or `text`) |
|
|
503
|
-
| `APP_ENV_LOGGER_FOLDER_PATH` | `./` | Log files directory |
|
|
504
|
-
| `APP_ENV_LOGGER_INSPECT_DEPTH` | `5` | Object inspection depth for `%s` placeholders. Non-negative integer only; invalid or absent falls back to `5` |
|
|
505
|
-
|
|
506
|
-
#### File Rotation
|
|
507
|
-
|
|
508
|
-
| Variable | Default | Description |
|
|
509
|
-
|----------|---------|-------------|
|
|
510
|
-
| `APP_ENV_LOGGER_FILE_FREQUENCY` | `1h` | Rotation frequency |
|
|
511
|
-
| `APP_ENV_LOGGER_FILE_MAX_SIZE` | `100m` | Max file size before rotation |
|
|
512
|
-
| `APP_ENV_LOGGER_FILE_MAX_FILES` | `5d` | Retention period |
|
|
513
|
-
| `APP_ENV_LOGGER_FILE_DATE_PATTERN` | `YYYYMMDD_HH` | Date pattern in filename |
|
|
514
|
-
|
|
515
|
-
#### UDP Transport
|
|
516
|
-
|
|
517
|
-
| Variable | Description |
|
|
518
|
-
|----------|-------------|
|
|
519
|
-
| `APP_ENV_LOGGER_DGRAM_HOST` | UDP log aggregator host |
|
|
520
|
-
| `APP_ENV_LOGGER_DGRAM_PORT` | UDP log aggregator port |
|
|
521
|
-
| `APP_ENV_LOGGER_DGRAM_LABEL` | Label to identify log source |
|
|
522
|
-
| `APP_ENV_LOGGER_DGRAM_LEVELS` | Comma-separated levels to send via UDP |
|
|
523
|
-
|
|
524
|
-
#### Example `.env`
|
|
108
|
+
Set all four `APP_ENV_LOGGER_DGRAM_*` variables - the transport is silently skipped if any one is missing.
|
|
525
109
|
|
|
526
110
|
```bash
|
|
527
|
-
# Application
|
|
528
|
-
APP_ENV_APPLICATION_NAME=my-service
|
|
529
|
-
|
|
530
|
-
# Core
|
|
531
|
-
DEBUG=true
|
|
532
|
-
APP_ENV_LOGGER_FORMAT=json
|
|
533
|
-
APP_ENV_LOGGER_FOLDER_PATH=./app_data/logs
|
|
534
|
-
APP_ENV_LOGGER_INSPECT_DEPTH=5
|
|
535
|
-
|
|
536
|
-
# File rotation
|
|
537
|
-
APP_ENV_LOGGER_FILE_FREQUENCY=24h
|
|
538
|
-
APP_ENV_LOGGER_FILE_MAX_SIZE=500m
|
|
539
|
-
APP_ENV_LOGGER_FILE_MAX_FILES=30d
|
|
540
|
-
|
|
541
|
-
# UDP transport
|
|
542
111
|
APP_ENV_LOGGER_DGRAM_HOST=127.0.0.1
|
|
543
112
|
APP_ENV_LOGGER_DGRAM_PORT=5000
|
|
544
113
|
APP_ENV_LOGGER_DGRAM_LABEL=my-app
|
|
545
114
|
APP_ENV_LOGGER_DGRAM_LEVELS=error,warn,info
|
|
546
115
|
```
|
|
547
116
|
|
|
548
|
-
##
|
|
549
|
-
|
|
550
|
-
| Export | Kind | Description |
|
|
551
|
-
|--------|------|-------------|
|
|
552
|
-
| `Logger` | class | Scoped logger with caching, wraps a Winston logger instance |
|
|
553
|
-
| `ApplicationLogger` | value + type alias | Backward-compatible alias for `Logger` |
|
|
554
|
-
| `LoggerFactory` | class | Factory that creates `Logger` from scope arrays |
|
|
555
|
-
| `HfLogger` | class | Zero-allocation ring-buffer logger |
|
|
556
|
-
| `HfLogFlusher` | class | Background flusher for `HfLogger` |
|
|
557
|
-
| `LogLevels` | class (constants) | Log level constants (`ERROR`, `ALERT`, `EMERG`, `WARN`, `INFO`, `HTTP`, `VERBOSE`, `DEBUG`, `SILLY`) with `isValid()` |
|
|
558
|
-
| `LoggerFormats` | class (constants) | Format constants (`JSON`, `TEXT`) with `isValid()` |
|
|
559
|
-
| `defineCustomLogger` | `(opts: ICustomLoggerOptions) => winston.Logger` | Create a fully configured Winston logger |
|
|
560
|
-
| `defineLogFormatter` | `(opts: { label: string; format?: TLoggerFormat }) => winston.Logform.Format` | Create a formatter (auto-detects format from env) |
|
|
561
|
-
| `defineJsonLoggerFormatter` | `(opts: { label: string }) => winston.Logform.Format` | Create a JSON formatter |
|
|
562
|
-
| `definePrettyLoggerFormatter` | `(opts: { label: string }) => winston.Logform.Format` | Create a pretty text formatter |
|
|
563
|
-
| `applicationLogFormatter` | `winston.Logform.Format` | Pre-built formatter using `APP_ENV_APPLICATION_NAME` label |
|
|
564
|
-
| `applicationLogger` | `winston.Logger` | Pre-built default Winston logger instance |
|
|
565
|
-
| `DgramTransport` | class | Custom Winston transport for UDP logging |
|
|
566
|
-
| `TLogLevel` | type | Union of all log level string literals |
|
|
567
|
-
| `TLoggerFormat` | type | Union of `'json' \| 'text'` |
|
|
568
|
-
| `IFileTransportOptions` | interface | Options for daily-rotating file transport |
|
|
569
|
-
| `ICustomLoggerOptions` | interface | Options for `defineCustomLogger` |
|
|
570
|
-
| `IDgramTransportOptions` | interface | Options for `DgramTransport` |
|
|
571
|
-
|
|
572
|
-
## Troubleshooting
|
|
573
|
-
|
|
574
|
-
### Debug logs not appearing
|
|
575
|
-
|
|
576
|
-
**Cause:** Debug logging requires both `DEBUG=true` AND a `NODE_ENV` that is either unset or present in the `COMMON_ENVS` set. These values are pre-computed at module load time.
|
|
577
|
-
|
|
578
|
-
**Fix:**
|
|
579
|
-
1. Verify `DEBUG=true` is set in your environment.
|
|
580
|
-
2. Verify `NODE_ENV` is set to one of: `local`, `debug`, `development`, `dev`, `sit`, `uat`, `alpha`, `beta`, `staging`, `production` -- or is unset entirely.
|
|
581
|
-
3. If you use a custom environment name (e.g. `qa`), add it to `APP_ENV_EXTRA_LOG_ENVS=qa`.
|
|
582
|
-
|
|
583
|
-
```bash
|
|
584
|
-
DEBUG=true NODE_ENV=development bun run server:dev
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
### "[defineLogger] Invalid logger format | format: {format} | valids: json,text"
|
|
588
|
-
|
|
589
|
-
**Cause:** The `format` option passed to `defineLogFormatter` (or the `APP_ENV_LOGGER_FORMAT` environment variable) is not `json` or `text`.
|
|
590
|
-
|
|
591
|
-
**Fix:** Set `APP_ENV_LOGGER_FORMAT` to either `json` or `text`:
|
|
592
|
-
|
|
593
|
-
```bash
|
|
594
|
-
APP_ENV_LOGGER_FORMAT=text
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
### UDP transport not sending logs
|
|
598
|
-
|
|
599
|
-
**Cause:** `DgramTransport.fromPartial()` returns `null` if any required option is missing (`label`, `host`, `port`, `levels` with at least one entry, or `socketOptions`). The transport is silently not registered.
|
|
600
|
-
|
|
601
|
-
**Fix:**
|
|
602
|
-
1. Ensure **all four** dgram env vars are set: `APP_ENV_LOGGER_DGRAM_HOST`, `APP_ENV_LOGGER_DGRAM_PORT`, `APP_ENV_LOGGER_DGRAM_LABEL`, and `APP_ENV_LOGGER_DGRAM_LEVELS`.
|
|
603
|
-
2. `APP_ENV_LOGGER_DGRAM_LEVELS` must contain at least one level (e.g. `error,warn,info`). An empty value results in no transport.
|
|
604
|
-
3. Verify the UDP aggregator is reachable from your host (firewall, port binding).
|
|
605
|
-
|
|
606
|
-
### Log label shows "APP" instead of application name
|
|
607
|
-
|
|
608
|
-
**Cause:** The default label comes from `Defaults.APPLICATION_NAME`, which reads `APP_ENV_APPLICATION_NAME`. If the env var is not set, it falls back to `'APP'`.
|
|
609
|
-
|
|
610
|
-
**Fix:** Set `APP_ENV_APPLICATION_NAME` in your environment:
|
|
611
|
-
|
|
612
|
-
```bash
|
|
613
|
-
APP_ENV_APPLICATION_NAME=my-service
|
|
614
|
-
```
|
|
615
|
-
|
|
616
|
-
## See Also
|
|
617
|
-
|
|
618
|
-
- **Related Concepts:**
|
|
619
|
-
- [Services](/guides/core-concepts/services) -- Logging in services
|
|
620
|
-
- [Controllers](/guides/core-concepts/rest-controllers) -- Logging in controllers
|
|
117
|
+
## See also
|
|
621
118
|
|
|
622
|
-
-
|
|
623
|
-
|
|
119
|
+
- [Full reference](/extensions/helpers/logger/reference) - every export, transport option, log level, and edge case
|
|
120
|
+
- [Services](/guides/core-concepts/services) - logging in services
|
|
121
|
+
- [Controllers](/guides/core-concepts/rest-controllers) - logging in controllers
|
|
122
|
+
- [Helpers Overview](/extensions/helpers/) - all available helpers
|
|
123
|
+
- [Request Tracker Component](/extensions/components/request-tracker) - request logging
|
|
124
|
+
- [Winston documentation](https://github.com/winstonjs/winston) - underlying logging library
|
|
624
125
|
|
|
625
|
-
|
|
626
|
-
- [Request Tracker Component](/extensions/components/request-tracker) -- Request logging
|
|
126
|
+
**Files:**
|
|
627
127
|
|
|
628
|
-
-
|
|
629
|
-
|
|
630
|
-
|
|
128
|
+
- [`packages/helpers/src/modules/logger/common/types.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/helpers/src/modules/logger/common/types.ts) - `ILogger`, the contract every consumer types against
|
|
129
|
+
- [`packages/helpers/src/modules/logger/winston/logger.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/helpers/src/modules/logger/winston/logger.ts) - `WinstonLogger`, `Logger` alias
|
|
130
|
+
- [`packages/helpers/src/modules/logger/factory.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/helpers/src/modules/logger/factory.ts) - `LoggerFactory`, `ApplicationLogger`
|
|
131
|
+
- [`packages/helpers/src/modules/logger/winston/define.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/helpers/src/modules/logger/winston/define.ts) - Winston setup, transports, env configuration
|