nest-logger-bundle 0.1.6 → 1.0.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 CHANGED
@@ -10,22 +10,17 @@
10
10
  <img alt="Snyk Vulnerabilities for npm package" src="https://img.shields.io/snyk/vulnerabilities/npm/nest-logger-bundle" />
11
11
  </a>
12
12
  <img alt="Libraries.io" src="https://img.shields.io/librariesio/release/npm/nest-logger-bundle">
13
+ <img alt="Supported Language: Typescript" src="https://img.shields.io/npm/types/typescript" />
13
14
  <img alt="Supported platforms: Express & Fastify" src="https://img.shields.io/badge/platforms-Express%20%26%20Fastify-green" />
14
15
  </p>
15
16
 
16
17
  ## Description
17
18
 
18
- This library made to be used with <a href="http://nodejs.org" target="blank">Nest.js</a> it offers more flexibility for controlling logs in the application. The strongest point is that it offers a way to pack all the logs originating from an request or some asynchronous flow into a single bundle, also later it provides ways to transport the bundles to some cloud observability service.
19
+ This library made to be used with <a href="http://nodejs.org" target="blank">Nest.js</a> it offers more flexibility for controlling logs in the application. The strongest point is that it offers a way to pack all the logs originating from an request or some asynchronous flow into a single bundle, you can also decide what to do with this bundle as well as regular logs.
19
20
 
20
- For example, in a request several logs can occur and organizing this later or finding yourself in the middle of so many logs becomes a complicated task, with the LoggerBundle all the logs that occur in that request will be packed in a bundle and this bundle shows exactly the order that these logs were displayed in a tree, you can even create branches of these logs using the `enter()/ exit()` methods as will be explained later. This bundle will include a lot of useful information, such as the request that originated these logs and in the log tree you will be able to see a time profiling telling you how long it took in each branch tree.
21
+ For example, in a request several logs can occur and organizing this later or finding yourself in the middle of so many logs becomes a complicated task, with the `LoggerBundle` all the logs that occur in that request will be packed in a bundle and this bundle shows exactly the order that these logs were occurred using a tree, you can even create branches of these logs using the `enter()/ exit()` methods as will be explained later. This bundle will include a lot of useful information, such as the request that originated these logs and in the log tree you will be able to see a time profiling telling you how long it took in each branch tree.
21
22
 
22
- Don't worry if some function of a service calls other functions of other services that contain another injected LoggerBundle, because it can find itself within the current context of the request, so no matter how many different services interact, the output will be in the same bundle.
23
-
24
- ________________
25
-
26
- ## Internal Dependencies
27
-
28
- You don't need to install any extra dependencies. Internally this library is also made using some bases that are made on top of the <a href="https://github.com/pinojs/pino" target="blank">pino</a>, but I have plans to expose this dependencies in the future and leave the user free to choose which one to use.
23
+ Inside it works based on a context, be it a request or an asynchronous flow, so you can inject the `LoggerBundle` into any desired service and all calls between these services work correctly, so all logs occurring in a given request will be packed in the same bundle.
29
24
 
30
25
  ________________
31
26
 
@@ -35,13 +30,20 @@ ________________
35
30
  $ npm i --save nest-logger-bundle
36
31
  ```
37
32
 
38
- ## Samples
39
33
 
40
34
  ________________
41
35
 
36
+ ## Internal Dependencies
37
+
38
+ You don't need to install any extra dependencies. Internally this library is also made using some bases that are made on top of the <a href="https://github.com/pinojs/pino" target="blank">pino</a>. If you need to use some transporter you will need to configure the streams, for that, follow this [section](#streams)
39
+
40
+ ________________
41
+
42
+ ## Samples
43
+
42
44
  If you want to see some usage examples use this repo <a href="https://github.com/pedrohcdo/nest-logger-bundle-samples" target="blank">NestLoggerBundleSamples</a>, In it you will find some projects with some use cases, the codes are commented for a better understanding.
43
45
 
44
- > If you want to see an simple example of how to configure it, see the test project [Example](test).
46
+ > But if you want to see an simple example of how to configure it, see the test project [Example](test).
45
47
 
46
48
  ________________
47
49
 
@@ -87,7 +89,7 @@ export class GlobalModule {}
87
89
  For the LoggerBundle to work correctly, it needs some points to be handled, for that there are two classes that are used to handle requests and errors, they are: `LoggerExceptionFilter` and `LoggerHttpInterceptor`.
88
90
  These classes need to be used in the global-scoped filters and interceptors like the example to be work across the whole application. `Remember to provide this filter and interceptor as in the example above in a global module or in the main module of your application.`
89
91
 
90
- > If you already have a global scope filter or interceptor, follow the [tutorial](#custom-filter-and-interceptor)
92
+ > If you already have a global scope filter or interceptor on your project, follow the [tutorial](#custom-filter-and-interceptor)
91
93
 
92
94
  ### Injecting LoggerBundle
93
95
 
@@ -143,12 +145,17 @@ export class SampleUserService {
143
145
 
144
146
  > Remembering that the name of the current service can be acquired by `<Class>.name`, so you can change the name of the context of the LoggerBundle right at the beginning using as shown in the example above: `this.logService.setContextToken(SampleService.name)`
145
147
 
146
- If the `SampleUserService.createUser(email, username)` function is called, the log structure that will be generated will be like the example below:
148
+ ________________
149
+
150
+ ## Bundle Structure
151
+
152
+
153
+ The bundle is generated at the end of a flow such as a request, after that the generated bundle is dispatched according to the parameters passed in the module configuration (`the complete configuration can be seen here `[Setting-up](#setting-up)). Para demonstrar como é a estrutura do bundle vamos usar o exemplo acima [Injecting LoggerBundle](#injecting-loggerbundle), if the `SampleUserService.createUser(email, username)` function is called, the bundle structure that will be generated will be like the example below:
147
154
 
148
155
  ```json
149
156
  {
150
157
  logs: {
151
- "profiling": "6ms",
158
+ "profiling": <duration>,
152
159
  "name": "root",
153
160
  "logs": [
154
161
  {
@@ -157,7 +164,7 @@ If the `SampleUserService.createUser(email, username)` function is called, the l
157
164
  "context": "SampleService"
158
165
  },
159
166
  {
160
- "profiling": "0ms",
167
+ "profiling": <duration>,
161
168
  "name": "creating user",
162
169
  "logs": [
163
170
  {
@@ -166,7 +173,7 @@ If the `SampleUserService.createUser(email, username)` function is called, the l
166
173
  "context": "SampleService"
167
174
  },
168
175
  {
169
- "profiling": "0ms",
176
+ "profiling": <duration>,
170
177
  "name": "finding user by email ",
171
178
  "logs": [
172
179
  {
@@ -189,27 +196,27 @@ If the `SampleUserService.createUser(email, username)` function is called, the l
189
196
  "requestDuration": <duration>,
190
197
  "method": "GET",
191
198
  "path": "/sample/create-user/teste%40teste.com/Teste%20123",
192
- "ip": <ip>
193
- },
194
- tags: {
195
- "test": "test 123"
199
+ "ip": <ip>,
200
+ tags: {
201
+ "test": "test 123"
202
+ },
196
203
  },
197
204
  req: <request object>,
198
205
  res: <response object>
199
206
  }
200
207
  ```
201
208
 
202
- The log will display 5 objects, they are:
209
+ The bundle will contain these 5 objects
203
210
 
204
211
  | Object | Description
205
212
  | :--- | :----:
206
- | `logs` | A bundle containing the entire log tree including a time profiling between each log.
207
- | `context` | The context in which this log bundle was created, containing information such as api path, method..
208
- | `tags` | The tags created in this context
209
- | `req` | The body of the request that originated this bundle
210
- | `res` | If it is a complete request context here you will be able to see the response of that request
213
+ | ***logs*** | A object containing the entire `logs` tree including a time profiling between each log.
214
+ | ***context*** | The `context` in which this log bundle was created, containing information such as api path, method..
215
+ | ***context.tags*** | The `tags` created in this context
216
+ | ***req*** | The body of the `request` that originated this bundle
217
+ | ***res*** | If it is a complete request context here you will be able to see the `response` of that request
211
218
 
212
- The generated bundle follows the following structure, where the `logs` array can contain more log nodes like the example
219
+ The generated logs tree follows the following structure, where the `logs` array can contain more log nodes like the example
213
220
 
214
221
  ```ts
215
222
  {
@@ -258,10 +265,10 @@ There are some methods available for use in NestLoggerService, here is a list of
258
265
  fatal(...args)
259
266
  ```
260
267
 
261
- Where all log levels follow the same argument model, there are thre call combinations, here is an example with `log()` level
268
+ Where all log levels follow the same argument model, there are three call combinations, here is an example with `log()` level
262
269
 
263
270
  ```ts
264
- // The first way is sending a text that can contain special characters for formatting and then the arguments referring to the formatting.
271
+ // The first way is sending a text that can contain special characters of printf-like format for formatting (see https://github.com/pinojs/quick-format-unescaped), then the next arguments are the values ​​referring to the provided formatting..
265
272
  this.logService.log("message to format %d %d", 10, 20)
266
273
 
267
274
  // The second form precedes an object that will be merged together with the formatted message
@@ -277,9 +284,9 @@ There are some methods available for use in NestLoggerService, here is a list of
277
284
 
278
285
  | Method | Description
279
286
  | :--- | :----:
280
- | `enter(`branchName`)` | This method creates a node in the log tree where the '`branchName`' is an string that will be the name of the subtree of logs
281
- | `exit()` | This method closes the current subtree, remembering that the same amount opened with `enter()` must be closed with `exit()`
282
- | `putTag(`tagName, tagValue`)` | Where the '`tagName`' and '`tagValue`' are strings. This method adds a tag in the current context, the tags have no direct relation with the `enter()` and `exit()` methods, so regardless of the current state of the tree, the tags will be added separately in the bundle.
287
+ | ***enter(`branchName`)*** | This method creates a node in the log tree where the '`branchName`' is an string that will be the name of the subtree of logs
288
+ | ***exit()*** | This method closes the current subtree, remembering that the same amount opened with `enter()` must be closed with `exit()`
289
+ | ***putTag(`tagName, tagValue`)*** | Where the '`tagName`' and '`tagValue`' are strings. This method adds a tag in the current context, the tags have no direct relation with the `enter()` and `exit()` methods, so regardless of the current state of the tree, the tags will be added separately in the bundle.
283
290
 
284
291
  - Async Methods
285
292
 
@@ -287,7 +294,7 @@ There are some methods available for use in NestLoggerService, here is a list of
287
294
 
288
295
  | Method | Description
289
296
  | :--- | :----:
290
- | `createAsyncLogger()` | Creates an asynchronous LoggerBundle, where the responsibility for transporting the bundle is on your side
297
+ | ***createAsyncLogger()*** | Creates an asynchronous LoggerBundle, where the responsibility for transporting the bundle is on your side
291
298
 
292
299
  ______
293
300
 
@@ -319,18 +326,22 @@ ______
319
326
  })
320
327
  ```
321
328
 
322
- You must provide the desired parameters for the LoggerBundle, the parameters follow the following schema
329
+ You must provide the desired parameters for the LoggerBundleModule, the parameters follow the following schema
323
330
 
324
331
  ```ts
325
332
  // default config
326
333
  {
327
- pinoStream: {
334
+ loggers: {
328
335
  type: 'default',
329
336
  prettyPrint: {
337
+ mode: NestLoggerParamsLogggerMode, // DEFAULT IS LOG_BUNDLE
330
338
  disabled: boolean,
331
339
  options: pino.PrettyOptions,
332
340
  },
333
- streams: pinoms.Streams,
341
+ streams: {
342
+ mode: NestLoggerParamsLogggerMode, // DEFAULT IS LOG_BUNDLE
343
+ pinoStreams: pinoms.Streams
344
+ },
334
345
  timestamp: {
335
346
  format: {
336
347
  template: string,
@@ -342,9 +353,7 @@ You must provide the desired parameters for the LoggerBundle, the parameters fol
342
353
  // You can change this
343
354
  contextBundle: {
344
355
  strategy: {
345
- onDispatch: NestLoggerDispatchStrategy,
346
- level: NestLoggerLevelStrategy,
347
- onError: NestLoggerOnErrorStrategy,
356
+ level: NestLoggerLevelStrategy
348
357
  },
349
358
  }
350
359
  }
@@ -352,17 +361,18 @@ You must provide the desired parameters for the LoggerBundle, the parameters fol
352
361
  ```ts
353
362
  // custom config
354
363
  {
355
- pinoStream: {
364
+ loggers: {
356
365
  type: 'custom',
357
- logger: pino.Logger
366
+ logger: pino.Logger,
367
+ level?: string,
368
+ bundleLogger: pino.Logger
369
+ lineLogger?: pino.Logger
358
370
  },
359
371
 
360
372
  // You can change this
361
373
  contextBundle: {
362
374
  strategy: {
363
- onDispatch: NestLoggerDispatchStrategy,
364
- level: NestLoggerLevelStrategy,
365
- onError: NestLoggerOnErrorStrategy,
375
+ level: NestLoggerLevelStrategy
366
376
  },
367
377
  }
368
378
  }
@@ -374,77 +384,118 @@ Below is the description of each parameter
374
384
 
375
385
  | Param | Description
376
386
  | :--- | :----:
377
- | `pinoStream`: NestLoggerParamsPinoStream \| NestLoggerParamsCustomPino | The NestLoggerBundle uses the `pino-multi-stream ` to transport the logs to several different destinations at the same time, for that it is necessary to use the `type: 'default'` so some parameters of `NestLoggerParamsPinoStream` will be provided, but if you choose to use a `type: 'custom'` some parameters of `NestLoggerParamsCustomPino` will be provided and you can use a pin logger configured in your own way.
378
- | `contextBundle`: NestLoggerParamsContextBundle | Here you can configure some behaviors related to how the bundle is created, for example, configure what the bundle's marjoritary level will be..
387
+ | ***loggers***?: NestLoggerParamsPinoStream \| NestLoggerParamsCustomPino | The NestLoggerBundle uses the `pino-multi-stream ` to transport the logs to several different destinations at the same time, if you want to use the default implementation that makes managing these logs very easy use type `'default'` so some parameters of `NestLoggersParamsStream` will be provided, but if you choose to use a type `'custom'` some parameters of `NestLoggersParamsCustom` will be provided and you can use a `pino` logger configured in your own way.
388
+ | ***contextBundle***?: NestLoggerParamsContextBundle | Here you can configure some behaviors related to how the bundle is created, for example, configure what the bundle's marjoritary level will be..
389
+ | ***forRoutes***?: (string \| Type<any> \| RouteInfo)[] | Pattern based routes are supported as well. For instance, the asterisk is used as a wildcard, and will match any combination of characters, for more datails see [NestJS-Middlewares](https://docs.nestjs.com/middleware), the default is `[{ path: '*', method: RequestMethod.ALL }]`
379
390
 
380
- - **NestLoggerParamsPinoStream**<br/>
391
+ - **NestLoggersParamsStream**<br/>
381
392
  If you choose to use the default configuration in `NestLoggerParams`, using '`{ type: 'default', ... }`' the options for these parameters will be provided
382
393
  > It is worth remembering that it is recommended to use this configuration if you do not have the need to create your own configuration.
383
394
 
384
395
  | Param | Description
385
396
  | :--- | :----:
386
- | `type: 'default'` | For the options to follow this pattern you must set the type to `'default'`
387
- | `prettyPrint`: NestLoggerParamsPrettyStream | Here you can configure `prettyStream`, choosing to disable it if necessary and also provide your `pin.PrettyOptions`
388
- | `streams`: pinoms.Streams | You can also tell which streams you want pinoms handles, you can find implementations of various transporters that can be used here https://github.com/pinojs/pino/blob/master/docs/transports.md#legacy
389
- | `timestamp`: NestLoggerParamsPinoTimestamp | You can also configure how the timestamp will be formatted in the logs informing a template and a timezone, the template is created with the help of `dayjs` to assemble the desired string you can use the symbols informed here https://day.js.org/docs/en/display/format
397
+ | ***type***: `'default'` | For the options to follow this pattern you must set the type to `'default'`
398
+ | ***prettyPrint***?: NestLoggersParamsPretty | Here you can configure `prettyStream`, choosing to disable it if necessary and also provide your `pin.PrettyOptions`
399
+ | ***streams***?: NestLoggersParamsStreams | Here you can configure `streams`, choosing to disable it if necessary and also provide your own transporter
400
+ | ***timestamp***?: NestLoggerParamsPinoTimestamp | You can also configure how the timestamp will be formatted in the logs informing a template and a timezone, the template is created with the help of `dayjs` to assemble the desired string you can use the symbols informed here [Day.js](https://day.js.org/docs/en/display/format)
390
401
 
391
- - **NestLoggerParamsPrettyStream**<br/>
402
+ ### Related Params
403
+
404
+ - **NestLoggersParamsPretty**<br/>
392
405
 
393
406
  | Param | Description
394
407
  | :--- | :----:
395
- | `disabled`: boolean | If you want to disable the `prettyStream` you can pass `false` in this option `(remembering that, as it will be disabled the 'options' will not have any effects)`
396
- | `options`: pino.PrettyOptions | Here you can pass some options provided by `pin`, like `{colorize: true}`
408
+ | ***mode***?: NestLoggerParamsLogggerMode | Here you can choose the mode that `prettyStream` will display the logs, the default value is `NestLoggerParamsLogggerMode.LOG_BUNDLE`, so the bundle will be logged.
409
+ | ***disabled***?: boolean | If you want to disable the `prettyStream` you can pass `false` in this option `(remembering that, as it will be disabled the 'options' will not have any effects)`
410
+ | ***options***?: pino.PrettyOptions | Here you can pass some options provided by `pin`, like `{colorize: true}`
397
411
 
398
- - **pinoms.Streams**<br/>
412
+ - **NestLoggersParamsStreams**<br/>
413
+
414
+ | Param | Description
415
+ | :--- | :----:
416
+ | ***mode***?: NestLoggerParamsLogggerMode | Here you can choose the mode that `streams` will display the logs, the default value is `NestLoggerParamsLogggerMode.LOG_BUNDLE`, so the bundle will be logged.
417
+ | ***pinoStreams***?: pinoms.Streams | You can also tell which `streams` you want pinoms handles, you can find implementations of various transporters that can be used here https://github.com/pinojs/pino/blob/master/docs/transports.md#legacy
399
418
 
400
- Here is an example of how to use a transport `(In this example, datadog is used)`
401
- > To find more transporters, have a look at the pino repository in this section [Legacy](https://github.com/pinojs/pino/blob/master/docs/transports.md#legacy)
402
-
403
- ```ts
404
- import datadog from 'pino-datadog';
405
-
406
- // ...
407
- NestLoggerModule.forRootAsync({
408
- useFactory: async (config: ConfigService): Promise<NestLoggerParams> => {
409
- const datadogStream = await datadog.createWriteStream({
410
- apiKey: config.get('datadog.apiKey'),
411
- service: config.get('datadog.serviceName'),
412
- });
413
-
414
- return {
415
- // ...
416
- pinoStream: {
417
- type: 'default',
418
- streams: [
419
- {
420
- stream: datadogStream,
421
- },
422
- ],
423
- },
424
- };
425
- },
426
- inject: [ConfigService],
427
- }),
419
+ - **NestLoggerParamsLogggerMode**<br/>
428
420
 
429
- ```
421
+ There are two types of modes used in the `prettyPrint` and `streams` settings, they are:
422
+
423
+ | Enum | Description
424
+ | :--- | :----:
425
+ | ***NestLoggerParamsLogggerMode.LOG_BUNDLE*** | Indicates that the log will be sent to the destination as a bundle `(this is the default behavior of all destinations)`
426
+ | ***NestLoggerParamsLogggerMode.LOG_LINE*** | Indicates that the log will be sent to the destination as log lines
427
+
428
+ - **pinoms.Streams**<br/>
429
+
430
+ Here you can set some streams to transport your logs, check these examples of how to use [Streams](#streams)
430
431
 
431
432
  - **NestLoggerParamsPinoTimestamp**<br/>
432
433
 
433
434
  | Param | Description
434
435
  | :--- | :----:
435
- | `template`: string | To format the timezone your way, use a string that follows the pattern informed here [dayjs-formar](https://day.js.org/docs/en/display/format), eg: `'DD/MM/YYYY - HH:mm:ss.SSS'`
436
- | `timezone`: string | Inform the timezone, you can find the valid timezones here [IANA database](https://www.iana.org/time-zones)
436
+ | ***template***: string | To format the timezone your way, use a string that follows the pattern informed here [dayjs-formar](https://day.js.org/docs/en/display/format), eg: `'DD/MM/YYYY - HH:mm:ss.SSS'`
437
+ | ***timezone***: string | Inform the timezone, you can find the valid timezones here [IANA database](https://www.iana.org/time-zones)
437
438
 
438
439
 
439
440
 
440
- - **NestLoggerParamsCustomPino**<br/>
441
+ - **NestLoggersParamsCustom**<br/>
441
442
  But if you choose to use the default configuration in `NestLoggerParamsCustomPino`, using '`{ type: 'custom', ... }`' the options for these parameters will be provided
442
443
 
443
444
  | Param | Description
444
445
  | :--- | :----:
445
- | `type: 'custom'` | For the options to follow this pattern you must set the type to `'custom'`
446
- | `logger`: pino.Logger | You can pass a logger that was configured your way
446
+ | ***type***: `'custom'` | For the options to follow this pattern you must set the type to `'custom'`
447
+ | ***bundleLogger***: pino.Logger | This logger will be used to log bundles only
448
+ | ***lineLogger***?: pino.Logger | This logger will be used to log only line logs (which are common logs)
449
+
450
+ - **NestLoggerParamsContextBundle**<br/>
451
+ Here you can configure bundle-related behaviors, such as the `strategy` used to dispatch the bundle to the loggers
452
+
453
+ | Param | Description
454
+ | :--- | :----:
455
+ | ***strategy***?: NestLoggerParamsContextBundleStrategy | Strategy used to dispatch the bundle to the loggers
456
+
457
+ ### Related Params
458
+
459
+ - **NestLoggerParamsContextBundleStrategy**<br/>
460
+ Below are the settings available for these strategies
461
+
462
+ | Param | Description
463
+ | :--- | :----:
464
+ | ***level***?: NestLoggerLevelStrategy | This strategy defines what will be the main level of the bundle, as the bundle will contain a tree of logs, it can contain several logs with several levels, so to define the main level, the configuration provided here is used to decide the best level, the default strategy is `NestLoggerLevelStrategy.MAJOR_LEVEL`
447
465
 
466
+ ### Streams
467
+
468
+ Probably at some point you may need to transport your logs, for example to some
469
+ observability service in the cloud, here is an example of how to configure this using the `streams` parameter to send the logs to Datadog service `(In this example, datadog transporter is used)`
470
+ > To find more transporters and how to install their dependencies, have a look at the pino repository in this section [Legacy](https://github.com/pinojs/pino/blob/master/docs/transports.md#legacy)
471
+
472
+ ```ts
473
+ import datadog from 'pino-datadog';
474
+
475
+ // ...
476
+ NestLoggerModule.forRootAsync({
477
+ useFactory: async (config: ConfigService): Promise<NestLoggerParams> => {
478
+ const datadogStream = await datadog.createWriteStream({
479
+ apiKey: config.get('datadog.apiKey'),
480
+ service: config.get('datadog.serviceName'),
481
+ });
482
+
483
+ return {
484
+ // ...
485
+ pinoStream: {
486
+ type: 'default',
487
+ streams: [
488
+ {
489
+ stream: datadogStream,
490
+ },
491
+ ],
492
+ },
493
+ };
494
+ },
495
+ inject: [ConfigService],
496
+ }),
497
+
498
+ ```
448
499
 
449
500
  ### Custom Filter and Interceptor
450
501
 
@@ -553,8 +604,8 @@ export class SampleUserService {
553
604
 
554
605
  ## Stay in touch
555
606
 
556
- - Author - [Pedro Henrique C.](https://github.com/pedrohcdo)
607
+ - Author - [Pedro Henrique C.](https://twitter.com/pedrohcdo)
557
608
 
558
609
  ## License
559
610
 
560
- NestLoggerBundle is [MIT licensed](LICENSE).
611
+ NestLoggerBundle is [Apache License 2.0](LICENSE).
@@ -13,7 +13,7 @@ export declare class NestAsyncLoggerContext {
13
13
  loggerBundle: any;
14
14
  };
15
15
  dispatchCurrentLoggerBundle(message: string): void;
16
- dispatchCurrentLoggerBundle(innerObject: unknown, message?: string): void;
16
+ dispatchCurrentLoggerBundle(exception: unknown, message?: string): void;
17
17
  hasContext(): boolean;
18
18
  createDetachedContext(): Promise<NestAsyncLoggerContext>;
19
19
  }
@@ -43,21 +43,18 @@ let NestAsyncLoggerContext = NestAsyncLoggerContext_1 = class NestAsyncLoggerCon
43
43
  loggerBundle: fromStore.loggerContext,
44
44
  };
45
45
  }
46
- dispatchCurrentLoggerBundle(innerObject, message) {
47
- var _a, _b, _c;
46
+ dispatchCurrentLoggerBundle(exceptionOrMessage, message) {
48
47
  if (!this.hasContext()) {
49
48
  return;
50
49
  }
51
50
  const { logger, loggerBundle } = this.getCurrent();
52
- if (((_c = (_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.contextBundle) === null || _b === void 0 ? void 0 : _b.strategy) === null || _c === void 0 ? void 0 : _c.onDispatch) === nest_logger_params_1.NestLoggerDispatchStrategy.DISPATCH) {
53
- const { object, level } = loggerBundle.build();
54
- const childLogger = logger.child(object);
55
- if (message)
56
- childLogger[level](innerObject, message);
57
- else
58
- childLogger[level](innerObject);
59
- childLogger.flush();
60
- }
51
+ const { object, level } = loggerBundle.build();
52
+ const childLogger = logger.child(object);
53
+ if (message)
54
+ childLogger[level](exceptionOrMessage, message);
55
+ else
56
+ childLogger[level](exceptionOrMessage);
57
+ childLogger.flush();
61
58
  loggerBundle.expireNow();
62
59
  }
63
60
  hasContext() {
@@ -1 +1 @@
1
- {"version":3,"file":"async-logger-context.service.js","sourceRoot":"","sources":["../../../../lib/src/bundle/context/async-logger-context.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAAyC;AACzC,gDAAwB;AACxB,uFAA2E;AAC3E,iEAKkC;AAClC,oEAA4D;AAC5D,2DAAwD;AAMxD,IAAa,sBAAsB,8BAAnC,MAAa,sBAAsB;IAQlC,YACuC,MAAwB,EAChB,YAAyB,EAC/D,SAAoB;QAFU,WAAM,GAAN,MAAM,CAAkB;QAChB,iBAAY,GAAZ,YAAY,CAAa;QAC/D,cAAS,GAAT,SAAS,CAAW;IAC1B,CAAC;IAEJ,UA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C;QACpE,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,wCAAgB,CAAC,CAAC;QAE3E,IAAI,OAIH,CAAC;QAEF,IAAI,IAAI,CAAC,eAAe,EAAE;YACzB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;SAC/B;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE;YAC7B,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;SAC5B;aAAM;YACN,OAAO,GAAG;gBACT,MAAM,EAAE,IAAI,CAAC,YAAY;gBACzB,YAAY,EAAE,IAAI;gBAClB,KAAK,EAAE,WAAW;aAClB,CAAC;SACF;QAED,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAEhD,IAAI,YAAY;YAAE,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAE9D,OAAO,CAAC,eAAe,GAAG;YACzB,MAAM;YACN,YAAY,EAAE,oBAAoB;YAClC,KAAK;SACL,CAAC;QAEF,OAAO,OAAO,CAAC;IAChB,CAAC;CACD,CAAA;AAhGY,sBAAsB;IADlC,IAAA,mBAAU,EAAC,EAAE,CAAC;IAUZ,WAAA,IAAA,eAAM,EAAC,oDAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,eAAM,EAAC,iDAA4B,CAAC,CAAA;qDAClB,gBAAS;GAXjB,sBAAsB,CAgGlC;AAhGY,wDAAsB"}
1
+ {"version":3,"file":"async-logger-context.service.js","sourceRoot":"","sources":["../../../../lib/src/bundle/context/async-logger-context.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAAyC;AACzC,gDAAwB;AACxB,uFAA2E;AAC3E,iEAGkC;AAClC,oEAA4D;AAC5D,2DAAwD;AAMxD,IAAa,sBAAsB,8BAAnC,MAAa,sBAAsB;IAQlC,YACuC,MAAwB,EAChB,YAAyB,EAC/D,SAAoB;Q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,oBAAoB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,wCAAgB,CAAC,CAAC;QAE3E,IAAI,OAIH,CAAC;QAEF,IAAI,IAAI,CAAC,eAAe,EAAE;YACzB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;SAC/B;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE;YAC7B,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;SAC5B;aAAM;YACN,OAAO,GAAG;gBACT,MAAM,EAAE,IAAI,CAAC,YAAY;gBACzB,YAAY,EAAE,IAAI;gBAClB,KAAK,EAAE,WAAW;aAClB,CAAC;SACF;QAED,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAEhD,IAAI,YAAY;YAAE,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAE9D,OAAO,CAAC,eAAe,GAAG;YACzB,MAAM;YACN,YAAY,EAAE,oBAAoB;YAClC,KAAK;SACL,CAAC;QAEF,OAAO,OAAO,CAAC;IAChB,CAAC;CACD,CAAA;AA/FY,sBAAsB;IADlC,IAAA,mBAAU,EAAC,EAAE,CAAC;IAUZ,WAAA,IAAA,eAAM,EAAC,oDAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,eAAM,EAAC,iDAA4B,CAAC,CAAA;qDAClB,gBAAS;GAXjB,sBAAsB,CA+FlC;AA/FY,wDAAsB"}
@@ -18,7 +18,7 @@ exports.LineLoggerProvider = {
18
18
  useFactory: async (params) => {
19
19
  var _a;
20
20
  if (((_a = params === null || params === void 0 ? void 0 : params.loggers) === null || _a === void 0 ? void 0 : _a.type) === "custom")
21
- return params.loggers.prettyLogger || (0, pino_1.default)({ enabled: false });
21
+ return params.loggers.lineLogger || (0, pino_1.default)({ enabled: false });
22
22
  return (0, utils_1.resolveLoggerFor)(params, nest_logger_params_1.NestLoggerParamsLogggerMode.LOG_LINE);
23
23
  },
24
24
  inject: [nest_logger_module_definition_1.MODULE_OPTIONS_TOKEN],
@@ -1 +1 @@
1
- {"version":3,"file":"pretty-logger.provider.js","sourceRoot":"","sources":["../../../../lib/src/core/providers/pretty-logger.provider.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAExB,uFAA2E;AAC3E,iEAAqH;AAErH,kDAAyB;AACzB,2DAAkC;AAClC,qEAA4C;AAC5C,mCAA2C;AAE3C,eAAK,CAAC,MAAM,CAAC,aAAG,CAAC,CAAA;AACjB,eAAK,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAA;AAET,QAAA,kBAAkB,GAAa;IAC3C,OAAO,EAAE,+CAA0B;IAEnC,UAAU,EAAE,KAAK,EAAE,MAAwB,EAAE,EAAE;;QAC9C,IAAG,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,0CAAE,IAAI,MAAK,QAAQ;YACpC,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,IAAI,IAAA,cAAI,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;QAI/D,OAAO,IAAA,wBAAgB,EAAC,MAAM,EAAE,gDAA2B,CAAC,QAAQ,CAAC,CAAA;IACtE,CAAC;IAED,MAAM,EAAE,CAAC,oDAAoB,CAAC;CAC9B,CAAC"}
1
+ {"version":3,"file":"pretty-logger.provider.js","sourceRoot":"","sources":["../../../../lib/src/core/providers/pretty-logger.provider.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AACxB,uFAA2E;AAC3E,iEAAqH;AACrH,kDAAyB;AACzB,2DAAkC;AAClC,qEAA4C;AAC5C,mCAA2C;AAE3C,eAAK,CAAC,MAAM,CAAC,aAAG,CAAC,CAAA;AACjB,eAAK,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAA;AAET,QAAA,kBAAkB,GAAa;IAC3C,OAAO,EAAE,+CAA0B;IAEnC,UAAU,EAAE,KAAK,EAAE,MAAwB,EAAE,EAAE;;QAC9C,IAAG,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,0CAAE,IAAI,MAAK,QAAQ;YACpC,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,IAAI,IAAA,cAAI,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;QAI7D,OAAO,IAAA,wBAAgB,EAAC,MAAM,EAAE,gDAA2B,CAAC,QAAQ,CAAC,CAAA;IACtE,CAAC;IAED,MAAM,EAAE,CAAC,oDAAoB,CAAC;CAC9B,CAAC"}
@@ -9,7 +9,7 @@ const pino_1 = __importDefault(require("pino"));
9
9
  const pino_multi_stream_1 = __importDefault(require("pino-multi-stream"));
10
10
  const nest_logger_params_1 = require("../../nest-logger.params");
11
11
  const resolveLoggerFor = async (params, designatedMode) => {
12
- var _a, _b, _c, _d;
12
+ var _a, _b, _c, _d, _e;
13
13
  const loggers = params === null || params === void 0 ? void 0 : params.loggers;
14
14
  let streams = [];
15
15
  if (!((_a = loggers === null || loggers === void 0 ? void 0 : loggers.prettyPrint) === null || _a === void 0 ? void 0 : _a.disabled) && (((_b = loggers === null || loggers === void 0 ? void 0 : loggers.prettyPrint) === null || _b === void 0 ? void 0 : _b.mode) || nest_logger_params_1.NestLoggerParamsLogggerMode.LOG_BUNDLE) === designatedMode) {
@@ -20,7 +20,7 @@ const resolveLoggerFor = async (params, designatedMode) => {
20
20
  stream: prettyStream,
21
21
  });
22
22
  }
23
- if ((loggers === null || loggers === void 0 ? void 0 : loggers.streams) && (((_d = loggers === null || loggers === void 0 ? void 0 : loggers.streams) === null || _d === void 0 ? void 0 : _d.mode) || nest_logger_params_1.NestLoggerParamsLogggerMode.LOG_BUNDLE) === designatedMode) {
23
+ if ((loggers === null || loggers === void 0 ? void 0 : loggers.streams) && !((_d = loggers === null || loggers === void 0 ? void 0 : loggers.streams) === null || _d === void 0 ? void 0 : _d.disabled) && (((_e = loggers === null || loggers === void 0 ? void 0 : loggers.streams) === null || _e === void 0 ? void 0 : _e.mode) || nest_logger_params_1.NestLoggerParamsLogggerMode.LOG_BUNDLE) === designatedMode) {
24
24
  streams.push(...loggers === null || loggers === void 0 ? void 0 : loggers.streams.pinoStreams);
25
25
  }
26
26
  if (streams.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../lib/src/core/providers/utils.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gDAAwB;AACxB,0EAAuC;AACvC,iEAAkH;AAE3G,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAwB,EAAE,cAA2C,EAAE,EAAE;;IAC5G,MAAM,OAAO,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAkC,CAAA;IAE1D,IAAI,OAAO,GAAG,EAAE,CAAC;IAGjB,IAAG,CAAC,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,QAAQ,CAAA,IAAI,CAAC,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,IAAI,KAAI,gDAA2B,CAAC,UAAU,CAAC,KAAK,cAAc,EAAE;QAC7H,MAAM,YAAY,GAAG,2BAAM,CAAC,YAAY,CAAC;YACrC,WAAW,EAAE,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,OAAO,KAAI,EAAE;SACnD,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,YAAY;SACvB,CAAC,CAAA;KACL;IAGD,IAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,CAAC,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,0CAAE,IAAI,KAAI,gDAA2B,CAAC,UAAU,CAAC,KAAK,cAAc,EAAE;QAC1G,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,WAA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C,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAA;gBAClG,CAAC,CAAA;aACJ;SACJ;QAED,OAAO,IAAA,2BAAM,EAAC;YACV,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,iBAAiB;SAC/B,CAAC,CAAC;KAGN;IACD,OAAO,IAAA,cAAI,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA;AAzCY,QAAA,gBAAgB,oBAyC5B"}
@@ -1,8 +1,10 @@
1
1
  import { MiddlewareConsumer, NestModule } from '@nestjs/common';
2
2
  import pino from 'pino';
3
3
  import { ConfigurableModuleClass } from './nest-logger.module-definition';
4
+ import { NestLoggerParams } from './nest-logger.params';
4
5
  export declare class NestLoggerModule extends ConfigurableModuleClass implements NestModule {
6
+ private params;
5
7
  private bundleLogger;
6
- constructor(bundleLogger: pino.Logger);
8
+ constructor(params: NestLoggerParams, bundleLogger: pino.Logger);
7
9
  configure(consumer: MiddlewareConsumer): Promise<void>;
8
10
  }
@@ -27,8 +27,9 @@ const logger_1 = require("./logger");
27
27
  const nest_logger_module_definition_1 = require("./nest-logger.module-definition");
28
28
  const nest_logger_params_1 = require("./nest-logger.params");
29
29
  let NestLoggerModule = class NestLoggerModule extends nest_logger_module_definition_1.ConfigurableModuleClass {
30
- constructor(bundleLogger) {
30
+ constructor(params, bundleLogger) {
31
31
  super();
32
+ this.params = params;
32
33
  this.bundleLogger = bundleLogger;
33
34
  }
34
35
  async configure(consumer) {
@@ -39,7 +40,8 @@ let NestLoggerModule = class NestLoggerModule extends nest_logger_module_definit
39
40
  },
40
41
  logger: this.bundleLogger,
41
42
  });
42
- consumer.apply(middleware, core_1.NestLoggerHookMiddleware).forRoutes({ path: '*', method: common_1.RequestMethod.ALL });
43
+ const routes = this.params.forRoutes || [{ path: '*', method: common_1.RequestMethod.ALL }];
44
+ consumer.apply(middleware, core_1.NestLoggerHookMiddleware).forRoutes(...routes);
43
45
  }
44
46
  };
45
47
  NestLoggerModule = __decorate([
@@ -61,8 +63,9 @@ NestLoggerModule = __decorate([
61
63
  pretty_logger_provider_1.LineLoggerProvider
62
64
  ],
63
65
  }),
64
- __param(0, (0, common_1.Inject)(nest_logger_params_1.BUNDLE_LOGGER_PROVIDER_TOKEN)),
65
- __metadata("design:paramtypes", [Object])
66
+ __param(0, (0, common_1.Inject)(nest_logger_module_definition_1.MODULE_OPTIONS_TOKEN)),
67
+ __param(1, (0, common_1.Inject)(nest_logger_params_1.BUNDLE_LOGGER_PROVIDER_TOKEN)),
68
+ __metadata("design:paramtypes", [Object, Object])
66
69
  ], NestLoggerModule);
67
70
  exports.NestLoggerModule = NestLoggerModule;
68
71
  //# sourceMappingURL=nest-logger.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nest-logger.module.js","sourceRoot":"","sources":["../../lib/src/nest-logger.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAMuB;AACvB,gDAAuB;AACvB,0DAAgC;AAChC,qCAAmE;AACnE,iCAAiD;AACjD,oFAA8E;AAC9E,oFAA4E;AAC5E,qCAAmE;AACnE,mFAAyE;AACzE,6DAAmE;AAoBnE,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,uDAAuB;IAC5D,YAC+C,YAAyB;QAEvE,KAAK,EAAE,CAAA;QAFuC,iBAAY,GAAZ,YAAY,CAAa;IAGxE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAA4B;QAC3C,MAAM,UAAU,GAAG,IAAA,mBAAQ,EAAC;YAE3B,WAAW,EAAE,KAAK;YAClB,mBAAmB,EAAE;gBACpB,GAAG,EAAE,SAAS;aACd;YACD,MAAM,EAAE,IAAI,CAAC,YAAY;SACzB,CAAC,CAAA;QAEF,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,+BAAwB,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,sBAAa,C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CAAC,KAAK,CAAC,UAAU,EAAE,+BAAwB,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAA;IAC1E,CAAC;CACD,CAAA;AAtBY,gBAAgB;IAlB5B,IAAA,eAAM,EAAC;QACP,SAAS,EAAE;YACV,yBAAgB;YAChB,0BAAiB;YACjB,+BAAsB;YACtB,8BAAqB;YACrB,6CAAoB;YACpB,2CAAkB;SAClB;QACD,OAAO,EAAE;YACR,yBAAgB;YAChB,0BAAiB;YACjB,+BAAsB;YACtB,8BAAqB;YACrB,2CAAkB;YAClB,2CAAkB;SAClB;KACD,CAAC;IAGC,WAAA,IAAA,eAAM,EAAC,oDAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,eAAM,EAAC,iDAA4B,CAAC,CAAA;;GAH1B,gBAAgB,CAsB5B;AAtBY,4CAAgB"}
@@ -1,28 +1,20 @@
1
+ import { RouteInfo, Type } from '@nestjs/common/interfaces';
1
2
  import pino from 'pino';
2
3
  import pinoms from 'pino-multi-stream';
3
4
  import { PinoLevels } from './bundle/context/logger.definitions';
4
5
  export declare const BUNDLE_LOGGER_PROVIDER_TOKEN = "BUNDLE_LOGGER_PROVIDER_TOKEN";
5
6
  export declare const LINE_LOGGER_PROVIDER_TOKEN = "LINE_LOGGER_PROVIDER_TOKEN";
6
- export declare enum NestLoggerDispatchStrategy {
7
- DISCARD = 0,
8
- DISPATCH = 1
9
- }
10
7
  export declare enum NestLoggerLevelStrategy {
11
8
  MINOR_LEVEL = 0,
12
9
  MAJOR_LEVEL = 1,
13
10
  LAST_LEVEL = 2
14
11
  }
15
- export declare enum NestLoggerOnErrorStrategy {
16
- DISPATCH = 0
17
- }
18
12
  export interface LoggerModuleAsyncParams {
19
13
  useFactory: (...args: any[]) => NestLoggerParams | Promise<NestLoggerParams>;
20
14
  inject?: any[];
21
15
  }
22
16
  export interface NestLoggerParamsContextBundleStrategy {
23
17
  level?: NestLoggerLevelStrategy;
24
- onDispatch?: NestLoggerDispatchStrategy;
25
- onError?: NestLoggerOnErrorStrategy;
26
18
  }
27
19
  export declare enum NestLoggerParamsLogggerMode {
28
20
  LOG_BUNDLE = 1,
@@ -42,14 +34,14 @@ export interface NestLoggersParamsTimestamp {
42
34
  format?: NestLoggerParamsPinoTimestampFormat;
43
35
  }
44
36
  export interface NestLoggersParamsStreams {
37
+ disabled?: boolean;
45
38
  pinoStreams?: pinoms.Streams;
46
39
  mode?: NestLoggerParamsLogggerMode;
47
40
  }
48
41
  export interface NestLoggersParamsCustom {
49
42
  type: "custom";
50
- level?: string;
51
43
  bundleLogger: pino.Logger;
52
- prettyLogger?: pino.Logger;
44
+ lineLogger?: pino.Logger;
53
45
  }
54
46
  export interface NestLoggersParamsStream {
55
47
  type: "default";
@@ -64,4 +56,5 @@ export interface NestLoggerParamsContextBundle {
64
56
  export interface NestLoggerParams {
65
57
  loggers?: NestLoggersParamsStream | NestLoggersParamsCustom;
66
58
  contextBundle?: NestLoggerParamsContextBundle;
59
+ forRoutes?: (string | Type<any> | RouteInfo)[];
67
60
  }