@athenna/logger 4.15.0 → 4.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/logger",
3
- "version": "4.15.0",
3
+ "version": "4.16.0",
4
4
  "description": "The Athenna logging solution. Log in stdout, files and buckets.",
5
5
  "license": "MIT",
6
6
  "author": "João Lenon <lenon@athenna.io>",
@@ -61,13 +61,14 @@
61
61
  "#tests": "./tests/index.js"
62
62
  },
63
63
  "dependencies": {
64
- "telegraf": "^4.15.3",
65
- "cls-rtracer": "^2.6.3"
64
+ "@aws-lambda-powertools/logger": "^1.18.0",
65
+ "cls-rtracer": "^2.6.3",
66
+ "telegraf": "^4.15.3"
66
67
  },
67
68
  "devDependencies": {
68
- "@athenna/common": "^4.32.0",
69
- "@athenna/config": "^4.14.0",
70
- "@athenna/ioc": "^4.14.0",
69
+ "@athenna/common": "^4.33.0",
70
+ "@athenna/config": "^4.15.0",
71
+ "@athenna/ioc": "^4.15.0",
71
72
  "@athenna/test": "^4.21.0",
72
73
  "@athenna/tsconfig": "^4.12.0",
73
74
  "@typescript-eslint/eslint-plugin": "^6.7.4",
@@ -35,6 +35,11 @@ export declare const VANILLA_CHANNELS: {
35
35
  formatter: string;
36
36
  driver: string;
37
37
  };
38
+ lambda: {
39
+ level: string;
40
+ formatter: string;
41
+ driver: string;
42
+ };
38
43
  request: {
39
44
  level: string;
40
45
  formatter: string;
@@ -35,6 +35,11 @@ export const VANILLA_CHANNELS = {
35
35
  formatter: 'cli',
36
36
  driver: 'console'
37
37
  },
38
+ lambda: {
39
+ level: 'trace',
40
+ formatter: 'json',
41
+ driver: 'lambda'
42
+ },
38
43
  request: {
39
44
  level: 'trace',
40
45
  formatter: 'request',
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import type { Level } from '#src/types';
10
+ import { Driver } from '#src/drivers/Driver';
11
+ export declare class LambdaDriver extends Driver {
12
+ transport(level: Level, message: any): any;
13
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import { debug } from '#src/debug';
10
+ import { Driver } from '#src/drivers/Driver';
11
+ import { logger } from '#src/helpers/AwsLogger';
12
+ export class LambdaDriver extends Driver {
13
+ transport(level, message) {
14
+ if (!this.couldBeTransported(level)) {
15
+ return;
16
+ }
17
+ const levelMap = {
18
+ info: 'info',
19
+ warn: 'warn',
20
+ trace: 'debug',
21
+ debug: 'debug',
22
+ error: 'error',
23
+ success: 'info',
24
+ fatal: 'critical'
25
+ };
26
+ const formatted = this.format(levelMap[level], message);
27
+ debug('[%s] Transporting logs using AWS Powertools.', LambdaDriver.name);
28
+ return logger[levelMap[level]](formatted);
29
+ }
30
+ }
@@ -13,6 +13,7 @@ import { FileDriver } from '#src/drivers/FileDriver';
13
13
  import { NullDriver } from '#src/drivers/NullDriver';
14
14
  import { SlackDriver } from '#src/drivers/SlackDriver';
15
15
  import { StackDriver } from '#src/drivers/StackDriver';
16
+ import { LambdaDriver } from '#src/drivers/LambdaDriver';
16
17
  import { ConsoleDriver } from '#src/drivers/ConsoleDriver';
17
18
  import { DiscordDriver } from '#src/drivers/DiscordDriver';
18
19
  import { FactoryHelper } from '#src/helpers/FactoryHelper';
@@ -29,6 +30,7 @@ export class DriverFactory {
29
30
  .set('null', { Driver: NullDriver })
30
31
  .set('slack', { Driver: SlackDriver })
31
32
  .set('stack', { Driver: StackDriver })
33
+ .set('lambda', { Driver: LambdaDriver })
32
34
  .set('console', { Driver: ConsoleDriver })
33
35
  .set('discord', { Driver: DiscordDriver })
34
36
  .set('telegram', { Driver: TelegramDriver }); }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import { Logger } from '@aws-lambda-powertools/logger';
10
+ /**
11
+ * Expose the AWS logger to be able to make changes on it.
12
+ * By default the log level is set to `debug` because the
13
+ * responsible of deciding if the message should be logged
14
+ * or not is from Athenna.
15
+ */
16
+ export declare const logger: Logger;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import { Logger } from '@aws-lambda-powertools/logger';
10
+ /**
11
+ * Expose the AWS logger to be able to make changes on it.
12
+ * By default the log level is set to `debug` because the
13
+ * responsible of deciding if the message should be logged
14
+ * or not is from Athenna.
15
+ */
16
+ export const logger = new Logger({ logLevel: 'debug' });
package/src/index.d.ts CHANGED
@@ -6,9 +6,11 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ export * from '#src/types';
9
10
  export * from '#src/facades/Log';
10
11
  export * from '#src/logger/Logger';
11
12
  export * from '#src/drivers/Driver';
13
+ export * from '#src/helpers/AwsLogger';
12
14
  export * from '#src/formatters/Formatter';
13
15
  export * from '#src/helpers/FactoryHelper';
14
16
  export * from '#src/factories/DriverFactory';
package/src/index.js CHANGED
@@ -6,9 +6,11 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ export * from '#src/types';
9
10
  export * from '#src/facades/Log';
10
11
  export * from '#src/logger/Logger';
11
12
  export * from '#src/drivers/Driver';
13
+ export * from '#src/helpers/AwsLogger';
12
14
  export * from '#src/formatters/Formatter';
13
15
  export * from '#src/helpers/FactoryHelper';
14
16
  export * from '#src/factories/DriverFactory';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export type Level = 'trace' | 'debug' | 'info' | 'success' | 'warn' | 'error' | 'fatal';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export * from '#src/types/Level';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @athenna/logger
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export * from '#src/types/Level';