@digitraffic/common 2023.3.21-1 → 2023.3.21-2

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.
@@ -41,30 +41,30 @@ export declare class DtLogger {
41
41
  readonly writeStream: Writable;
42
42
  constructor(config?: LoggerConfiguration);
43
43
  /**
44
- * Log given message with level DEBUG
44
+ * Log given message with level DEBUG. This will not be forwarded to centralized logging system!.
45
45
  *
46
- * @param message Either a string or json-object
46
+ * @param message anything
47
47
  * @see log
48
48
  */
49
- debug(message: LoggableType): void;
49
+ debug(message: unknown): void;
50
50
  /**
51
51
  * Log given message with level INFO
52
52
  *
53
- * @param message Either a string or json-object
53
+ * @param message Json-object to log
54
54
  * @see log
55
55
  */
56
56
  info(message: LoggableType): void;
57
57
  /**
58
58
  * Log given message with level WARN
59
59
  *
60
- * @param message Either a string or json-object
60
+ * @param message Json-object to log
61
61
  * @see log
62
62
  */
63
63
  warn(message: LoggableType): void;
64
64
  /**
65
65
  * Log given message with level INFO
66
66
  *
67
- * @param message Either a string or json-object
67
+ * @param message Json-object to log
68
68
  * @see log
69
69
  */
70
70
  error(message: LoggableType): void;
@@ -17,18 +17,25 @@ class DtLogger {
17
17
  this.writeStream = config?.writeStream ?? process.stdout;
18
18
  }
19
19
  /**
20
- * Log given message with level DEBUG
20
+ * Log given message with level DEBUG. This will not be forwarded to centralized logging system!.
21
21
  *
22
- * @param message Either a string or json-object
22
+ * @param message anything
23
23
  * @see log
24
24
  */
25
25
  debug(message) {
26
- this.log("DEBUG", message);
26
+ const logMessage = {
27
+ message,
28
+ level: "DEBUG",
29
+ fileName: this.fileName,
30
+ lambdaName: this.lambdaName,
31
+ runtime: this.runtime,
32
+ };
33
+ this.writeStream.write(JSON.stringify(logMessage) + "\n");
27
34
  }
28
35
  /**
29
36
  * Log given message with level INFO
30
37
  *
31
- * @param message Either a string or json-object
38
+ * @param message Json-object to log
32
39
  * @see log
33
40
  */
34
41
  info(message) {
@@ -37,7 +44,7 @@ class DtLogger {
37
44
  /**
38
45
  * Log given message with level WARN
39
46
  *
40
- * @param message Either a string or json-object
47
+ * @param message Json-object to log
41
48
  * @see log
42
49
  */
43
50
  warn(message) {
@@ -46,7 +53,7 @@ class DtLogger {
46
53
  /**
47
54
  * Log given message with level INFO
48
55
  *
49
- * @param message Either a string or json-object
56
+ * @param message Json-object to log
50
57
  * @see log
51
58
  */
52
59
  error(message) {
@@ -1,4 +1,4 @@
1
1
  import { AxiosError } from "axios";
2
2
  import { DtLogger } from "../aws/runtime/dt-logger";
3
- export declare function logException(logger: DtLogger, error: Error | string, includeStack: boolean): void;
3
+ export declare function logException(logger: DtLogger, error: Error | string, includeStack?: boolean): void;
4
4
  export declare function logException(logger: DtLogger, error: AxiosError): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2023.3.21-1",
3
+ "version": "2023.3.21-2",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,19 +53,27 @@ export class DtLogger {
53
53
  }
54
54
 
55
55
  /**
56
- * Log given message with level DEBUG
56
+ * Log given message with level DEBUG. This will not be forwarded to centralized logging system!.
57
57
  *
58
- * @param message Either a string or json-object
58
+ * @param message anything
59
59
  * @see log
60
60
  */
61
- debug(message: LoggableType): void {
62
- this.log("DEBUG", message);
61
+ debug(message: unknown): void {
62
+ const logMessage = {
63
+ message,
64
+ level: "DEBUG",
65
+ fileName: this.fileName,
66
+ lambdaName: this.lambdaName,
67
+ runtime: this.runtime,
68
+ };
69
+
70
+ this.writeStream.write(JSON.stringify(logMessage) + "\n");
63
71
  }
64
72
 
65
73
  /**
66
74
  * Log given message with level INFO
67
75
  *
68
- * @param message Either a string or json-object
76
+ * @param message Json-object to log
69
77
  * @see log
70
78
  */
71
79
  info(message: LoggableType): void {
@@ -75,7 +83,7 @@ export class DtLogger {
75
83
  /**
76
84
  * Log given message with level WARN
77
85
  *
78
- * @param message Either a string or json-object
86
+ * @param message Json-object to log
79
87
  * @see log
80
88
  */
81
89
  warn(message: LoggableType): void {
@@ -84,7 +92,7 @@ export class DtLogger {
84
92
  /**
85
93
  * Log given message with level INFO
86
94
  *
87
- * @param message Either a string or json-object
95
+ * @param message Json-object to log
88
96
  * @see log
89
97
  */
90
98
  error(message: LoggableType): void {
@@ -7,7 +7,7 @@ const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
7
7
  export function logException(
8
8
  logger: DtLogger,
9
9
  error: Error | string,
10
- includeStack: boolean
10
+ includeStack?: boolean
11
11
  ): void;
12
12
  export function logException(logger: DtLogger, error: AxiosError): void;
13
13