unnbound-logger-sdk 2.0.10 → 3.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/dist/index.d.ts DELETED
@@ -1,10 +0,0 @@
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 { clearTraceId } from './utils/logger-utils';
10
- export { UnnboundLogger, LogLevel, LogType, HttpMethod, LoggerOptions, GeneralLogOptions, HttpRequestLogOptions, HttpResponseLogOptions, SftpTransactionLogOptions, DbQueryTransactionLogOptions, Log, LogTransaction, HttpRequestLog, HttpResponseLog, SftpTransactionLog, DbQueryTransactionLog, SerializableError, clearTraceId, };
package/dist/types.d.ts DELETED
@@ -1,132 +0,0 @@
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
- logId: string;
23
- level: LogLevel;
24
- type: T;
25
- message: string;
26
- serviceId: string;
27
- deploymentId: string;
28
- workflowId: string;
29
- traceId: string;
30
- requestId: string;
31
- error?: SerializableError;
32
- }
33
- export interface LogTransaction<T extends LogType> extends Log<T> {
34
- duration: number;
35
- }
36
- export interface HttpRequestLog extends LogTransaction<'httpRequest'> {
37
- httpRequest: {
38
- url: string;
39
- method: string;
40
- headers: Record<string, string>;
41
- ip?: string;
42
- body?: unknown;
43
- };
44
- }
45
- export interface HttpResponseLog extends LogTransaction<'httpResponse'> {
46
- httpResponse: {
47
- url: string;
48
- method: string;
49
- headers: Record<string, string>;
50
- ip?: string;
51
- status: number;
52
- body?: unknown;
53
- };
54
- }
55
- export interface SftpTransactionLog extends LogTransaction<'sftpTransaction'> {
56
- sftp: {
57
- host: string;
58
- username: string;
59
- operation: 'upload' | 'download' | 'list' | 'delete' | 'rename' | 'stat';
60
- path: string;
61
- status: 'success' | 'failure';
62
- bytesTransferred?: number;
63
- filesListed?: number;
64
- sourcePath?: string;
65
- };
66
- }
67
- export interface DbQueryTransactionLog extends LogTransaction<'dbQueryTransaction'> {
68
- db: {
69
- instance: string;
70
- vendor: 'postgres' | 'mysql' | 'mssql' | 'mongodb';
71
- query?: string;
72
- status: 'success' | 'failure';
73
- rowsReturned?: number;
74
- rowsAffected?: number;
75
- };
76
- }
77
- /**
78
- * Configuration options for the logger
79
- */
80
- export interface LoggerOptions {
81
- /** Optional trace header key */
82
- traceHeaderKey?: string;
83
- /** Routes to ignore in trace middleware (supports glob patterns) */
84
- ignoreTraceRoutes?: string[];
85
- /** Routes to ignore in axios trace middleware (supports glob patterns) */
86
- ignoreAxiosTraceRoutes?: string[];
87
- }
88
- /**
89
- * Options for general logs
90
- */
91
- export interface GeneralLogOptions {
92
- /** Log level override */
93
- level?: LogLevel;
94
- /** Custom trace ID */
95
- traceId?: string;
96
- /** Custom request ID */
97
- requestId?: string;
98
- /** Custom metadata */
99
- [key: string]: unknown;
100
- }
101
- /**
102
- * Options for HTTP request logs
103
- */
104
- export interface HttpRequestLogOptions extends GeneralLogOptions {
105
- /** Start time of the request for duration calculation */
106
- startTime?: number;
107
- }
108
- /**
109
- * Options for HTTP response logs
110
- */
111
- export interface HttpResponseLogOptions extends HttpRequestLogOptions {
112
- /** Duration of the request in milliseconds */
113
- duration?: number;
114
- }
115
- /**
116
- * Options for SFTP transaction logs
117
- */
118
- export interface SftpTransactionLogOptions extends GeneralLogOptions {
119
- /** Start time of the transaction for duration calculation */
120
- startTime?: number;
121
- /** Duration of the transaction in milliseconds */
122
- duration?: number;
123
- }
124
- /**
125
- * Options for database query transaction logs
126
- */
127
- export interface DbQueryTransactionLogOptions extends GeneralLogOptions {
128
- /** Start time of the query for duration calculation */
129
- startTime?: number;
130
- /** Duration of the query in milliseconds */
131
- duration?: number;
132
- }
package/dist/types.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- /**
3
- * Type definitions for structured logging library
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,124 +0,0 @@
1
- import { LogLevel, LoggerOptions, GeneralLogOptions, HttpRequestLogOptions, HttpResponseLogOptions, SftpTransactionLogOptions, DbQueryTransactionLogOptions, Log, HttpRequestLog, HttpResponseLog, SftpTransactionLog, DbQueryTransactionLog } from './types';
2
- import { Request, Response, NextFunction } from 'express';
3
- import { InternalAxiosRequestConfig } from 'axios';
4
- declare module 'axios' {
5
- interface InternalAxiosRequestConfig {
6
- metadata?: {
7
- startTime: number;
8
- requestId?: string;
9
- };
10
- }
11
- }
12
- /**
13
- * UnnboundLogger provides typed, structured logging using Pino
14
- */
15
- export declare class UnnboundLogger {
16
- private logger;
17
- private workflowId;
18
- private workflowUrl;
19
- private serviceId;
20
- private deploymentId;
21
- private traceHeaderKey;
22
- private ignoreTraceRoutes;
23
- private ignoreAxiosTraceRoutes;
24
- /**
25
- * Creates a new UnnboundLogger instance
26
- * @param options - Configuration options for the logger
27
- */
28
- constructor(options?: LoggerOptions);
29
- /**
30
- * Checks if a path matches any of the ignore patterns
31
- * @param path - The path to check
32
- * @param patterns - Array of glob patterns to match against
33
- * @returns boolean indicating if the path should be ignored
34
- */
35
- private shouldIgnorePath;
36
- /**
37
- * Logs a general message
38
- * @param level - Log level
39
- * @param message - Log message
40
- * @param options - Additional logging options
41
- */
42
- log(level: LogLevel, message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): Log;
43
- /**
44
- * Logs an error message
45
- * @param message - Error message or object
46
- * @param options - Additional logging options
47
- */
48
- error(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): Log;
49
- /**
50
- * Logs a warning message
51
- * @param message - Warning message
52
- * @param options - Additional logging options
53
- */
54
- warn(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): Log;
55
- /**
56
- * Logs an info message
57
- * @param message - Info message
58
- * @param options - Additional logging options
59
- */
60
- info(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): Log;
61
- /**
62
- * Logs a debug message
63
- * @param message - Debug message
64
- * @param options - Additional logging options
65
- */
66
- debug(message: string | Error | Record<string, unknown>, options?: GeneralLogOptions): Log;
67
- /**
68
- * Constructs the full URL from request information
69
- * @param req - Express request object
70
- * @returns Full URL string
71
- */
72
- private constructFullUrl;
73
- /**
74
- * Logs an HTTP request
75
- * @param req - Express request object
76
- * @param options - Additional logging options
77
- * @returns The request ID for correlating with the response
78
- */
79
- httpRequest(req: Request, options?: HttpRequestLogOptions): HttpRequestLog;
80
- /**
81
- * Logs an HTTP response
82
- * @param res - Express response object
83
- * @param req - Express request object
84
- * @param options - Additional logging options
85
- */
86
- httpResponse(res: Response, req: Request, options?: HttpResponseLogOptions): HttpResponseLog;
87
- /**
88
- * Logs an SFTP transaction
89
- * @param operation - SFTP operation details
90
- * @param options - Additional logging options
91
- */
92
- sftpTransaction(operation: {
93
- host: string;
94
- username: string;
95
- operation: 'upload' | 'download' | 'list' | 'delete' | 'rename' | 'stat';
96
- path: string;
97
- status: 'success' | 'failure';
98
- bytesTransferred?: number;
99
- filesListed?: number;
100
- sourcePath?: string;
101
- }, options?: SftpTransactionLogOptions): SftpTransactionLog;
102
- /**
103
- * Logs a database query transaction
104
- * @param query - Database query details
105
- * @param options - Additional logging options
106
- */
107
- dbQueryTransaction(query: {
108
- instance: string;
109
- vendor: 'postgres' | 'mysql' | 'mssql' | 'mongodb';
110
- query?: string;
111
- status: 'success' | 'failure';
112
- rowsReturned?: number;
113
- rowsAffected?: number;
114
- }, options?: DbQueryTransactionLogOptions): DbQueryTransactionLog;
115
- traceMiddleware: (req: Request, res: Response, next: NextFunction) => void;
116
- axiosTraceMiddleware: {
117
- onFulfilled: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
118
- onRejected: (error: any) => any;
119
- };
120
- axiosResponseInterceptor: {
121
- onFulfilled: (response: any) => any;
122
- onRejected: (error: any) => any;
123
- };
124
- }