@loglayer/transport-datadog 1.0.1 → 2.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
@@ -9,25 +9,17 @@ Ships logs to Datadog using the [datadog-transport-common](https://www.npmjs.com
9
9
  ## Important Notes
10
10
 
11
11
  - Only works server-side (not in browsers)
12
- * For browser-side logging, use the [`@loglayer/transport-datadog-browser-logs`](https://loglayer.dev/transports/datadog-browser-logs.html) package
13
- - import `createDataDogTransport` from `@loglayer/transport-datadog` to create a new DataDog transport
12
+ * For browser-side logging, use the [`@loglayer/transport-datadog-browser-logs`](https://github.com/loglayer/loglayer/tree/master/packages/transports/datadog-browser-logs) package
14
13
  - You will not get any console output since this sends directly to DataDog. Use the `onDebug` option to log out messages.
15
14
 
16
- ## Installation
17
-
18
- ```bash
19
- npm install loglayer @loglayer/transport-datadog
20
- ```
21
-
22
15
  ## Usage
23
16
 
24
17
  ```typescript
25
18
  import { LogLayer } from 'loglayer'
26
- import { createDataDogTransport } from "@loglayer/transport-datadog"
19
+ import { DataDogTransport } from "@loglayer/transport-datadog"
27
20
 
28
21
  const log = new LogLayer({
29
- transport: createDataDogTransport({
30
- id: "datadog",
22
+ transport: new DataDogTransport({
31
23
  options: {
32
24
  ddClientConf: {
33
25
  authMethods: {
@@ -49,112 +41,4 @@ const log = new LogLayer({
49
41
  })
50
42
  ```
51
43
 
52
- ## Configuration
53
-
54
- ```typescript
55
- interface DataDogTransportOptions {
56
- /**
57
- * The ID of the transport.
58
- */
59
- id?: string
60
- /**
61
- * Whether the transport is enabled. Default is true.
62
- */
63
- enabled?: boolean
64
- /**
65
- * The field name to use for the message. Default is "message".
66
- */
67
- messageField?: string;
68
- /**
69
- * The field name to use for the log level. Default is "level".
70
- */
71
- levelField?: string;
72
- /**
73
- * The field name to use for the timestamp. Default is "time".
74
- */
75
- timestampField?: string;
76
- /**
77
- * A custom function to stamp the timestamp. The default timestamp uses the ISO 8601 format.
78
- */
79
- timestampFunction?: () => any;
80
- /**
81
- * The options for the transport.
82
- */
83
- options: DDTransportOptions
84
- }
85
- ```
86
-
87
- ```typescript
88
- export interface DDTransportOptions {
89
- /**
90
- * DataDog client configuration parameters.
91
- * @see https://datadoghq.dev/datadog-api-client-typescript/interfaces/client.Configuration.html
92
- */
93
- ddClientConf: ConfigurationParameters
94
- /**
95
- * Datadog server config for the client. Use this to change the Datadog server region.
96
- * @see https://github.com/DataDog/datadog-api-client-typescript/blob/1e1097c68a437894b482701ecbe3d61522429319/packages/datadog-api-client-common/servers.ts#L90
97
- */
98
- ddServerConf?: {
99
- /**
100
- * The datadog server to use. Default is datadoghq.com.
101
- * Other values could be:
102
- * - us3.datadoghq.com
103
- * - us5.datadoghq.com
104
- * - datadoghq.eu
105
- * - ddog-gov.com
106
- */
107
- site?: string
108
- subdomain?: string
109
- protocol?: string
110
- }
111
- /**
112
- * The integration name associated with your log: the technology from which
113
- * the log originated. When it matches an integration name, Datadog
114
- * automatically installs the corresponding parsers and facets.
115
- * @see https://docs.datadoghq.com/logs/log_collection/?tab=host#reserved-attributes
116
- */
117
- ddsource?: string
118
- /**
119
- * Comma separated tags associated with your logs. Ex: "env:prod,org:finance"
120
- */
121
- ddtags?: string
122
- /**
123
- * The name of the application or service generating the log events.
124
- * Default is "Electron"
125
- * @see https://docs.datadoghq.com/logs/log_collection/?tab=host#reserved-attributes
126
- */
127
- service?: string
128
- /**
129
- * Called when the plugin is ready to process logs.
130
- */
131
- onInit?: () => void
132
- /**
133
- * Error handler for when the submitLog() call fails.
134
- */
135
- onError?: (err: any, logs?: Array<Record<string, any>>) => void
136
- /**
137
- * Define this callback to get debug messages from this transport
138
- */
139
- onDebug?: (msg: string) => void
140
- /**
141
- * Number of times to retry sending the log before onError() is called.
142
- * Default is 5.
143
- */
144
- retries?: number
145
- /**
146
- * Interval in which logs are sent to Datadog.
147
- * Default is 3000 milliseconds.
148
- */
149
- sendIntervalMs?: number
150
- /**
151
- * Set to true to disable batch sending and send each log as it comes in. This disables
152
- * the send interval.
153
- */
154
- sendImmediate?: boolean
155
- }
156
- ```
157
-
158
- ## Documentation
159
-
160
- For more details, visit [https://loglayer.dev/transports/datadog](https://loglayer.dev/transports/datadog)
44
+ See the [documentation](https://loglayer.dev/transports/datadog) for more information.
package/dist/index.cjs CHANGED
@@ -1,13 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/DataDogTransport.ts
2
2
  var _transport = require('@loglayer/transport');
3
3
  var _datadogtransportcommon = require('datadog-transport-common');
4
- var DataDogTransport = class extends _transport.BaseTransport {
4
+ var DataDogTransport = class extends _transport.LoggerlessTransport {
5
+
5
6
 
6
7
 
7
8
 
8
9
 
9
10
  constructor(config) {
10
11
  super(config);
12
+ this.transport = new (0, _datadogtransportcommon.DataDogTransport)(config.options);
11
13
  this.messageField = _nullishCoalesce(config.messageField, () => ( "message"));
12
14
  this.levelField = _nullishCoalesce(config.levelField, () => ( "level"));
13
15
  this.timestampField = _nullishCoalesce(config.timestampField, () => ( "time"));
@@ -18,24 +20,18 @@ var DataDogTransport = class extends _transport.BaseTransport {
18
20
  if (data && hasData) {
19
21
  Object.assign(logEntry, data);
20
22
  }
21
- if (this.timestampField && this.timestampFunction) {
23
+ if (this.timestampFunction) {
22
24
  logEntry[this.timestampField] = this.timestampFunction();
23
25
  } else {
24
26
  logEntry[this.timestampField] = (/* @__PURE__ */ new Date()).toISOString();
25
27
  }
26
28
  logEntry[this.levelField] = logLevel;
27
29
  logEntry[this.messageField] = messages.join(" ");
28
- this.logger.processLog(logEntry);
30
+ this.transport.processLog(logEntry);
29
31
  return messages;
30
32
  }
31
33
  };
32
- function createDataDogTransport(config) {
33
- return new DataDogTransport({
34
- ...config,
35
- logger: new (0, _datadogtransportcommon.DataDogTransport)(config.options)
36
- });
37
- }
38
34
 
39
35
 
40
- exports.createDataDogTransport = createDataDogTransport;
36
+ exports.DataDogTransport = DataDogTransport;
41
37
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/loglayer/loglayer/packages/transports/datadog/dist/index.cjs","../src/DataDogTransport.ts"],"names":[],"mappings":"AAAA;ACAA,gDAA4D;AAE5D,kEAAoF;AAyBpF,IAAM,iBAAA,EAAN,MAAA,QAA+B,yBAAsC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,WAAA,CAAY,MAAA,EAAkG;AAC5G,IAAA,KAAA,CAAM,MAAM,CAAA;AAEZ,IAAA,IAAA,CAAK,aAAA,mBAAe,MAAA,CAAO,YAAA,UAAgB,WAAA;AAC3C,IAAA,IAAA,CAAK,WAAA,mBAAa,MAAA,CAAO,UAAA,UAAc,SAAA;AACvC,IAAA,IAAA,CAAK,eAAA,mBAAiB,MAAA,CAAO,cAAA,UAAkB,QAAA;AAC/C,IAAA,IAAA,CAAK,kBAAA,EAAoB,MAAA,CAAO,iBAAA;AAAA,EAClC;AAAA,EAEA,YAAA,CAAa,EAAE,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAQ,CAAA,EAA4B;AAC3E,IAAA,MAAM,SAAA,EAAgC,CAAC,CAAA;AAEvC,IAAA,GAAA,CAAI,KAAA,GAAQ,OAAA,EAAS;AACnB,MAAA,MAAA,CAAO,MAAA,CAAO,QAAA,EAAU,IAAI,CAAA;AAAA,IAC9B;AAEA,IAAA,GAAA,CAAI,IAAA,CAAK,eAAA,GAAkB,IAAA,CAAK,iBAAA,EAAmB;AACjD,MAAA,QAAA,CAAS,IAAA,CAAK,cAAc,EAAA,EAAI,IAAA,CAAK,iBAAA,CAAkB,CAAA;AAAA,IACzD,EAAA,KAAO;AACL,MAAA,QAAA,CAAS,IAAA,CAAK,cAAc,EAAA,EAAA,iBAAI,IAAI,IAAA,CAAK,CAAA,CAAA,CAAE,WAAA,CAAY,CAAA;AAAA,IACzD;AAEA,IAAA,QAAA,CAAS,IAAA,CAAK,UAAU,EAAA,EAAI,QAAA;AAC5B,IAAA,QAAA,CAAS,IAAA,CAAK,YAAY,EAAA,EAAI,QAAA,CAAS,IAAA,CAAK,GAAG,CAAA;AAE/C,IAAA,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,QAAQ,CAAA;AAE/B,IAAA,OAAO,QAAA;AAAA,EACT;AACF,CAAA;AAEO,SAAS,sBAAA,CAAuB,MAAA,EAAgC;AACrE,EAAA,OAAO,IAAI,gBAAA,CAAiB;AAAA,IAC1B,GAAG,MAAA;AAAA,IACH,MAAA,EAAQ,IAAI,6CAAA,CAAuB,MAAA,CAAO,OAAO;AAAA,EACnD,CAAC,CAAA;AACH;ADhCA;AACE;AACF,wDAAC","file":"/home/runner/work/loglayer/loglayer/packages/transports/datadog/dist/index.cjs","sourcesContent":[null,"import { BaseTransport, type LogLayerTransportParams } from \"@loglayer/transport\";\nimport type { LogLayerTransportConfig } from \"@loglayer/transport\";\nimport { type DDTransportOptions, DataDogTransport as DatadogTransportCommon } from \"datadog-transport-common\";\n\nexport interface DatadogTransportConfig extends Omit<LogLayerTransportConfig<DatadogTransportCommon>, \"logger\"> {\n /**\n * The options to pass to the datadog-transport-common instance.\n */\n options: DDTransportOptions;\n /**\n * The field name to use for the message. Default is \"message\".\n */\n messageField?: string;\n /**\n * The field name to use for the log level. Default is \"level\".\n */\n levelField?: string;\n /**\n * The field name to use for the timestamp. Default is \"time\".\n */\n timestampField?: string;\n /**\n * A custom function to stamp the timestamp\n */\n timestampFunction?: () => any;\n}\n\nclass DataDogTransport extends BaseTransport<DatadogTransportCommon> {\n messageField: string;\n levelField: string;\n timestampField: string;\n timestampFunction?: () => any;\n\n constructor(config: DatadogTransportConfig & Pick<LogLayerTransportConfig<DatadogTransportCommon>, \"logger\">) {\n super(config);\n\n this.messageField = config.messageField ?? \"message\";\n this.levelField = config.levelField ?? \"level\";\n this.timestampField = config.timestampField ?? \"time\";\n this.timestampFunction = config.timestampFunction;\n }\n\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams) {\n const logEntry: Record<string, any> = {};\n\n if (data && hasData) {\n Object.assign(logEntry, data);\n }\n\n if (this.timestampField && this.timestampFunction) {\n logEntry[this.timestampField] = this.timestampFunction();\n } else {\n logEntry[this.timestampField] = new Date().toISOString();\n }\n\n logEntry[this.levelField] = logLevel;\n logEntry[this.messageField] = messages.join(\" \");\n\n this.logger.processLog(logEntry);\n\n return messages;\n }\n}\n\nexport function createDataDogTransport(config: DatadogTransportConfig) {\n return new DataDogTransport({\n ...config,\n logger: new DatadogTransportCommon(config.options),\n });\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/loglayer/loglayer/packages/transports/datadog/dist/index.cjs","../src/DataDogTransport.ts"],"names":[],"mappings":"AAAA;ACEA,gDAAoC;AACpC,kEAAoF;AAyB7E,IAAM,iBAAA,EAAN,MAAA,QAA+B,+BAAoB;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,WAAA,CAAY,MAAA,EAAgC;AAC1C,IAAA,KAAA,CAAM,MAAM,CAAA;AAEZ,IAAA,IAAA,CAAK,UAAA,EAAY,IAAI,6CAAA,CAAuB,MAAA,CAAO,OAAO,CAAA;AAC1D,IAAA,IAAA,CAAK,aAAA,mBAAe,MAAA,CAAO,YAAA,UAAgB,WAAA;AAC3C,IAAA,IAAA,CAAK,WAAA,mBAAa,MAAA,CAAO,UAAA,UAAc,SAAA;AACvC,IAAA,IAAA,CAAK,eAAA,mBAAiB,MAAA,CAAO,cAAA,UAAkB,QAAA;AAC/C,IAAA,IAAA,CAAK,kBAAA,EAAoB,MAAA,CAAO,iBAAA;AAAA,EAClC;AAAA,EAEA,YAAA,CAAa,EAAE,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAQ,CAAA,EAA4B;AAC3E,IAAA,MAAM,SAAA,EAAgC,CAAC,CAAA;AAEvC,IAAA,GAAA,CAAI,KAAA,GAAQ,OAAA,EAAS;AACnB,MAAA,MAAA,CAAO,MAAA,CAAO,QAAA,EAAU,IAAI,CAAA;AAAA,IAC9B;AAEA,IAAA,GAAA,CAAI,IAAA,CAAK,iBAAA,EAAmB;AAC1B,MAAA,QAAA,CAAS,IAAA,CAAK,cAAc,EAAA,EAAI,IAAA,CAAK,iBAAA,CAAkB,CAAA;AAAA,IACzD,EAAA,KAAO;AACL,MAAA,QAAA,CAAS,IAAA,CAAK,cAAc,EAAA,EAAA,iBAAI,IAAI,IAAA,CAAK,CAAA,CAAA,CAAE,WAAA,CAAY,CAAA;AAAA,IACzD;AAEA,IAAA,QAAA,CAAS,IAAA,CAAK,UAAU,EAAA,EAAI,QAAA;AAC5B,IAAA,QAAA,CAAS,IAAA,CAAK,YAAY,EAAA,EAAI,QAAA,CAAS,IAAA,CAAK,GAAG,CAAA;AAE/C,IAAA,IAAA,CAAK,SAAA,CAAU,UAAA,CAAW,QAAQ,CAAA;AAElC,IAAA,OAAO,QAAA;AAAA,EACT;AACF,CAAA;ADhCA;AACE;AACF,4CAAC","file":"/home/runner/work/loglayer/loglayer/packages/transports/datadog/dist/index.cjs","sourcesContent":[null,"import type { LogLayerTransportParams } from \"@loglayer/transport\";\nimport type { LoggerlessTransportConfig } from \"@loglayer/transport\";\nimport { LoggerlessTransport } from \"@loglayer/transport\";\nimport { type DDTransportOptions, DataDogTransport as DatadogTransportCommon } from \"datadog-transport-common\";\n\nexport interface DatadogTransportConfig extends LoggerlessTransportConfig {\n /**\n * The options to pass to the datadog-transport-common instance.\n */\n options: DDTransportOptions;\n /**\n * The field name to use for the message. Default is \"message\".\n */\n messageField?: string;\n /**\n * The field name to use for the log level. Default is \"level\".\n */\n levelField?: string;\n /**\n * The field name to use for the timestamp. Default is \"time\".\n */\n timestampField?: string;\n /**\n * A custom function to stamp the timestamp\n */\n timestampFunction?: () => any;\n}\n\nexport class DataDogTransport extends LoggerlessTransport {\n private messageField: string;\n private levelField: string;\n private timestampField: string;\n private timestampFunction?: () => any;\n private transport: DatadogTransportCommon;\n\n constructor(config: DatadogTransportConfig) {\n super(config);\n\n this.transport = new DatadogTransportCommon(config.options);\n this.messageField = config.messageField ?? \"message\";\n this.levelField = config.levelField ?? \"level\";\n this.timestampField = config.timestampField ?? \"time\";\n this.timestampFunction = config.timestampFunction;\n }\n\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams) {\n const logEntry: Record<string, any> = {};\n\n if (data && hasData) {\n Object.assign(logEntry, data);\n }\n\n if (this.timestampFunction) {\n logEntry[this.timestampField] = this.timestampFunction();\n } else {\n logEntry[this.timestampField] = new Date().toISOString();\n }\n\n logEntry[this.levelField] = logLevel;\n logEntry[this.messageField] = messages.join(\" \");\n\n this.transport.processLog(logEntry);\n\n return messages;\n }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { LogLayerTransportConfig, BaseTransport, LogLayerTransportParams } from '@loglayer/transport';
2
- import { DataDogTransport as DataDogTransport$1, DDTransportOptions } from 'datadog-transport-common';
1
+ import { LoggerlessTransportConfig, LoggerlessTransport, LogLayerTransportParams } from '@loglayer/transport';
2
+ import { DDTransportOptions } from 'datadog-transport-common';
3
3
  export { DDTransportOptions } from 'datadog-transport-common';
4
4
 
5
- interface DatadogTransportConfig extends Omit<LogLayerTransportConfig<DataDogTransport$1>, "logger"> {
5
+ interface DatadogTransportConfig extends LoggerlessTransportConfig {
6
6
  /**
7
7
  * The options to pass to the datadog-transport-common instance.
8
8
  */
@@ -24,14 +24,14 @@ interface DatadogTransportConfig extends Omit<LogLayerTransportConfig<DataDogTra
24
24
  */
25
25
  timestampFunction?: () => any;
26
26
  }
27
- declare class DataDogTransport extends BaseTransport<DataDogTransport$1> {
28
- messageField: string;
29
- levelField: string;
30
- timestampField: string;
31
- timestampFunction?: () => any;
32
- constructor(config: DatadogTransportConfig & Pick<LogLayerTransportConfig<DataDogTransport$1>, "logger">);
27
+ declare class DataDogTransport extends LoggerlessTransport {
28
+ private messageField;
29
+ private levelField;
30
+ private timestampField;
31
+ private timestampFunction?;
32
+ private transport;
33
+ constructor(config: DatadogTransportConfig);
33
34
  shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
34
35
  }
35
- declare function createDataDogTransport(config: DatadogTransportConfig): DataDogTransport;
36
36
 
37
- export { type DatadogTransportConfig, createDataDogTransport };
37
+ export { DataDogTransport, type DatadogTransportConfig };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { LogLayerTransportConfig, BaseTransport, LogLayerTransportParams } from '@loglayer/transport';
2
- import { DataDogTransport as DataDogTransport$1, DDTransportOptions } from 'datadog-transport-common';
1
+ import { LoggerlessTransportConfig, LoggerlessTransport, LogLayerTransportParams } from '@loglayer/transport';
2
+ import { DDTransportOptions } from 'datadog-transport-common';
3
3
  export { DDTransportOptions } from 'datadog-transport-common';
4
4
 
5
- interface DatadogTransportConfig extends Omit<LogLayerTransportConfig<DataDogTransport$1>, "logger"> {
5
+ interface DatadogTransportConfig extends LoggerlessTransportConfig {
6
6
  /**
7
7
  * The options to pass to the datadog-transport-common instance.
8
8
  */
@@ -24,14 +24,14 @@ interface DatadogTransportConfig extends Omit<LogLayerTransportConfig<DataDogTra
24
24
  */
25
25
  timestampFunction?: () => any;
26
26
  }
27
- declare class DataDogTransport extends BaseTransport<DataDogTransport$1> {
28
- messageField: string;
29
- levelField: string;
30
- timestampField: string;
31
- timestampFunction?: () => any;
32
- constructor(config: DatadogTransportConfig & Pick<LogLayerTransportConfig<DataDogTransport$1>, "logger">);
27
+ declare class DataDogTransport extends LoggerlessTransport {
28
+ private messageField;
29
+ private levelField;
30
+ private timestampField;
31
+ private timestampFunction?;
32
+ private transport;
33
+ constructor(config: DatadogTransportConfig);
33
34
  shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
34
35
  }
35
- declare function createDataDogTransport(config: DatadogTransportConfig): DataDogTransport;
36
36
 
37
- export { type DatadogTransportConfig, createDataDogTransport };
37
+ export { DataDogTransport, type DatadogTransportConfig };
package/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  // src/DataDogTransport.ts
2
- import { BaseTransport } from "@loglayer/transport";
2
+ import { LoggerlessTransport } from "@loglayer/transport";
3
3
  import { DataDogTransport as DatadogTransportCommon } from "datadog-transport-common";
4
- var DataDogTransport = class extends BaseTransport {
4
+ var DataDogTransport = class extends LoggerlessTransport {
5
5
  messageField;
6
6
  levelField;
7
7
  timestampField;
8
8
  timestampFunction;
9
+ transport;
9
10
  constructor(config) {
10
11
  super(config);
12
+ this.transport = new DatadogTransportCommon(config.options);
11
13
  this.messageField = config.messageField ?? "message";
12
14
  this.levelField = config.levelField ?? "level";
13
15
  this.timestampField = config.timestampField ?? "time";
@@ -18,24 +20,18 @@ var DataDogTransport = class extends BaseTransport {
18
20
  if (data && hasData) {
19
21
  Object.assign(logEntry, data);
20
22
  }
21
- if (this.timestampField && this.timestampFunction) {
23
+ if (this.timestampFunction) {
22
24
  logEntry[this.timestampField] = this.timestampFunction();
23
25
  } else {
24
26
  logEntry[this.timestampField] = (/* @__PURE__ */ new Date()).toISOString();
25
27
  }
26
28
  logEntry[this.levelField] = logLevel;
27
29
  logEntry[this.messageField] = messages.join(" ");
28
- this.logger.processLog(logEntry);
30
+ this.transport.processLog(logEntry);
29
31
  return messages;
30
32
  }
31
33
  };
32
- function createDataDogTransport(config) {
33
- return new DataDogTransport({
34
- ...config,
35
- logger: new DatadogTransportCommon(config.options)
36
- });
37
- }
38
34
  export {
39
- createDataDogTransport
35
+ DataDogTransport
40
36
  };
41
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/DataDogTransport.ts"],"sourcesContent":["import { BaseTransport, type LogLayerTransportParams } from \"@loglayer/transport\";\nimport type { LogLayerTransportConfig } from \"@loglayer/transport\";\nimport { type DDTransportOptions, DataDogTransport as DatadogTransportCommon } from \"datadog-transport-common\";\n\nexport interface DatadogTransportConfig extends Omit<LogLayerTransportConfig<DatadogTransportCommon>, \"logger\"> {\n /**\n * The options to pass to the datadog-transport-common instance.\n */\n options: DDTransportOptions;\n /**\n * The field name to use for the message. Default is \"message\".\n */\n messageField?: string;\n /**\n * The field name to use for the log level. Default is \"level\".\n */\n levelField?: string;\n /**\n * The field name to use for the timestamp. Default is \"time\".\n */\n timestampField?: string;\n /**\n * A custom function to stamp the timestamp\n */\n timestampFunction?: () => any;\n}\n\nclass DataDogTransport extends BaseTransport<DatadogTransportCommon> {\n messageField: string;\n levelField: string;\n timestampField: string;\n timestampFunction?: () => any;\n\n constructor(config: DatadogTransportConfig & Pick<LogLayerTransportConfig<DatadogTransportCommon>, \"logger\">) {\n super(config);\n\n this.messageField = config.messageField ?? \"message\";\n this.levelField = config.levelField ?? \"level\";\n this.timestampField = config.timestampField ?? \"time\";\n this.timestampFunction = config.timestampFunction;\n }\n\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams) {\n const logEntry: Record<string, any> = {};\n\n if (data && hasData) {\n Object.assign(logEntry, data);\n }\n\n if (this.timestampField && this.timestampFunction) {\n logEntry[this.timestampField] = this.timestampFunction();\n } else {\n logEntry[this.timestampField] = new Date().toISOString();\n }\n\n logEntry[this.levelField] = logLevel;\n logEntry[this.messageField] = messages.join(\" \");\n\n this.logger.processLog(logEntry);\n\n return messages;\n }\n}\n\nexport function createDataDogTransport(config: DatadogTransportConfig) {\n return new DataDogTransport({\n ...config,\n logger: new DatadogTransportCommon(config.options),\n });\n}\n"],"mappings":";AAAA,SAAS,qBAAmD;AAE5D,SAAkC,oBAAoB,8BAA8B;AAyBpF,IAAM,mBAAN,cAA+B,cAAsC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,QAAkG;AAC5G,UAAM,MAAM;AAEZ,SAAK,eAAe,OAAO,gBAAgB;AAC3C,SAAK,aAAa,OAAO,cAAc;AACvC,SAAK,iBAAiB,OAAO,kBAAkB;AAC/C,SAAK,oBAAoB,OAAO;AAAA,EAClC;AAAA,EAEA,aAAa,EAAE,UAAU,UAAU,MAAM,QAAQ,GAA4B;AAC3E,UAAM,WAAgC,CAAC;AAEvC,QAAI,QAAQ,SAAS;AACnB,aAAO,OAAO,UAAU,IAAI;AAAA,IAC9B;AAEA,QAAI,KAAK,kBAAkB,KAAK,mBAAmB;AACjD,eAAS,KAAK,cAAc,IAAI,KAAK,kBAAkB;AAAA,IACzD,OAAO;AACL,eAAS,KAAK,cAAc,KAAI,oBAAI,KAAK,GAAE,YAAY;AAAA,IACzD;AAEA,aAAS,KAAK,UAAU,IAAI;AAC5B,aAAS,KAAK,YAAY,IAAI,SAAS,KAAK,GAAG;AAE/C,SAAK,OAAO,WAAW,QAAQ;AAE/B,WAAO;AAAA,EACT;AACF;AAEO,SAAS,uBAAuB,QAAgC;AACrE,SAAO,IAAI,iBAAiB;AAAA,IAC1B,GAAG;AAAA,IACH,QAAQ,IAAI,uBAAuB,OAAO,OAAO;AAAA,EACnD,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/DataDogTransport.ts"],"sourcesContent":["import type { LogLayerTransportParams } from \"@loglayer/transport\";\nimport type { LoggerlessTransportConfig } from \"@loglayer/transport\";\nimport { LoggerlessTransport } from \"@loglayer/transport\";\nimport { type DDTransportOptions, DataDogTransport as DatadogTransportCommon } from \"datadog-transport-common\";\n\nexport interface DatadogTransportConfig extends LoggerlessTransportConfig {\n /**\n * The options to pass to the datadog-transport-common instance.\n */\n options: DDTransportOptions;\n /**\n * The field name to use for the message. Default is \"message\".\n */\n messageField?: string;\n /**\n * The field name to use for the log level. Default is \"level\".\n */\n levelField?: string;\n /**\n * The field name to use for the timestamp. Default is \"time\".\n */\n timestampField?: string;\n /**\n * A custom function to stamp the timestamp\n */\n timestampFunction?: () => any;\n}\n\nexport class DataDogTransport extends LoggerlessTransport {\n private messageField: string;\n private levelField: string;\n private timestampField: string;\n private timestampFunction?: () => any;\n private transport: DatadogTransportCommon;\n\n constructor(config: DatadogTransportConfig) {\n super(config);\n\n this.transport = new DatadogTransportCommon(config.options);\n this.messageField = config.messageField ?? \"message\";\n this.levelField = config.levelField ?? \"level\";\n this.timestampField = config.timestampField ?? \"time\";\n this.timestampFunction = config.timestampFunction;\n }\n\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams) {\n const logEntry: Record<string, any> = {};\n\n if (data && hasData) {\n Object.assign(logEntry, data);\n }\n\n if (this.timestampFunction) {\n logEntry[this.timestampField] = this.timestampFunction();\n } else {\n logEntry[this.timestampField] = new Date().toISOString();\n }\n\n logEntry[this.levelField] = logLevel;\n logEntry[this.messageField] = messages.join(\" \");\n\n this.transport.processLog(logEntry);\n\n return messages;\n }\n}\n"],"mappings":";AAEA,SAAS,2BAA2B;AACpC,SAAkC,oBAAoB,8BAA8B;AAyB7E,IAAM,mBAAN,cAA+B,oBAAoB;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,QAAgC;AAC1C,UAAM,MAAM;AAEZ,SAAK,YAAY,IAAI,uBAAuB,OAAO,OAAO;AAC1D,SAAK,eAAe,OAAO,gBAAgB;AAC3C,SAAK,aAAa,OAAO,cAAc;AACvC,SAAK,iBAAiB,OAAO,kBAAkB;AAC/C,SAAK,oBAAoB,OAAO;AAAA,EAClC;AAAA,EAEA,aAAa,EAAE,UAAU,UAAU,MAAM,QAAQ,GAA4B;AAC3E,UAAM,WAAgC,CAAC;AAEvC,QAAI,QAAQ,SAAS;AACnB,aAAO,OAAO,UAAU,IAAI;AAAA,IAC9B;AAEA,QAAI,KAAK,mBAAmB;AAC1B,eAAS,KAAK,cAAc,IAAI,KAAK,kBAAkB;AAAA,IACzD,OAAO;AACL,eAAS,KAAK,cAAc,KAAI,oBAAI,KAAK,GAAE,YAAY;AAAA,IACzD;AAEA,aAAS,KAAK,UAAU,IAAI;AAC5B,aAAS,KAAK,YAAY,IAAI,SAAS,KAAK,GAAG;AAE/C,SAAK,UAAU,WAAW,QAAQ;AAElC,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loglayer/transport-datadog",
3
3
  "description": "DataDog transport for loglayer.",
4
- "version": "1.0.1",
4
+ "version": "2.0.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@datadog/datadog-api-client": "1.31.0",
31
31
  "datadog-transport-common": "3.0.2",
32
- "@loglayer/transport": "1.1.0"
32
+ "@loglayer/transport": "1.1.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "hash-runner": "2.0.1",
@@ -37,7 +37,7 @@
37
37
  "tsup": "8.3.5",
38
38
  "typescript": "5.7.2",
39
39
  "vitest": "2.1.8",
40
- "loglayer": "5.0.4",
40
+ "loglayer": "5.0.7",
41
41
  "@internal/tsconfig": "1.0.0"
42
42
  },
43
43
  "bugs": "https://github.com/loglayer/loglayer/issues",