unnbound-logger-sdk 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 Unnbound Team
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,312 @@
1
+ # Unnbound Logger
2
+
3
+ A structured logging library with TypeScript support built on Pino. Provides consistent, well-typed logging across different operational contexts. All logs are output in JSON format for better machine readability and parsing.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install unnbound-logger
9
+ ```
10
+
11
+ ## Basic Usage
12
+
13
+ ```typescript
14
+ import { UnnboundLogger } from 'unnbound-logger';
15
+
16
+ // Create a new logger instance
17
+ const logger = new UnnboundLogger();
18
+
19
+ // Log with string messages
20
+ logger.info('Application started');
21
+ logger.warn('Resource usage high');
22
+ logger.error(new Error('Database connection failed'));
23
+ logger.debug('Debug information');
24
+
25
+ // Log with object messages
26
+ logger.info({
27
+ event: 'user_login',
28
+ userId: '123',
29
+ timestamp: new Date().toISOString()
30
+ });
31
+
32
+ // Log with both string message and metadata
33
+ logger.info('User logged in', {
34
+ userId: '123',
35
+ timestamp: new Date().toISOString()
36
+ });
37
+
38
+ // Log with object message and additional metadata
39
+ logger.info(
40
+ { event: 'user_login', userId: '123' },
41
+ { timestamp: new Date().toISOString() }
42
+ );
43
+ ```
44
+
45
+ ## Log Format
46
+
47
+ All logs follow a standardized format:
48
+
49
+ ```typescript
50
+ interface Log<T extends LogType = 'general'> {
51
+ level: LogLevel; // "info" | "debug" | "error" | "warn"
52
+ type: T; // "general" | "httpRequest" | "httpResponse" | "sftpTransaction" | "dbQueryTransaction"
53
+ message: string;
54
+ traceId: string;
55
+ requestId: string;
56
+ error?: SerializableError; // Only present for Error objects
57
+ }
58
+
59
+ interface LogTransaction<T extends LogType> extends Log<T> {
60
+ duration: number; // Duration in milliseconds
61
+ }
62
+ ```
63
+
64
+ ## HTTP Request/Response Logging
65
+
66
+ ```typescript
67
+ import { UnnboundLogger } from 'unnbound-logger';
68
+ import express from 'express';
69
+
70
+ const app = express();
71
+ const logger = new UnnboundLogger();
72
+
73
+ // Middleware to log requests
74
+ app.use((req, res, next) => {
75
+ // Log the request and get the request ID
76
+ const requestId = logger.httpRequest(req, {
77
+ startTime: Date.now()
78
+ });
79
+
80
+ // Store the request ID in res.locals for later use
81
+ res.locals.requestId = requestId;
82
+
83
+ // Add response listener to log the response
84
+ res.on('finish', () => {
85
+ logger.httpResponse(res, req, {
86
+ requestId,
87
+ startTime: res.locals.startTime
88
+ });
89
+ });
90
+
91
+ next();
92
+ });
93
+
94
+ // Example route
95
+ app.post('/api/users', (req, res) => {
96
+ // Your route handler code here
97
+ res.status(201).json({ id: '123', status: 'created' });
98
+ });
99
+ ```
100
+
101
+ The logger automatically captures:
102
+ - Request method, URL, body, and headers (filtered for security)
103
+ - Response status code, body, and headers (filtered for security)
104
+ - Request duration
105
+ - Trace ID and request ID for correlation
106
+
107
+ ## SFTP Transaction Logging
108
+
109
+ For logging SFTP operations:
110
+
111
+ ```typescript
112
+ import { UnnboundLogger } from 'unnbound-logger';
113
+
114
+ const logger = new UnnboundLogger();
115
+
116
+ // Log an SFTP upload
117
+ logger.sftpTransaction({
118
+ host: 'sftp.example.com',
119
+ username: 'ftpuser',
120
+ operation: 'upload',
121
+ path: '/uploads/file.txt',
122
+ status: 'success',
123
+ bytesTransferred: 1024
124
+ });
125
+
126
+ // Log an SFTP download with failure
127
+ logger.sftpTransaction({
128
+ host: 'sftp.example.com',
129
+ username: 'ftpuser',
130
+ operation: 'download',
131
+ path: '/downloads/file.txt',
132
+ status: 'failure'
133
+ }, {
134
+ startTime: Date.now() - 5000 // Started 5 seconds ago
135
+ });
136
+ ```
137
+
138
+ ## Database Query Transaction Logging
139
+
140
+ For logging database operations:
141
+
142
+ ```typescript
143
+ import { UnnboundLogger } from 'unnbound-logger';
144
+
145
+ const logger = new UnnboundLogger();
146
+
147
+ // Log a successful database query
148
+ logger.dbQueryTransaction({
149
+ instance: 'localhost:5432',
150
+ vendor: 'postgres',
151
+ query: 'SELECT * FROM users WHERE active = true',
152
+ status: 'success',
153
+ rowsReturned: 150
154
+ });
155
+
156
+ // Log a failed database operation
157
+ logger.dbQueryTransaction({
158
+ instance: 'prod-db-cluster',
159
+ vendor: 'mysql',
160
+ query: 'UPDATE users SET last_login = NOW()',
161
+ status: 'failure',
162
+ rowsAffected: 0
163
+ }, {
164
+ duration: 2500 // Operation took 2.5 seconds
165
+ });
166
+ ```
167
+
168
+ ## Middleware Usage
169
+
170
+ ### Express Trace Middleware
171
+
172
+ The library provides a trace middleware for Express applications that automatically logs HTTP requests and maintains trace context:
173
+
174
+ ```typescript
175
+ import { UnnboundLogger } from 'unnbound-logger';
176
+ import express from 'express';
177
+
178
+ const app = express();
179
+ const logger = new UnnboundLogger();
180
+
181
+ // Apply the trace middleware globally
182
+ app.use(logger.traceMiddleware);
183
+
184
+ ```
185
+
186
+ The trace middleware automatically:
187
+ - Logs incoming requests with method, URL, headers, and body
188
+ - Generates and maintains trace IDs across the request lifecycle
189
+ - Measures request duration
190
+ - Handles errors and logs them appropriately
191
+
192
+ ### Axios Trace Middleware
193
+
194
+ For logging outgoing HTTP requests made with Axios:
195
+
196
+ ```typescript
197
+ import { UnnboundLogger } from 'unnbound-logger';
198
+ import axios from 'axios';
199
+
200
+ const logger = new UnnboundLogger();
201
+
202
+ // Add Axios trace middleware
203
+ axios.interceptors.request.use(
204
+ logger.axiosTraceMiddleware.onFulfilled,
205
+ logger.axiosTraceMiddleware.onRejected
206
+ );
207
+
208
+ // All requests made with axios will be automatically logged
209
+ axios.get('https://api.example.com/data');
210
+ ```
211
+
212
+ The Axios trace middleware:
213
+ - Logs outgoing requests with method, URL, headers, and body
214
+ - Maintains trace context across requests
215
+ - Handles errors and logs them appropriately
216
+ - Supports request/response filtering through configuration
217
+
218
+ ## Function Tracing with withTrace
219
+
220
+ The `withTrace` higher-order function allows you to wrap any function with automatic trace context. This is particularly useful for maintaining consistent trace IDs across async operations and distributed systems:
221
+
222
+ ```typescript
223
+ import { UnnboundLogger } from 'unnbound-logger';
224
+ import { withTrace } from 'unnbound-logger/utils/with-trace';
225
+ import { traceContext } from 'unnbound-logger/utils/trace-context';
226
+
227
+ const logger = new UnnboundLogger();
228
+
229
+ // Example: Wrapping a function with trace context
230
+ const operation = (value: number) => {
231
+ const traceId = traceContext.getTraceId();
232
+ logger.info('Processing value', { value, traceId });
233
+ return value * 2;
234
+ };
235
+
236
+ // Wrap the function with trace context
237
+ const tracedOperation = withTrace(operation);
238
+
239
+ // Execute the function
240
+ const result = tracedOperation(21); // Returns 42
241
+ ```
242
+
243
+ ### Using Custom Trace IDs
244
+
245
+ You can provide your own trace ID when wrapping a function:
246
+
247
+ ```typescript
248
+ const customTraceId = 'custom-trace-123';
249
+ const tracedOperation = withTrace(operation, customTraceId);
250
+ ```
251
+
252
+ ### Async Operations
253
+
254
+ The trace context is maintained across async operations:
255
+
256
+ ```typescript
257
+ const asyncOperation = async (value: number) => {
258
+ const traceId1 = traceContext.getTraceId();
259
+ logger.info('First step', { traceId: traceId1 });
260
+
261
+ await someAsyncWork();
262
+
263
+ const traceId2 = traceContext.getTraceId();
264
+ logger.info('Second step', { traceId: traceId2 });
265
+ // traceId1 and traceId2 will be the same
266
+ };
267
+
268
+ const tracedOperation = withTrace(asyncOperation);
269
+ await tracedOperation(42);
270
+ ```
271
+
272
+ ### Benefits
273
+
274
+ - Automatic trace ID generation
275
+ - Consistent trace context across async operations
276
+ - Support for custom trace IDs
277
+ - Type-safe implementation
278
+ - Works with both sync and async functions
279
+ - Maintains separate trace contexts for different operations
280
+
281
+ > **Note:** When using `UnnboundLogger`, you don't need to manually call `traceContext.getTraceId()` in your logging calls. The logger automatically includes the current trace ID in all log entries. The example above shows manual trace ID retrieval for demonstration purposes, but in practice, you can simply use the logger methods directly:
282
+ >
283
+ > ```typescript
284
+ > const operation = (value: number) => {
285
+ > logger.info('Processing value', { value }); // Trace ID is automatically included
286
+ > return value * 2;
287
+ > };
288
+ > ```
289
+
290
+ ## API Reference
291
+
292
+ ### UnnboundLogger
293
+
294
+ The main logger class that provides all logging functionality using Pino.
295
+
296
+ #### Constructor
297
+
298
+ ```typescript
299
+ new UnnboundLogger(options?: LoggerOptions)
300
+ ```
301
+
302
+ #### Methods
303
+
304
+ - `log(level: LogLevel, message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): void`
305
+ - `error(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): void`
306
+ - `warn(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): void`
307
+ - `info(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): void`
308
+ - `debug(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): void`
309
+ - `httpRequest(req: Request, options?: HttpRequestLogOptions): string`
310
+ - `httpResponse(res: Response, req: Request, options: HttpResponseLogOptions): void`
311
+ - `sftpTransaction(operation: SftpOperation, options?: SftpTransactionLogOptions): void`
312
+ - `dbQueryTransaction(query: DbQuery, options?: DbQueryTransactionLogOptions): void`
@@ -0,0 +1,38 @@
1
+ /**
2
+ * unnbound-logger
3
+ *
4
+ * A structured logging library built on Pino with TypeScript support.
5
+ * Provides consistent, well-typed logging across different operational contexts.
6
+ */
7
+ import { UnnboundLogger } from './unnbound-logger';
8
+ import { LogLevel, LogType, HttpMethod, LoggerOptions, GeneralLogOptions, HttpRequestLogOptions, HttpResponseLogOptions, SftpTransactionLogOptions, DbQueryTransactionLogOptions, Log, LogTransaction, HttpRequestLog, HttpResponseLog, SftpTransactionLog, DbQueryTransactionLog, SerializableError } from './types';
9
+ import { generateUuid, clearTraceId } from './utils/id-generator';
10
+ export { UnnboundLogger, LogLevel, LogType, HttpMethod, LoggerOptions, GeneralLogOptions, HttpRequestLogOptions, HttpResponseLogOptions, SftpTransactionLogOptions, DbQueryTransactionLogOptions, Log, LogTransaction, HttpRequestLog, HttpResponseLog, SftpTransactionLog, DbQueryTransactionLog, SerializableError, generateUuid, clearTraceId, };
11
+ declare const defaultLogger: UnnboundLogger;
12
+ export { defaultLogger };
13
+ export declare const log: (level: LogLevel, message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
14
+ export declare const error: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
15
+ export declare const warn: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
16
+ export declare const info: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
17
+ export declare const debug: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
18
+ export declare const httpRequest: (req: import("express").Request, options?: HttpRequestLogOptions) => string;
19
+ export declare const httpResponse: (res: import("express").Response, req: import("express").Request, options?: HttpResponseLogOptions) => void;
20
+ export declare const sftpTransaction: (operation: {
21
+ host: string;
22
+ username: string;
23
+ operation: "upload" | "download" | "list" | "delete" | "rename" | "stat";
24
+ path: string;
25
+ status: "success" | "failure";
26
+ bytesTransferred?: number;
27
+ filesListed?: number;
28
+ sourcePath?: string;
29
+ }, options?: SftpTransactionLogOptions) => void;
30
+ export declare const dbQueryTransaction: (query: {
31
+ instance: string;
32
+ vendor: "postgres" | "mysql" | "mssql" | "mongodb";
33
+ query?: string;
34
+ status: "success" | "failure";
35
+ rowsReturned?: number;
36
+ rowsAffected?: number;
37
+ }, options?: DbQueryTransactionLogOptions) => void;
38
+ export default UnnboundLogger;
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dbQueryTransaction = exports.sftpTransaction = exports.httpResponse = exports.httpRequest = exports.debug = exports.info = exports.warn = exports.error = exports.log = exports.defaultLogger = exports.clearTraceId = exports.generateUuid = exports.UnnboundLogger = void 0;
4
+ /**
5
+ * unnbound-logger
6
+ *
7
+ * A structured logging library built on Pino with TypeScript support.
8
+ * Provides consistent, well-typed logging across different operational contexts.
9
+ */
10
+ const unnbound_logger_1 = require("./unnbound-logger");
11
+ Object.defineProperty(exports, "UnnboundLogger", { enumerable: true, get: function () { return unnbound_logger_1.UnnboundLogger; } });
12
+ const id_generator_1 = require("./utils/id-generator");
13
+ Object.defineProperty(exports, "generateUuid", { enumerable: true, get: function () { return id_generator_1.generateUuid; } });
14
+ Object.defineProperty(exports, "clearTraceId", { enumerable: true, get: function () { return id_generator_1.clearTraceId; } });
15
+ // Create a default logger instance
16
+ const defaultLogger = new unnbound_logger_1.UnnboundLogger();
17
+ exports.defaultLogger = defaultLogger;
18
+ // Export default logger functions for convenience
19
+ exports.log = defaultLogger.log.bind(defaultLogger);
20
+ exports.error = defaultLogger.error.bind(defaultLogger);
21
+ exports.warn = defaultLogger.warn.bind(defaultLogger);
22
+ exports.info = defaultLogger.info.bind(defaultLogger);
23
+ exports.debug = defaultLogger.debug.bind(defaultLogger);
24
+ exports.httpRequest = defaultLogger.httpRequest.bind(defaultLogger);
25
+ exports.httpResponse = defaultLogger.httpResponse.bind(defaultLogger);
26
+ exports.sftpTransaction = defaultLogger.sftpTransaction.bind(defaultLogger);
27
+ exports.dbQueryTransaction = defaultLogger.dbQueryTransaction.bind(defaultLogger);
28
+ // Default export is the UnnboundLogger class
29
+ exports.default = unnbound_logger_1.UnnboundLogger;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * unnbound-logger
3
+ *
4
+ * A structured logging library built on Pino with TypeScript support.
5
+ * Provides consistent, well-typed logging across different operational contexts.
6
+ */
7
+ import { UnnboundLogger } from './unnbound-logger';
8
+ import { LogLevel, LogType, HttpMethod, LoggerOptions, GeneralLogOptions, HttpRequestLogOptions, HttpResponseLogOptions, SftpTransactionLogOptions, DbQueryTransactionLogOptions, Log, LogTransaction, HttpRequestLog, HttpResponseLog, SftpTransactionLog, DbQueryTransactionLog, SerializableError } from './types';
9
+ import { generateUuid, clearTraceId } from './utils/id-generator';
10
+ export { UnnboundLogger, LogLevel, LogType, HttpMethod, LoggerOptions, GeneralLogOptions, HttpRequestLogOptions, HttpResponseLogOptions, SftpTransactionLogOptions, DbQueryTransactionLogOptions, Log, LogTransaction, HttpRequestLog, HttpResponseLog, SftpTransactionLog, DbQueryTransactionLog, SerializableError, generateUuid, clearTraceId, };
11
+ declare const defaultLogger: UnnboundLogger;
12
+ export { defaultLogger };
13
+ export declare const log: (level: LogLevel, message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
14
+ export declare const error: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
15
+ export declare const warn: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
16
+ export declare const info: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
17
+ export declare const debug: (message: string | Error | Record<string, unknown>, options?: GeneralLogOptions) => void;
18
+ export declare const httpRequest: (req: import("express").Request, options?: HttpRequestLogOptions) => string;
19
+ export declare const httpResponse: (res: import("express").Response, req: import("express").Request, options?: HttpResponseLogOptions) => void;
20
+ export declare const sftpTransaction: (operation: {
21
+ host: string;
22
+ username: string;
23
+ operation: "upload" | "download" | "list" | "delete" | "rename" | "stat";
24
+ path: string;
25
+ status: "success" | "failure";
26
+ bytesTransferred?: number;
27
+ filesListed?: number;
28
+ sourcePath?: string;
29
+ }, options?: SftpTransactionLogOptions) => void;
30
+ export declare const dbQueryTransaction: (query: {
31
+ instance: string;
32
+ vendor: "postgres" | "mysql" | "mssql" | "mongodb";
33
+ query?: string;
34
+ status: "success" | "failure";
35
+ rowsReturned?: number;
36
+ rowsAffected?: number;
37
+ }, options?: DbQueryTransactionLogOptions) => void;
38
+ export default UnnboundLogger;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dbQueryTransaction = exports.sftpTransaction = exports.httpResponse = exports.httpRequest = exports.debug = exports.info = exports.warn = exports.error = exports.log = exports.defaultLogger = exports.clearTraceId = exports.generateUuid = exports.UnnboundLogger = void 0;
4
+ /**
5
+ * unnbound-logger
6
+ *
7
+ * A structured logging library built on Pino with TypeScript support.
8
+ * Provides consistent, well-typed logging across different operational contexts.
9
+ */
10
+ const unnbound_logger_1 = require("./unnbound-logger");
11
+ Object.defineProperty(exports, "UnnboundLogger", { enumerable: true, get: function () { return unnbound_logger_1.UnnboundLogger; } });
12
+ const id_generator_1 = require("./utils/id-generator");
13
+ Object.defineProperty(exports, "generateUuid", { enumerable: true, get: function () { return id_generator_1.generateUuid; } });
14
+ Object.defineProperty(exports, "clearTraceId", { enumerable: true, get: function () { return id_generator_1.clearTraceId; } });
15
+ // Create a default logger instance
16
+ const defaultLogger = new unnbound_logger_1.UnnboundLogger();
17
+ exports.defaultLogger = defaultLogger;
18
+ // Export default logger functions for convenience
19
+ exports.log = defaultLogger.log.bind(defaultLogger);
20
+ exports.error = defaultLogger.error.bind(defaultLogger);
21
+ exports.warn = defaultLogger.warn.bind(defaultLogger);
22
+ exports.info = defaultLogger.info.bind(defaultLogger);
23
+ exports.debug = defaultLogger.debug.bind(defaultLogger);
24
+ exports.httpRequest = defaultLogger.httpRequest.bind(defaultLogger);
25
+ exports.httpResponse = defaultLogger.httpResponse.bind(defaultLogger);
26
+ exports.sftpTransaction = defaultLogger.sftpTransaction.bind(defaultLogger);
27
+ exports.dbQueryTransaction = defaultLogger.dbQueryTransaction.bind(defaultLogger);
28
+ // Default export is the UnnboundLogger class
29
+ exports.default = unnbound_logger_1.UnnboundLogger;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Type definitions for structured logging library
3
+ */
4
+ /**
5
+ * Available log levels
6
+ */
7
+ export type LogLevel = "info" | "debug" | "error" | "warn";
8
+ /**
9
+ * Available log types
10
+ */
11
+ export type LogType = "general" | "httpRequest" | "httpResponse" | "sftpTransaction" | "dbQueryTransaction";
12
+ /**
13
+ * HTTP methods supported for HTTP logging
14
+ */
15
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
16
+ export interface SerializableError {
17
+ name: string;
18
+ message: string;
19
+ stack?: string;
20
+ }
21
+ export interface Log<T extends LogType = 'general'> {
22
+ level: LogLevel;
23
+ type: T;
24
+ message: string;
25
+ traceId: string;
26
+ requestId: string;
27
+ error?: SerializableError;
28
+ }
29
+ export interface LogTransaction<T extends LogType> extends Log<T> {
30
+ duration: number;
31
+ }
32
+ export interface HttpRequestLog extends LogTransaction<'httpRequest'> {
33
+ httpRequest: {
34
+ url: string;
35
+ method: string;
36
+ headers: Record<string, string>;
37
+ ip?: string;
38
+ body?: unknown;
39
+ };
40
+ }
41
+ export interface HttpResponseLog extends LogTransaction<'httpResponse'> {
42
+ httpResponse: {
43
+ url: string;
44
+ method: string;
45
+ headers: Record<string, string>;
46
+ ip?: string;
47
+ status: number;
48
+ body?: unknown;
49
+ };
50
+ }
51
+ export interface SftpTransactionLog extends LogTransaction<'sftpTransaction'> {
52
+ sftp: {
53
+ host: string;
54
+ username: string;
55
+ operation: 'upload' | 'download' | 'list' | 'delete' | 'rename' | 'stat';
56
+ path: string;
57
+ status: 'success' | 'failure';
58
+ bytesTransferred?: number;
59
+ filesListed?: number;
60
+ sourcePath?: string;
61
+ };
62
+ }
63
+ export interface DbQueryTransactionLog extends LogTransaction<'dbQueryTransaction'> {
64
+ db: {
65
+ instance: string;
66
+ vendor: 'postgres' | 'mysql' | 'mssql' | 'mongodb';
67
+ query?: string;
68
+ status: 'success' | 'failure';
69
+ rowsReturned?: number;
70
+ rowsAffected?: number;
71
+ };
72
+ }
73
+ /**
74
+ * Configuration options for the logger
75
+ */
76
+ export interface LoggerOptions {
77
+ /** Default log level */
78
+ defaultLevel?: LogLevel;
79
+ /** Optional service name to include in logs */
80
+ serviceName?: string;
81
+ /** Optional environment name to include in logs */
82
+ environment?: string;
83
+ /** Optional trace header key */
84
+ traceHeaderKey?: string;
85
+ /** Routes to ignore in trace middleware (supports glob patterns) */
86
+ ignoreTraceRoutes?: string[];
87
+ /** Routes to ignore in axios trace middleware (supports glob patterns) */
88
+ ignoreAxiosTraceRoutes?: string[];
89
+ }
90
+ /**
91
+ * Options for general logs
92
+ */
93
+ export interface GeneralLogOptions {
94
+ /** Log level override */
95
+ level?: LogLevel;
96
+ /** Custom trace ID */
97
+ traceId?: string;
98
+ /** Custom request ID */
99
+ requestId?: string;
100
+ /** Custom metadata */
101
+ [key: string]: unknown;
102
+ }
103
+ /**
104
+ * Options for HTTP request logs
105
+ */
106
+ export interface HttpRequestLogOptions extends GeneralLogOptions {
107
+ /** Start time of the request for duration calculation */
108
+ startTime?: number;
109
+ }
110
+ /**
111
+ * Options for HTTP response logs
112
+ */
113
+ export interface HttpResponseLogOptions extends HttpRequestLogOptions {
114
+ /** Duration of the request in milliseconds */
115
+ duration?: number;
116
+ }
117
+ /**
118
+ * Options for SFTP transaction logs
119
+ */
120
+ export interface SftpTransactionLogOptions extends GeneralLogOptions {
121
+ /** Start time of the transaction for duration calculation */
122
+ startTime?: number;
123
+ /** Duration of the transaction in milliseconds */
124
+ duration?: number;
125
+ }
126
+ /**
127
+ * Options for database query transaction logs
128
+ */
129
+ export interface DbQueryTransactionLogOptions extends GeneralLogOptions {
130
+ /** Start time of the query for duration calculation */
131
+ startTime?: number;
132
+ /** Duration of the query in milliseconds */
133
+ duration?: number;
134
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for structured logging library
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });