@loglayer/transport-sumo-logic 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Theo Gravity
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Sumo Logic Transport for LogLayer
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/%40loglayer%2Ftransport-sumo-logic)](https://www.npmjs.com/package/@loglayer/transport-sumo-logic)
4
+ [![NPM Downloads](https://img.shields.io/npm/dm/%40loglayer%2Ftransport-sumo-logic)](https://www.npmjs.com/package/@loglayer/transport-sumo-logic)
5
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
6
+
7
+ A [LogLayer](https://loglayer.dev) transport for sending logs to Sumo Logic via [HTTP Source](https://help.sumologic.com/docs/send-data/hosted-collectors/http-source/logs-metrics/upload-logs/).
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @loglayer/transport-sumo-logic serialize-error
13
+ # or
14
+ yarn add @loglayer/transport-sumo-logic serialize-error
15
+ # or
16
+ pnpm add @loglayer/transport-sumo-logic serialize-error
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { LogLayer } from "loglayer";
23
+ import { SumoLogicTransport } from "@loglayer/transport-sumo-logic";
24
+ import { serializeError } from "serialize-error";
25
+
26
+ const transport = new SumoLogicTransport({
27
+ url: "YOUR_SUMO_LOGIC_HTTP_SOURCE_URL",
28
+ });
29
+
30
+ const logger = new LogLayer({
31
+ errorSerializer: serializeError,
32
+ transport
33
+ });
34
+
35
+ // Basic logging
36
+ logger.info("Hello from LogLayer!");
37
+ ```
38
+
39
+ ## Documentation
40
+
41
+ For more details, visit [https://loglayer.dev/transports/sumo-logic](https://loglayer.dev/transports/sumo-logic)
package/dist/index.cjs ADDED
@@ -0,0 +1,137 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/SumoLogicTransport.ts
2
+ var _transport = require('@loglayer/transport');
3
+ var MAX_PAYLOAD_SIZE = 1e6;
4
+ var SumoLogicTransport = class extends _transport.LoggerlessTransport {
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ constructor(config) {
17
+ super(config);
18
+ this.url = config.url;
19
+ this.useCompression = _nullishCoalesce(config.useCompression, () => ( true));
20
+ this.sourceCategory = config.sourceCategory;
21
+ this.sourceName = config.sourceName;
22
+ this.sourceHost = config.sourceHost;
23
+ this.fields = _nullishCoalesce(config.fields, () => ( {}));
24
+ this.headers = _nullishCoalesce(config.headers, () => ( {}));
25
+ this.maxRetries = _nullishCoalesce(_optionalChain([config, 'access', _ => _.retryConfig, 'optionalAccess', _2 => _2.maxRetries]), () => ( 3));
26
+ this.initialRetryMs = _nullishCoalesce(_optionalChain([config, 'access', _3 => _3.retryConfig, 'optionalAccess', _4 => _4.initialRetryMs]), () => ( 1e3));
27
+ this.onError = config.onError;
28
+ this.messageField = _nullishCoalesce(config.messageField, () => ( "message"));
29
+ }
30
+ /**
31
+ * Compresses data using gzip compression.
32
+ */
33
+ async compressData(data) {
34
+ const stream = new CompressionStream("gzip");
35
+ const writer = stream.writable.getWriter();
36
+ const textEncoder = new TextEncoder();
37
+ const chunks = [];
38
+ await writer.write(textEncoder.encode(data));
39
+ await writer.close();
40
+ const reader = stream.readable.getReader();
41
+ while (true) {
42
+ const { value, done } = await reader.read();
43
+ if (done) break;
44
+ chunks.push(value);
45
+ }
46
+ const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
47
+ const result = new Uint8Array(totalLength);
48
+ let offset = 0;
49
+ for (const chunk of chunks) {
50
+ result.set(chunk, offset);
51
+ offset += chunk.length;
52
+ }
53
+ return result;
54
+ }
55
+ /**
56
+ * Handles errors by calling the onError callback if defined
57
+ */
58
+ handleError(error) {
59
+ if (this.onError) {
60
+ this.onError(error);
61
+ }
62
+ }
63
+ /**
64
+ * Sends logs to SumoLogic with retry logic, compression, and size validation.
65
+ */
66
+ async sendToSumoLogic(payload, retryCount = 0) {
67
+ try {
68
+ const rawSize = new TextEncoder().encode(payload).length;
69
+ if (rawSize > MAX_PAYLOAD_SIZE) {
70
+ const error = `Payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${rawSize} bytes`;
71
+ this.handleError(error);
72
+ return;
73
+ }
74
+ let compressedPayload;
75
+ if (this.useCompression) {
76
+ compressedPayload = await this.compressData(payload);
77
+ if (compressedPayload.length > MAX_PAYLOAD_SIZE) {
78
+ const error = `Compressed payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${compressedPayload.length} bytes`;
79
+ this.handleError(error);
80
+ return;
81
+ }
82
+ }
83
+ const headers = {
84
+ ...this.headers,
85
+ "Content-Type": "application/json"
86
+ };
87
+ if (this.sourceCategory) {
88
+ headers["X-Sumo-Category"] = this.sourceCategory;
89
+ }
90
+ if (this.sourceName) {
91
+ headers["X-Sumo-Name"] = this.sourceName;
92
+ }
93
+ if (this.sourceHost) {
94
+ headers["X-Sumo-Host"] = this.sourceHost;
95
+ }
96
+ if (this.useCompression) {
97
+ headers["Content-Encoding"] = "gzip";
98
+ }
99
+ if (Object.keys(this.fields).length > 0) {
100
+ headers["X-Sumo-Fields"] = Object.entries(this.fields).map(([key, value]) => `${key}=${value}`).join(",");
101
+ }
102
+ const response = await fetch(this.url, {
103
+ method: "POST",
104
+ headers,
105
+ body: this.useCompression ? compressedPayload : payload
106
+ });
107
+ if (!response.ok) {
108
+ throw new Error(`HTTP error! status: ${response.status}`);
109
+ }
110
+ } catch (error) {
111
+ if (retryCount < this.maxRetries) {
112
+ const delay = this.initialRetryMs * 2 ** retryCount;
113
+ await new Promise((resolve) => setTimeout(resolve, delay));
114
+ return this.sendToSumoLogic(payload, retryCount + 1);
115
+ }
116
+ this.handleError(error instanceof Error ? error : String(error));
117
+ }
118
+ }
119
+ shipToLogger({ logLevel, messages, data, hasData }) {
120
+ const stringMessages = messages.filter((msg) => typeof msg === "string");
121
+ const message = stringMessages.join(" ");
122
+ const payload = {
123
+ severity: logLevel,
124
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
125
+ ...data && hasData ? data : {}
126
+ };
127
+ if (message) {
128
+ payload[this.messageField] = message;
129
+ }
130
+ this.sendToSumoLogic(JSON.stringify(payload));
131
+ return messages;
132
+ }
133
+ };
134
+
135
+
136
+ exports.SumoLogicTransport = SumoLogicTransport;
137
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/loglayer/loglayer/packages/transports/sumo-logic/dist/index.cjs","../src/SumoLogicTransport.ts"],"names":[],"mappings":"AAAA;ACAA,gDAAkG;AA0DlG,IAAM,iBAAA,EAAmB,GAAA;AAElB,IAAM,mBAAA,EAAN,MAAA,QAAiC,+BAAoB;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,WAAA,CAAY,MAAA,EAAkC;AAC5C,IAAA,KAAA,CAAM,MAAM,CAAA;AACZ,IAAA,IAAA,CAAK,IAAA,EAAM,MAAA,CAAO,GAAA;AAClB,IAAA,IAAA,CAAK,eAAA,mBAAiB,MAAA,CAAO,cAAA,UAAkB,MAAA;AAC/C,IAAA,IAAA,CAAK,eAAA,EAAiB,MAAA,CAAO,cAAA;AAC7B,IAAA,IAAA,CAAK,WAAA,EAAa,MAAA,CAAO,UAAA;AACzB,IAAA,IAAA,CAAK,WAAA,EAAa,MAAA,CAAO,UAAA;AACzB,IAAA,IAAA,CAAK,OAAA,mBAAS,MAAA,CAAO,MAAA,UAAU,CAAC,GAAA;AAChC,IAAA,IAAA,CAAK,QAAA,mBAAU,MAAA,CAAO,OAAA,UAAW,CAAC,GAAA;AAClC,IAAA,IAAA,CAAK,WAAA,mCAAa,MAAA,mBAAO,WAAA,6BAAa,YAAA,UAAc,GAAA;AACpD,IAAA,IAAA,CAAK,eAAA,mCAAiB,MAAA,qBAAO,WAAA,6BAAa,gBAAA,UAAkB,KAAA;AAC5D,IAAA,IAAA,CAAK,QAAA,EAAU,MAAA,CAAO,OAAA;AACtB,IAAA,IAAA,CAAK,aAAA,mBAA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K,cAAA;AAAA,MACpC;AACA,MAAA,GAAA,CAAI,IAAA,CAAK,UAAA,EAAY;AACnB,QAAA,OAAA,CAAQ,aAAa,EAAA,EAAI,IAAA,CAAK,UAAA;AAAA,MAChC;AACA,MAAA,GAAA,CAAI,IAAA,CAAK,UAAA,EAAY;AACnB,QAAA,OAAA,CAAQ,aAAa,EAAA,EAAI,IAAA,CAAK,UAAA;AAAA,MAChC;AACA,MAAA,GAAA,CAAI,IAAA,CAAK,cAAA,EAAgB;AACvB,QAAA,OAAA,CAAQ,kBAAkB,EAAA,EAAI,MAAA;AAAA,MAChC;AACA,MAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAS,CAAA,EAAG;AACvC,QAAA,OAAA,CAAQ,eAAe,EAAA,EAAI,MAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAA,CAClD,GAAA,CAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,EAAA,GAAM,CAAA,EAAA;AAE3B,MAAA;AAEwC,MAAA;AAC9B,QAAA;AACR,QAAA;AACgD,QAAA;AACjD,MAAA;AAEiB,MAAA;AACwC,QAAA;AAC1D,MAAA;AACc,IAAA;AACoB,MAAA;AACS,QAAA;AACgB,QAAA;AACN,QAAA;AACrD,MAAA;AAC+D,MAAA;AACjE,IAAA;AACF,EAAA;AAEoF,EAAA;AAEX,IAAA;AAChC,IAAA;AAEvB,IAAA;AACJ,MAAA;AACwB,MAAA;AACJ,MAAA;AAChC,IAAA;AAEa,IAAA;AACkB,MAAA;AAC/B,IAAA;AAE4C,IAAA;AAErC,IAAA;AACT,EAAA;AACF;ADhFsF;AACA;AACA","file":"/home/runner/work/loglayer/loglayer/packages/transports/sumo-logic/dist/index.cjs","sourcesContent":[null,"import { type LogLayerTransportParams, LoggerlessTransport, type LoggerlessTransportConfig } from \"@loglayer/transport\";\n\ninterface SumoLogicTransportConfig extends LoggerlessTransportConfig {\n /**\n * The URL of your HTTP Source endpoint\n */\n url: string;\n\n /**\n * Whether to use gzip compression (defaults to true)\n */\n useCompression?: boolean;\n\n /**\n * Source category to assign to the logs (optional)\n */\n sourceCategory?: string;\n\n /**\n * Source name to assign to the logs (optional)\n */\n sourceName?: string;\n\n /**\n * Source host to assign to the logs (optional)\n */\n sourceHost?: string;\n\n /**\n * Fields to be added as X-Sumo-Fields header (optional)\n * Will be formatted as a comma-separated list of key=value pairs\n */\n fields?: Record<string, string>;\n\n /**\n * Custom headers to be added to the request (optional)\n */\n headers?: Record<string, string>;\n\n /**\n * Retry configuration (optional)\n */\n retryConfig?: {\n maxRetries?: number;\n initialRetryMs?: number;\n };\n\n /**\n * Optional callback for error handling\n */\n onError?: (error: Error | string) => void;\n\n /**\n * Field name to use for the message (defaults to \"message\")\n */\n messageField?: string;\n}\n\nconst MAX_PAYLOAD_SIZE = 1000000; // 1MB limit as per SumoLogic docs\n\nexport class SumoLogicTransport extends LoggerlessTransport {\n private url: string;\n private useCompression: boolean;\n private sourceCategory?: string;\n private sourceName?: string;\n private sourceHost?: string;\n private fields: Record<string, string>;\n private headers: Record<string, string>;\n private maxRetries: number;\n private initialRetryMs: number;\n private onError?: (error: Error | string) => void;\n private messageField: string;\n\n constructor(config: SumoLogicTransportConfig) {\n super(config);\n this.url = config.url;\n this.useCompression = config.useCompression ?? true;\n this.sourceCategory = config.sourceCategory;\n this.sourceName = config.sourceName;\n this.sourceHost = config.sourceHost;\n this.fields = config.fields ?? {};\n this.headers = config.headers ?? {};\n this.maxRetries = config.retryConfig?.maxRetries ?? 3;\n this.initialRetryMs = config.retryConfig?.initialRetryMs ?? 1000;\n this.onError = config.onError;\n this.messageField = config.messageField ?? \"message\";\n }\n\n /**\n * Compresses data using gzip compression.\n */\n private async compressData(data: string): Promise<Uint8Array> {\n const stream = new CompressionStream(\"gzip\");\n const writer = stream.writable.getWriter();\n const textEncoder = new TextEncoder();\n const chunks: Uint8Array[] = [];\n\n await writer.write(textEncoder.encode(data));\n await writer.close();\n\n const reader = stream.readable.getReader();\n\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n chunks.push(value);\n }\n\n const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n\n return result;\n }\n\n /**\n * Handles errors by calling the onError callback if defined\n */\n private handleError(error: Error | string): void {\n if (this.onError) {\n this.onError(error);\n }\n }\n\n /**\n * Sends logs to SumoLogic with retry logic, compression, and size validation.\n */\n private async sendToSumoLogic(payload: string, retryCount = 0): Promise<void> {\n try {\n // Check payload size before compression\n const rawSize = new TextEncoder().encode(payload).length;\n if (rawSize > MAX_PAYLOAD_SIZE) {\n const error = `Payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${rawSize} bytes`;\n this.handleError(error);\n return;\n }\n\n let compressedPayload: Uint8Array | undefined;\n if (this.useCompression) {\n compressedPayload = await this.compressData(payload);\n if (compressedPayload.length > MAX_PAYLOAD_SIZE) {\n const error = `Compressed payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${compressedPayload.length} bytes`;\n this.handleError(error);\n return;\n }\n }\n\n const headers: Record<string, string> = {\n ...this.headers,\n \"Content-Type\": \"application/json\",\n };\n\n if (this.sourceCategory) {\n headers[\"X-Sumo-Category\"] = this.sourceCategory;\n }\n if (this.sourceName) {\n headers[\"X-Sumo-Name\"] = this.sourceName;\n }\n if (this.sourceHost) {\n headers[\"X-Sumo-Host\"] = this.sourceHost;\n }\n if (this.useCompression) {\n headers[\"Content-Encoding\"] = \"gzip\";\n }\n if (Object.keys(this.fields).length > 0) {\n headers[\"X-Sumo-Fields\"] = Object.entries(this.fields)\n .map(([key, value]) => `${key}=${value}`)\n .join(\",\");\n }\n\n const response = (await fetch(this.url, {\n method: \"POST\",\n headers,\n body: this.useCompression ? compressedPayload : payload,\n })) as Response;\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch (error) {\n if (retryCount < this.maxRetries) {\n const delay = this.initialRetryMs * 2 ** retryCount;\n await new Promise((resolve) => setTimeout(resolve, delay));\n return this.sendToSumoLogic(payload, retryCount + 1);\n }\n this.handleError(error instanceof Error ? error : String(error));\n }\n }\n\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[] {\n // Only use the string messages for content\n const stringMessages = messages.filter((msg) => typeof msg === \"string\");\n const message = stringMessages.join(\" \");\n\n const payload = {\n severity: logLevel,\n timestamp: new Date().toISOString(),\n ...(data && hasData ? data : {}),\n };\n\n if (message) {\n payload[this.messageField] = message;\n }\n\n this.sendToSumoLogic(JSON.stringify(payload));\n\n return messages;\n }\n}\n"]}
@@ -0,0 +1,77 @@
1
+ import { LoggerlessTransport, LogLayerTransportParams, LoggerlessTransportConfig } from '@loglayer/transport';
2
+
3
+ interface SumoLogicTransportConfig extends LoggerlessTransportConfig {
4
+ /**
5
+ * The URL of your HTTP Source endpoint
6
+ */
7
+ url: string;
8
+ /**
9
+ * Whether to use gzip compression (defaults to true)
10
+ */
11
+ useCompression?: boolean;
12
+ /**
13
+ * Source category to assign to the logs (optional)
14
+ */
15
+ sourceCategory?: string;
16
+ /**
17
+ * Source name to assign to the logs (optional)
18
+ */
19
+ sourceName?: string;
20
+ /**
21
+ * Source host to assign to the logs (optional)
22
+ */
23
+ sourceHost?: string;
24
+ /**
25
+ * Fields to be added as X-Sumo-Fields header (optional)
26
+ * Will be formatted as a comma-separated list of key=value pairs
27
+ */
28
+ fields?: Record<string, string>;
29
+ /**
30
+ * Custom headers to be added to the request (optional)
31
+ */
32
+ headers?: Record<string, string>;
33
+ /**
34
+ * Retry configuration (optional)
35
+ */
36
+ retryConfig?: {
37
+ maxRetries?: number;
38
+ initialRetryMs?: number;
39
+ };
40
+ /**
41
+ * Optional callback for error handling
42
+ */
43
+ onError?: (error: Error | string) => void;
44
+ /**
45
+ * Field name to use for the message (defaults to "message")
46
+ */
47
+ messageField?: string;
48
+ }
49
+ declare class SumoLogicTransport extends LoggerlessTransport {
50
+ private url;
51
+ private useCompression;
52
+ private sourceCategory?;
53
+ private sourceName?;
54
+ private sourceHost?;
55
+ private fields;
56
+ private headers;
57
+ private maxRetries;
58
+ private initialRetryMs;
59
+ private onError?;
60
+ private messageField;
61
+ constructor(config: SumoLogicTransportConfig);
62
+ /**
63
+ * Compresses data using gzip compression.
64
+ */
65
+ private compressData;
66
+ /**
67
+ * Handles errors by calling the onError callback if defined
68
+ */
69
+ private handleError;
70
+ /**
71
+ * Sends logs to SumoLogic with retry logic, compression, and size validation.
72
+ */
73
+ private sendToSumoLogic;
74
+ shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
75
+ }
76
+
77
+ export { SumoLogicTransport };
@@ -0,0 +1,77 @@
1
+ import { LoggerlessTransport, LogLayerTransportParams, LoggerlessTransportConfig } from '@loglayer/transport';
2
+
3
+ interface SumoLogicTransportConfig extends LoggerlessTransportConfig {
4
+ /**
5
+ * The URL of your HTTP Source endpoint
6
+ */
7
+ url: string;
8
+ /**
9
+ * Whether to use gzip compression (defaults to true)
10
+ */
11
+ useCompression?: boolean;
12
+ /**
13
+ * Source category to assign to the logs (optional)
14
+ */
15
+ sourceCategory?: string;
16
+ /**
17
+ * Source name to assign to the logs (optional)
18
+ */
19
+ sourceName?: string;
20
+ /**
21
+ * Source host to assign to the logs (optional)
22
+ */
23
+ sourceHost?: string;
24
+ /**
25
+ * Fields to be added as X-Sumo-Fields header (optional)
26
+ * Will be formatted as a comma-separated list of key=value pairs
27
+ */
28
+ fields?: Record<string, string>;
29
+ /**
30
+ * Custom headers to be added to the request (optional)
31
+ */
32
+ headers?: Record<string, string>;
33
+ /**
34
+ * Retry configuration (optional)
35
+ */
36
+ retryConfig?: {
37
+ maxRetries?: number;
38
+ initialRetryMs?: number;
39
+ };
40
+ /**
41
+ * Optional callback for error handling
42
+ */
43
+ onError?: (error: Error | string) => void;
44
+ /**
45
+ * Field name to use for the message (defaults to "message")
46
+ */
47
+ messageField?: string;
48
+ }
49
+ declare class SumoLogicTransport extends LoggerlessTransport {
50
+ private url;
51
+ private useCompression;
52
+ private sourceCategory?;
53
+ private sourceName?;
54
+ private sourceHost?;
55
+ private fields;
56
+ private headers;
57
+ private maxRetries;
58
+ private initialRetryMs;
59
+ private onError?;
60
+ private messageField;
61
+ constructor(config: SumoLogicTransportConfig);
62
+ /**
63
+ * Compresses data using gzip compression.
64
+ */
65
+ private compressData;
66
+ /**
67
+ * Handles errors by calling the onError callback if defined
68
+ */
69
+ private handleError;
70
+ /**
71
+ * Sends logs to SumoLogic with retry logic, compression, and size validation.
72
+ */
73
+ private sendToSumoLogic;
74
+ shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
75
+ }
76
+
77
+ export { SumoLogicTransport };
package/dist/index.js ADDED
@@ -0,0 +1,137 @@
1
+ // src/SumoLogicTransport.ts
2
+ import { LoggerlessTransport } from "@loglayer/transport";
3
+ var MAX_PAYLOAD_SIZE = 1e6;
4
+ var SumoLogicTransport = class extends LoggerlessTransport {
5
+ url;
6
+ useCompression;
7
+ sourceCategory;
8
+ sourceName;
9
+ sourceHost;
10
+ fields;
11
+ headers;
12
+ maxRetries;
13
+ initialRetryMs;
14
+ onError;
15
+ messageField;
16
+ constructor(config) {
17
+ super(config);
18
+ this.url = config.url;
19
+ this.useCompression = config.useCompression ?? true;
20
+ this.sourceCategory = config.sourceCategory;
21
+ this.sourceName = config.sourceName;
22
+ this.sourceHost = config.sourceHost;
23
+ this.fields = config.fields ?? {};
24
+ this.headers = config.headers ?? {};
25
+ this.maxRetries = config.retryConfig?.maxRetries ?? 3;
26
+ this.initialRetryMs = config.retryConfig?.initialRetryMs ?? 1e3;
27
+ this.onError = config.onError;
28
+ this.messageField = config.messageField ?? "message";
29
+ }
30
+ /**
31
+ * Compresses data using gzip compression.
32
+ */
33
+ async compressData(data) {
34
+ const stream = new CompressionStream("gzip");
35
+ const writer = stream.writable.getWriter();
36
+ const textEncoder = new TextEncoder();
37
+ const chunks = [];
38
+ await writer.write(textEncoder.encode(data));
39
+ await writer.close();
40
+ const reader = stream.readable.getReader();
41
+ while (true) {
42
+ const { value, done } = await reader.read();
43
+ if (done) break;
44
+ chunks.push(value);
45
+ }
46
+ const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
47
+ const result = new Uint8Array(totalLength);
48
+ let offset = 0;
49
+ for (const chunk of chunks) {
50
+ result.set(chunk, offset);
51
+ offset += chunk.length;
52
+ }
53
+ return result;
54
+ }
55
+ /**
56
+ * Handles errors by calling the onError callback if defined
57
+ */
58
+ handleError(error) {
59
+ if (this.onError) {
60
+ this.onError(error);
61
+ }
62
+ }
63
+ /**
64
+ * Sends logs to SumoLogic with retry logic, compression, and size validation.
65
+ */
66
+ async sendToSumoLogic(payload, retryCount = 0) {
67
+ try {
68
+ const rawSize = new TextEncoder().encode(payload).length;
69
+ if (rawSize > MAX_PAYLOAD_SIZE) {
70
+ const error = `Payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${rawSize} bytes`;
71
+ this.handleError(error);
72
+ return;
73
+ }
74
+ let compressedPayload;
75
+ if (this.useCompression) {
76
+ compressedPayload = await this.compressData(payload);
77
+ if (compressedPayload.length > MAX_PAYLOAD_SIZE) {
78
+ const error = `Compressed payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${compressedPayload.length} bytes`;
79
+ this.handleError(error);
80
+ return;
81
+ }
82
+ }
83
+ const headers = {
84
+ ...this.headers,
85
+ "Content-Type": "application/json"
86
+ };
87
+ if (this.sourceCategory) {
88
+ headers["X-Sumo-Category"] = this.sourceCategory;
89
+ }
90
+ if (this.sourceName) {
91
+ headers["X-Sumo-Name"] = this.sourceName;
92
+ }
93
+ if (this.sourceHost) {
94
+ headers["X-Sumo-Host"] = this.sourceHost;
95
+ }
96
+ if (this.useCompression) {
97
+ headers["Content-Encoding"] = "gzip";
98
+ }
99
+ if (Object.keys(this.fields).length > 0) {
100
+ headers["X-Sumo-Fields"] = Object.entries(this.fields).map(([key, value]) => `${key}=${value}`).join(",");
101
+ }
102
+ const response = await fetch(this.url, {
103
+ method: "POST",
104
+ headers,
105
+ body: this.useCompression ? compressedPayload : payload
106
+ });
107
+ if (!response.ok) {
108
+ throw new Error(`HTTP error! status: ${response.status}`);
109
+ }
110
+ } catch (error) {
111
+ if (retryCount < this.maxRetries) {
112
+ const delay = this.initialRetryMs * 2 ** retryCount;
113
+ await new Promise((resolve) => setTimeout(resolve, delay));
114
+ return this.sendToSumoLogic(payload, retryCount + 1);
115
+ }
116
+ this.handleError(error instanceof Error ? error : String(error));
117
+ }
118
+ }
119
+ shipToLogger({ logLevel, messages, data, hasData }) {
120
+ const stringMessages = messages.filter((msg) => typeof msg === "string");
121
+ const message = stringMessages.join(" ");
122
+ const payload = {
123
+ severity: logLevel,
124
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
125
+ ...data && hasData ? data : {}
126
+ };
127
+ if (message) {
128
+ payload[this.messageField] = message;
129
+ }
130
+ this.sendToSumoLogic(JSON.stringify(payload));
131
+ return messages;
132
+ }
133
+ };
134
+ export {
135
+ SumoLogicTransport
136
+ };
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SumoLogicTransport.ts"],"sourcesContent":["import { type LogLayerTransportParams, LoggerlessTransport, type LoggerlessTransportConfig } from \"@loglayer/transport\";\n\ninterface SumoLogicTransportConfig extends LoggerlessTransportConfig {\n /**\n * The URL of your HTTP Source endpoint\n */\n url: string;\n\n /**\n * Whether to use gzip compression (defaults to true)\n */\n useCompression?: boolean;\n\n /**\n * Source category to assign to the logs (optional)\n */\n sourceCategory?: string;\n\n /**\n * Source name to assign to the logs (optional)\n */\n sourceName?: string;\n\n /**\n * Source host to assign to the logs (optional)\n */\n sourceHost?: string;\n\n /**\n * Fields to be added as X-Sumo-Fields header (optional)\n * Will be formatted as a comma-separated list of key=value pairs\n */\n fields?: Record<string, string>;\n\n /**\n * Custom headers to be added to the request (optional)\n */\n headers?: Record<string, string>;\n\n /**\n * Retry configuration (optional)\n */\n retryConfig?: {\n maxRetries?: number;\n initialRetryMs?: number;\n };\n\n /**\n * Optional callback for error handling\n */\n onError?: (error: Error | string) => void;\n\n /**\n * Field name to use for the message (defaults to \"message\")\n */\n messageField?: string;\n}\n\nconst MAX_PAYLOAD_SIZE = 1000000; // 1MB limit as per SumoLogic docs\n\nexport class SumoLogicTransport extends LoggerlessTransport {\n private url: string;\n private useCompression: boolean;\n private sourceCategory?: string;\n private sourceName?: string;\n private sourceHost?: string;\n private fields: Record<string, string>;\n private headers: Record<string, string>;\n private maxRetries: number;\n private initialRetryMs: number;\n private onError?: (error: Error | string) => void;\n private messageField: string;\n\n constructor(config: SumoLogicTransportConfig) {\n super(config);\n this.url = config.url;\n this.useCompression = config.useCompression ?? true;\n this.sourceCategory = config.sourceCategory;\n this.sourceName = config.sourceName;\n this.sourceHost = config.sourceHost;\n this.fields = config.fields ?? {};\n this.headers = config.headers ?? {};\n this.maxRetries = config.retryConfig?.maxRetries ?? 3;\n this.initialRetryMs = config.retryConfig?.initialRetryMs ?? 1000;\n this.onError = config.onError;\n this.messageField = config.messageField ?? \"message\";\n }\n\n /**\n * Compresses data using gzip compression.\n */\n private async compressData(data: string): Promise<Uint8Array> {\n const stream = new CompressionStream(\"gzip\");\n const writer = stream.writable.getWriter();\n const textEncoder = new TextEncoder();\n const chunks: Uint8Array[] = [];\n\n await writer.write(textEncoder.encode(data));\n await writer.close();\n\n const reader = stream.readable.getReader();\n\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n chunks.push(value);\n }\n\n const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n\n return result;\n }\n\n /**\n * Handles errors by calling the onError callback if defined\n */\n private handleError(error: Error | string): void {\n if (this.onError) {\n this.onError(error);\n }\n }\n\n /**\n * Sends logs to SumoLogic with retry logic, compression, and size validation.\n */\n private async sendToSumoLogic(payload: string, retryCount = 0): Promise<void> {\n try {\n // Check payload size before compression\n const rawSize = new TextEncoder().encode(payload).length;\n if (rawSize > MAX_PAYLOAD_SIZE) {\n const error = `Payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${rawSize} bytes`;\n this.handleError(error);\n return;\n }\n\n let compressedPayload: Uint8Array | undefined;\n if (this.useCompression) {\n compressedPayload = await this.compressData(payload);\n if (compressedPayload.length > MAX_PAYLOAD_SIZE) {\n const error = `Compressed payload size exceeds maximum of ${MAX_PAYLOAD_SIZE} bytes. Size: ${compressedPayload.length} bytes`;\n this.handleError(error);\n return;\n }\n }\n\n const headers: Record<string, string> = {\n ...this.headers,\n \"Content-Type\": \"application/json\",\n };\n\n if (this.sourceCategory) {\n headers[\"X-Sumo-Category\"] = this.sourceCategory;\n }\n if (this.sourceName) {\n headers[\"X-Sumo-Name\"] = this.sourceName;\n }\n if (this.sourceHost) {\n headers[\"X-Sumo-Host\"] = this.sourceHost;\n }\n if (this.useCompression) {\n headers[\"Content-Encoding\"] = \"gzip\";\n }\n if (Object.keys(this.fields).length > 0) {\n headers[\"X-Sumo-Fields\"] = Object.entries(this.fields)\n .map(([key, value]) => `${key}=${value}`)\n .join(\",\");\n }\n\n const response = (await fetch(this.url, {\n method: \"POST\",\n headers,\n body: this.useCompression ? compressedPayload : payload,\n })) as Response;\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch (error) {\n if (retryCount < this.maxRetries) {\n const delay = this.initialRetryMs * 2 ** retryCount;\n await new Promise((resolve) => setTimeout(resolve, delay));\n return this.sendToSumoLogic(payload, retryCount + 1);\n }\n this.handleError(error instanceof Error ? error : String(error));\n }\n }\n\n shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[] {\n // Only use the string messages for content\n const stringMessages = messages.filter((msg) => typeof msg === \"string\");\n const message = stringMessages.join(\" \");\n\n const payload = {\n severity: logLevel,\n timestamp: new Date().toISOString(),\n ...(data && hasData ? data : {}),\n };\n\n if (message) {\n payload[this.messageField] = message;\n }\n\n this.sendToSumoLogic(JSON.stringify(payload));\n\n return messages;\n }\n}\n"],"mappings":";AAAA,SAAuC,2BAA2D;AA0DlG,IAAM,mBAAmB;AAElB,IAAM,qBAAN,cAAiC,oBAAoB;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,QAAkC;AAC5C,UAAM,MAAM;AACZ,SAAK,MAAM,OAAO;AAClB,SAAK,iBAAiB,OAAO,kBAAkB;AAC/C,SAAK,iBAAiB,OAAO;AAC7B,SAAK,aAAa,OAAO;AACzB,SAAK,aAAa,OAAO;AACzB,SAAK,SAAS,OAAO,UAAU,CAAC;AAChC,SAAK,UAAU,OAAO,WAAW,CAAC;AAClC,SAAK,aAAa,OAAO,aAAa,cAAc;AACpD,SAAK,iBAAiB,OAAO,aAAa,kBAAkB;AAC5D,SAAK,UAAU,OAAO;AACtB,SAAK,eAAe,OAAO,gBAAgB;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,aAAa,MAAmC;AAC5D,UAAM,SAAS,IAAI,kBAAkB,MAAM;AAC3C,UAAM,SAAS,OAAO,SAAS,UAAU;AACzC,UAAM,cAAc,IAAI,YAAY;AACpC,UAAM,SAAuB,CAAC;AAE9B,UAAM,OAAO,MAAM,YAAY,OAAO,IAAI,CAAC;AAC3C,UAAM,OAAO,MAAM;AAEnB,UAAM,SAAS,OAAO,SAAS,UAAU;AAEzC,WAAO,MAAM;AACX,YAAM,EAAE,OAAO,KAAK,IAAI,MAAM,OAAO,KAAK;AAC1C,UAAI,KAAM;AACV,aAAO,KAAK,KAAK;AAAA,IACnB;AAEA,UA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gBAAQ,eAAe,IAAI,OAAO,QAAQ,KAAK,MAAM,EAClD,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,EACvC,KAAK,GAAG;AAAA,MACb;AAEA,YAAM,WAAY,MAAM,MAAM,KAAK,KAAK;AAAA,QACtC,QAAQ;AAAA,QACR;AAAA,QACA,MAAM,KAAK,iBAAiB,oBAAoB;AAAA,MAClD,CAAC;AAED,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAAA,MAC1D;AAAA,IACF,SAAS,OAAO;AACd,UAAI,aAAa,KAAK,YAAY;AAChC,cAAM,QAAQ,KAAK,iBAAiB,KAAK;AACzC,cAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,CAAC;AACzD,eAAO,KAAK,gBAAgB,SAAS,aAAa,CAAC;AAAA,MACrD;AACA,WAAK,YAAY,iBAAiB,QAAQ,QAAQ,OAAO,KAAK,CAAC;AAAA,IACjE;AAAA,EACF;AAAA,EAEA,aAAa,EAAE,UAAU,UAAU,MAAM,QAAQ,GAAmC;AAElF,UAAM,iBAAiB,SAAS,OAAO,CAAC,QAAQ,OAAO,QAAQ,QAAQ;AACvE,UAAM,UAAU,eAAe,KAAK,GAAG;AAEvC,UAAM,UAAU;AAAA,MACd,UAAU;AAAA,MACV,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,GAAI,QAAQ,UAAU,OAAO,CAAC;AAAA,IAChC;AAEA,QAAI,SAAS;AACX,cAAQ,KAAK,YAAY,IAAI;AAAA,IAC/B;AAEA,SAAK,gBAAgB,KAAK,UAAU,OAAO,CAAC;AAE5C,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@loglayer/transport-sumo-logic",
3
+ "description": "Sumo Logic transport for LogLayer.",
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "exports": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "types": "./dist/index.d.ts",
19
+ "license": "MIT",
20
+ "repository": "loglayer/loglayer.git",
21
+ "author": "Theo Gravity <theo@suteki.nu>",
22
+ "keywords": [
23
+ "logging",
24
+ "log",
25
+ "loglayer",
26
+ "sumologic",
27
+ "transport"
28
+ ],
29
+ "dependencies": {
30
+ "@loglayer/transport": "1.1.5"
31
+ },
32
+ "devDependencies": {
33
+ "hash-runner": "2.0.1",
34
+ "@types/node": "22.10.4",
35
+ "serialize-error": "11.0.3",
36
+ "tsup": "8.3.5",
37
+ "typescript": "5.7.2",
38
+ "vitest": "2.1.8",
39
+ "tsx": "4.19.2",
40
+ "@internal/tsconfig": "1.0.0",
41
+ "loglayer": "5.1.1"
42
+ },
43
+ "bugs": "https://github.com/loglayer/loglayer/issues",
44
+ "engines": {
45
+ "node": ">=18"
46
+ },
47
+ "files": [
48
+ "dist"
49
+ ],
50
+ "homepage": "https://loglayer.dev",
51
+ "scripts": {
52
+ "build": "tsup src/index.ts",
53
+ "test": "vitest --run",
54
+ "build:dev": "hash-runner",
55
+ "clean": "rm -rf .turbo node_modules dist",
56
+ "lint": "biome check --write --unsafe src && biome format src --write && biome lint src --fix",
57
+ "verify-types": "tsc --noEmit",
58
+ "livetest": "tsx src/__tests__/livetest.ts"
59
+ }
60
+ }