@octaviaflow/logger 1.0.0 → 1.0.1

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.
@@ -0,0 +1,21 @@
1
+ import type { LogLevel } from '../types/logger.js';
2
+ export declare const LOG_LEVELS: Record<LogLevel, number>;
3
+ export declare const LOG_LEVEL_NAMES: Record<number, LogLevel>;
4
+ export declare const COLORS: {
5
+ readonly fatal: "\u001B[35m";
6
+ readonly error: "\u001B[31m";
7
+ readonly warn: "\u001B[33m";
8
+ readonly info: "\u001B[36m";
9
+ readonly debug: "\u001B[32m";
10
+ readonly trace: "\u001B[37m";
11
+ readonly reset: "\u001B[0m";
12
+ readonly bold: "\u001B[1m";
13
+ readonly dim: "\u001B[2m";
14
+ };
15
+ export declare const DEFAULT_BUFFER_SIZE = 100;
16
+ export declare const DEFAULT_FLUSH_INTERVAL = 5000;
17
+ export declare const DEFAULT_MAX_FILE_SIZE = "10m";
18
+ export declare const DEFAULT_MAX_FILES = 10;
19
+ export declare const DEFAULT_DATE_PATTERN = "YYYY-MM-DD";
20
+ export declare const SIZE_UNITS: Record<string, number>;
21
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAOtC,CAAC;AAEX,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAO3C,CAAC;AAEX,eAAO,MAAM,MAAM;;;;;;;;;;CAUT,CAAC;AAEX,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKpC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { BaseLogMeta } from '../../types/logger.js';
2
+ export declare class ContextManager {
3
+ private storage;
4
+ /**
5
+ * Run a function with a specific context
6
+ */
7
+ run<T>(context: Partial<BaseLogMeta>, fn: () => T): T;
8
+ /**
9
+ * Get the current context
10
+ */
11
+ getContext(): Partial<BaseLogMeta>;
12
+ /**
13
+ * Set context for the current async scope
14
+ */
15
+ setContext(context: Partial<BaseLogMeta>): void;
16
+ /**
17
+ * Clear the current context
18
+ */
19
+ clearContext(): void;
20
+ /**
21
+ * Merge context with existing context
22
+ */
23
+ mergeContext(context: Partial<BaseLogMeta>): Partial<BaseLogMeta>;
24
+ }
25
+ export declare const contextManager: ContextManager;
26
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/context/manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAiD;IAEhE;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIrD;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IAIlC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAQ/C;;OAEG;IACH,YAAY,IAAI,IAAI;IAIpB;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;CAIlE;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { BaseLogMeta, LogFormat } from '../../types/logger.js';
2
+ export interface FormatterOptions {
3
+ colorize?: boolean;
4
+ prettyPrint?: boolean;
5
+ includeTimestamp?: boolean;
6
+ }
7
+ export interface Formatter {
8
+ format(message: string, meta: BaseLogMeta): string;
9
+ }
10
+ /**
11
+ * JSON Formatter - Structured JSON output
12
+ */
13
+ export declare class JSONFormatter implements Formatter {
14
+ private options;
15
+ constructor(options?: FormatterOptions);
16
+ format(message: string, meta: BaseLogMeta): string;
17
+ }
18
+ /**
19
+ * Pretty Formatter - Human-readable colored output
20
+ */
21
+ export declare class PrettyFormatter implements Formatter {
22
+ private options;
23
+ constructor(options?: FormatterOptions);
24
+ format(message: string, meta: BaseLogMeta): string;
25
+ private extractAdditionalMeta;
26
+ }
27
+ /**
28
+ * Compact Formatter - Single-line compact output
29
+ */
30
+ export declare class CompactFormatter implements Formatter {
31
+ private options;
32
+ constructor(options?: FormatterOptions);
33
+ format(message: string, meta: BaseLogMeta): string;
34
+ }
35
+ /**
36
+ * ECS Formatter - Elastic Common Schema format
37
+ */
38
+ export declare class ECSFormatter implements Formatter {
39
+ private options;
40
+ constructor(options?: FormatterOptions);
41
+ format(message: string, meta: BaseLogMeta): string;
42
+ private extractLabels;
43
+ private extractECSFields;
44
+ }
45
+ /**
46
+ * Create formatter based on format type
47
+ */
48
+ export declare function createFormatter(format: LogFormat, options?: FormatterOptions): Formatter;
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;CACpD;AAED;;GAEG;AACH,qBAAa,aAAc,YAAW,SAAS;IACjC,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,gBAAqB;IAElD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM;CAUnD;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IACnC,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,gBAAqB;IAElD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM;IAqClD,OAAO,CAAC,qBAAqB;CAc9B;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IACpC,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,gBAAqB;IAElD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM;CAMnD;AAED;;GAEG;AACH,qBAAa,YAAa,YAAW,SAAS;IAChC,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,gBAAqB;IAElD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM;IAuBlD,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,gBAAgB;CAoCzB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CAaX"}
@@ -0,0 +1,8 @@
1
+ export { Logger } from './logger.js';
2
+ export { BaseTransport, ConsoleTransport, FileTransport, HTTPTransport, } from './transports/index.js';
3
+ export { createFormatter, JSONFormatter, PrettyFormatter, CompactFormatter, ECSFormatter, type Formatter, type FormatterOptions, } from './formatters/index.js';
4
+ export { ContextManager, contextManager } from './context/manager.js';
5
+ export { parseSize, formatBytes, formatDuration, getHostname, getPid, generateId, sanitize, deepMerge, formatDateForFile, safeStringify, ensureDir, isProduction, isDevelopment, } from './utils/helpers.js';
6
+ export { LOG_LEVELS, LOG_LEVEL_NAMES, COLORS } from './constants.js';
7
+ export type * from '../types/logger.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtE,OAAO,EACL,SAAS,EACT,WAAW,EACX,cAAc,EACd,WAAW,EACX,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGrE,mBAAmB,oBAAoB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { Logger as ILogger, LoggerConfig, BaseLogMeta, ErrorLogMeta, AuditLogMeta, SecurityLogMeta, PerformanceLogMeta, MetricsLogMeta, WorkflowContext, RequestContext, WorkflowLogMeta } from '../types/logger.js';
2
+ export declare class Logger implements ILogger {
3
+ private config;
4
+ private transports;
5
+ private timers;
6
+ private childContext;
7
+ constructor(config: LoggerConfig);
8
+ private initializeTransports;
9
+ private setupErrorHandlers;
10
+ private shouldLog;
11
+ private buildMeta;
12
+ private log;
13
+ private shouldSample;
14
+ private shouldFilter;
15
+ private getNestedValue;
16
+ fatal(message: string, meta?: Partial<BaseLogMeta>): void;
17
+ error(message: string, meta?: Partial<ErrorLogMeta>): void;
18
+ warn(message: string, meta?: Partial<BaseLogMeta>): void;
19
+ info(message: string, meta?: Partial<BaseLogMeta>): void;
20
+ debug(message: string, meta?: Partial<BaseLogMeta>): void;
21
+ trace(message: string, meta?: Partial<BaseLogMeta>): void;
22
+ audit(action: string, meta: Omit<AuditLogMeta, 'type' | 'level'>): void;
23
+ security(event: SecurityLogMeta['event'], meta: Omit<SecurityLogMeta, 'type' | 'level'>): void;
24
+ performance(operation: string, duration: number, meta?: Partial<PerformanceLogMeta>): void;
25
+ metric(name: string, value: number, meta?: Partial<MetricsLogMeta>): void;
26
+ child(context: Partial<BaseLogMeta>): Logger;
27
+ setContext(context: Partial<BaseLogMeta>): void;
28
+ clearContext(): void;
29
+ startWorkflow(workflow: WorkflowContext): void;
30
+ endWorkflow(success: boolean, meta?: Partial<WorkflowLogMeta>): void;
31
+ startRequest(request: RequestContext): void;
32
+ endRequest(statusCode: number, duration: number): void;
33
+ profile(id: string): void;
34
+ startTimer(): () => number;
35
+ flush(): Promise<void>;
36
+ close(): Promise<void>;
37
+ }
38
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,MAAM,IAAI,OAAO,EACjB,YAAY,EACZ,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAO5B,qBAAa,MAAO,YAAW,OAAO;IACpC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,YAAY,CAA4B;gBAEpC,MAAM,EAAE,YAAY;IAMhC,OAAO,CAAC,oBAAoB;IAgC5B,OAAO,CAAC,kBAAkB;IAuC1B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IA+BjB,OAAO,CAAC,GAAG;IAyBX,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,cAAc;IAUtB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAIzD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAI1D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAIxD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAIxD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAIzD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAQzD,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI;IAOvE,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI;IAS9F,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAY1F,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAczE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,MAAM;IAO5C,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAI/C,YAAY,IAAI,IAAI;IAQpB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAQ9C,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAepE,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAQ3C,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IActD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAWzB,UAAU,IAAI,MAAM,MAAM;IAKpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -0,0 +1,12 @@
1
+ import type { LoggerConfig } from '../../types/logger.js';
2
+ import { Logger } from '../logger.js';
3
+ export interface BackendLoggerOptions {
4
+ level?: LoggerConfig['level'];
5
+ logDir?: string;
6
+ enableConsole?: boolean;
7
+ enableFile?: boolean;
8
+ version?: string;
9
+ defaultMeta?: Record<string, unknown>;
10
+ }
11
+ export declare function createBackendLogger(options?: BackendLoggerOptions): Logger;
12
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/presets/backend.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CA0F9E"}
@@ -0,0 +1,13 @@
1
+ import type { LoggerConfig } from '../../types/logger.js';
2
+ import { Logger } from '../logger.js';
3
+ export interface EngineLoggerOptions {
4
+ level?: LoggerConfig['level'];
5
+ logDir?: string;
6
+ enableConsole?: boolean;
7
+ enableFile?: boolean;
8
+ version?: string;
9
+ workerId?: string;
10
+ defaultMeta?: Record<string, unknown>;
11
+ }
12
+ export declare function createEngineLogger(options?: EngineLoggerOptions): Logger;
13
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/presets/engine.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA2G5E"}
@@ -0,0 +1,4 @@
1
+ export { createBackendLogger, type BackendLoggerOptions } from './backend.js';
2
+ export { createEngineLogger, type EngineLoggerOptions } from './engine.js';
3
+ export { createUILogger, type UILoggerOptions } from './ui.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presets/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { LoggerConfig } from '../../types/logger.js';
2
+ import { Logger } from '../logger.js';
3
+ export interface UILoggerOptions {
4
+ level?: LoggerConfig['level'];
5
+ enableConsole?: boolean;
6
+ enableRemote?: boolean;
7
+ remoteUrl?: string;
8
+ version?: string;
9
+ defaultMeta?: Record<string, unknown>;
10
+ }
11
+ export declare function createUILogger(options?: UILoggerOptions): Logger;
12
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/presets/ui.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,MAAM,CA8EpE"}
@@ -0,0 +1,13 @@
1
+ import type { BaseLogMeta, LogLevel, TransportConfig } from '../../types/logger.js';
2
+ import type { Formatter } from '../formatters/index.js';
3
+ export declare abstract class BaseTransport {
4
+ protected config: TransportConfig;
5
+ protected formatter?: Formatter;
6
+ constructor(config: TransportConfig);
7
+ setFormatter(formatter: Formatter): void;
8
+ shouldLog(level: LogLevel): boolean;
9
+ abstract log(message: string, meta: BaseLogMeta): void | Promise<void>;
10
+ abstract flush(): Promise<void>;
11
+ abstract close(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/transports/base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,8BAAsB,aAAa;IACjC,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC;IAClC,SAAS,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;gBAEpB,MAAM,EAAE,eAAe;IAInC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIxC,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAOnC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACtE,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAC/B,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAChC"}
@@ -0,0 +1,8 @@
1
+ import type { BaseLogMeta } from '../../types/logger.js';
2
+ import { BaseTransport } from './base.js';
3
+ export declare class ConsoleTransport extends BaseTransport {
4
+ log(message: string, meta: BaseLogMeta): void;
5
+ flush(): Promise<void>;
6
+ close(): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=console.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/transports/console.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;IA2BvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -0,0 +1,21 @@
1
+ import type { BaseLogMeta } from '../../types/logger.js';
2
+ import { BaseTransport } from './base.js';
3
+ export declare class FileTransport extends BaseTransport {
4
+ private writeStream?;
5
+ private currentSize;
6
+ private currentDate;
7
+ private writeQueue;
8
+ private isWriting;
9
+ private isClosed;
10
+ log(message: string, meta: BaseLogMeta): Promise<void>;
11
+ private processQueue;
12
+ private ensureStream;
13
+ private writeToStream;
14
+ private rotate;
15
+ private rotateFiles;
16
+ private compressFile;
17
+ private closeStream;
18
+ flush(): Promise<void>;
19
+ close(): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/transports/file.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAW1C,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAS;IAEnB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;YAW9C,YAAY;YAkBZ,YAAY;YAsBZ,aAAa;YAkBb,MAAM;YAyCN,WAAW;YAoCX,YAAY;YAcZ,WAAW;IAcnB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
@@ -0,0 +1,14 @@
1
+ import type { BaseLogMeta, TransportConfig } from '../../types/logger.js';
2
+ import { BaseTransport } from './base.js';
3
+ export declare class HTTPTransport extends BaseTransport {
4
+ private batch;
5
+ private flushTimer?;
6
+ private isClosed;
7
+ constructor(config: TransportConfig);
8
+ log(message: string, meta: BaseLogMeta): Promise<void>;
9
+ private startFlushTimer;
10
+ flush(): Promise<void>;
11
+ private sendWithRetry;
12
+ close(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/transports/http.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAO1C,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,KAAK,CAAiD;IAC9D,OAAO,CAAC,UAAU,CAAC,CAAiC;IACpD,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,eAAe;IAK7B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5D,OAAO,CAAC,eAAe;IAejB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAiBd,aAAa;IAqCrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAU7B"}
@@ -0,0 +1,5 @@
1
+ export { BaseTransport } from './base.js';
2
+ export { ConsoleTransport } from './console.js';
3
+ export { FileTransport } from './file.js';
4
+ export { HTTPTransport } from './http.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transports/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Parse size string (e.g., "10m", "1g") to bytes
3
+ */
4
+ export declare function parseSize(size: string): number;
5
+ /**
6
+ * Format bytes to human-readable string
7
+ */
8
+ export declare function formatBytes(bytes: number): string;
9
+ /**
10
+ * Format duration in milliseconds to human-readable string
11
+ */
12
+ export declare function formatDuration(ms: number): string;
13
+ /**
14
+ * Get hostname
15
+ */
16
+ export declare function getHostname(): string;
17
+ /**
18
+ * Get process ID
19
+ */
20
+ export declare function getPid(): number;
21
+ /**
22
+ * Generate unique ID
23
+ */
24
+ export declare function generateId(prefix?: string): string;
25
+ /**
26
+ * Sanitize sensitive data from objects
27
+ */
28
+ export declare function sanitize(obj: unknown, fields?: string[], replacement?: string): unknown;
29
+ /**
30
+ * Deep merge objects
31
+ */
32
+ export declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
33
+ /**
34
+ * Format date for file names
35
+ */
36
+ export declare function formatDateForFile(date: Date, pattern: string): string;
37
+ /**
38
+ * Safe JSON stringify with circular reference handling
39
+ */
40
+ export declare function safeStringify(obj: unknown, space?: number): string;
41
+ /**
42
+ * Ensure directory exists
43
+ */
44
+ export declare function ensureDir(dirPath: string): Promise<void>;
45
+ /**
46
+ * Check if running in production
47
+ */
48
+ export declare function isProduction(): boolean;
49
+ /**
50
+ * Check if running in development
51
+ */
52
+ export declare function isDevelopment(): boolean;
53
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAK,GAAG,MAAM,CAI9C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,OAAO,EACZ,MAAM,GAAE,MAAM,EAA+D,EAC7E,WAAW,SAAe,GACzB,OAAO,CAyBT;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GACvB,CAAC,CAqBH;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAarE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAkClE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU9D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octaviaflow/logger",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Production-ready, high-performance logger for Octaviaflow microservices",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,9 @@
28
28
  "LICENSE"
29
29
  ],
30
30
  "scripts": {
31
- "build": "bun run build:clean && bun run build:bundle",
31
+ "build": "bun run build:clean && bun run build:types && bun run build:bundle",
32
32
  "build:clean": "rm -rf dist",
33
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist",
33
34
  "build:bundle": "bun build src/index.ts --outdir dist --target node --format esm --sourcemap=external && bun build src/index.ts --outdir dist --target node --format cjs --outfile index.cjs --sourcemap=external && bun build src/presets/index.ts --outdir dist/presets --target node --format esm --sourcemap=external && bun build src/presets/index.ts --outdir dist/presets --target node --format cjs --outfile index.cjs --sourcemap=external",
34
35
  "test": "bun test",
35
36
  "test:watch": "bun test --watch",