@infosel-sdk/logger 0.1.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.
Files changed (47) hide show
  1. package/README.md +233 -0
  2. package/package.json +51 -0
  3. package/src/data/datasources/console_logger_datasource.d.ts +31 -0
  4. package/src/data/datasources/console_logger_datasource.js +96 -0
  5. package/src/data/datasources/console_logger_datasource.js.map +1 -0
  6. package/src/data/datasources/pino_logger_datasource.d.ts +32 -0
  7. package/src/data/datasources/pino_logger_datasource.js +103 -0
  8. package/src/data/datasources/pino_logger_datasource.js.map +1 -0
  9. package/src/data/di/logger_component_impl.d.ts +13 -0
  10. package/src/data/di/logger_component_impl.js +103 -0
  11. package/src/data/di/logger_component_impl.js.map +1 -0
  12. package/src/data/repositories/logger_repository_impl.d.ts +34 -0
  13. package/src/data/repositories/logger_repository_impl.js +58 -0
  14. package/src/data/repositories/logger_repository_impl.js.map +1 -0
  15. package/src/domain/datasources/logger_datasource.d.ts +16 -0
  16. package/src/domain/datasources/logger_datasource.js +3 -0
  17. package/src/domain/datasources/logger_datasource.js.map +1 -0
  18. package/src/domain/di/logger_component.d.ts +127 -0
  19. package/src/domain/di/logger_component.js +3 -0
  20. package/src/domain/di/logger_component.js.map +1 -0
  21. package/src/domain/entities/error_types.d.ts +39 -0
  22. package/src/domain/entities/error_types.js +6 -0
  23. package/src/domain/entities/error_types.js.map +1 -0
  24. package/src/domain/entities/index.d.ts +3 -0
  25. package/src/domain/entities/index.js +7 -0
  26. package/src/domain/entities/index.js.map +1 -0
  27. package/src/domain/entities/log_entry.d.ts +13 -0
  28. package/src/domain/entities/log_entry.js +3 -0
  29. package/src/domain/entities/log_entry.js.map +1 -0
  30. package/src/domain/entities/log_level.d.ts +13 -0
  31. package/src/domain/entities/log_level.js +23 -0
  32. package/src/domain/entities/log_level.js.map +1 -0
  33. package/src/domain/entities/logger_config.d.ts +52 -0
  34. package/src/domain/entities/logger_config.js +18 -0
  35. package/src/domain/entities/logger_config.js.map +1 -0
  36. package/src/domain/repositories/logger_repository.d.ts +47 -0
  37. package/src/domain/repositories/logger_repository.js +3 -0
  38. package/src/domain/repositories/logger_repository.js.map +1 -0
  39. package/src/domain/use_cases/log_error.d.ts +57 -0
  40. package/src/domain/use_cases/log_error.js +143 -0
  41. package/src/domain/use_cases/log_error.js.map +1 -0
  42. package/src/domain/use_cases/log_message.d.ts +21 -0
  43. package/src/domain/use_cases/log_message.js +29 -0
  44. package/src/domain/use_cases/log_message.js.map +1 -0
  45. package/src/index.d.ts +13 -0
  46. package/src/index.js +21 -0
  47. package/src/index.js.map +1 -0
@@ -0,0 +1,34 @@
1
+ import { LoggerDataSource } from '../../domain/datasources/logger_datasource';
2
+ import { LoggerRepository, LogOptions } from '../../domain/repositories/logger_repository';
3
+ import { LogLevel } from '../../domain/entities/log_level';
4
+ /**
5
+ * Implementation of logger repository
6
+ */
7
+ export declare class LoggerRepositoryImpl implements LoggerRepository {
8
+ private dataSource;
9
+ constructor(dataSource: LoggerDataSource);
10
+ /**
11
+ * Log a debug message
12
+ */
13
+ debug(message: string, options?: LogOptions): void;
14
+ /**
15
+ * Log an info message
16
+ */
17
+ info(message: string, options?: LogOptions): void;
18
+ /**
19
+ * Log a warning message
20
+ */
21
+ warn(message: string, options?: LogOptions): void;
22
+ /**
23
+ * Log an error message
24
+ */
25
+ error(message: string, options?: LogOptions): void;
26
+ /**
27
+ * Log a message with a specific level, service, and context
28
+ */
29
+ log(level: LogLevel, message: string, options?: LogOptions): void;
30
+ /**
31
+ * Check if a log level is enabled
32
+ */
33
+ isLevelEnabled(level: LogLevel): boolean;
34
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerRepositoryImpl = void 0;
4
+ const log_level_1 = require("../../domain/entities/log_level");
5
+ /**
6
+ * Implementation of logger repository
7
+ */
8
+ class LoggerRepositoryImpl {
9
+ constructor(dataSource) {
10
+ this.dataSource = dataSource;
11
+ }
12
+ /**
13
+ * Log a debug message
14
+ */
15
+ debug(message, options) {
16
+ this.log(log_level_1.LogLevel.DEBUG, message, options);
17
+ }
18
+ /**
19
+ * Log an info message
20
+ */
21
+ info(message, options) {
22
+ this.log(log_level_1.LogLevel.INFO, message, options);
23
+ }
24
+ /**
25
+ * Log a warning message
26
+ */
27
+ warn(message, options) {
28
+ this.log(log_level_1.LogLevel.WARN, message, options);
29
+ }
30
+ /**
31
+ * Log an error message
32
+ */
33
+ error(message, options) {
34
+ this.log(log_level_1.LogLevel.ERROR, message, options);
35
+ }
36
+ /**
37
+ * Log a message with a specific level, service, and context
38
+ */
39
+ log(level, message, options) {
40
+ const entry = {
41
+ level,
42
+ message,
43
+ timestamp: new Date(),
44
+ metadata: options === null || options === void 0 ? void 0 : options.metadata,
45
+ service: options === null || options === void 0 ? void 0 : options.service,
46
+ context: options === null || options === void 0 ? void 0 : options.context,
47
+ };
48
+ this.dataSource.log(entry);
49
+ }
50
+ /**
51
+ * Check if a log level is enabled
52
+ */
53
+ isLevelEnabled(level) {
54
+ return this.dataSource.isLevelEnabled(level);
55
+ }
56
+ }
57
+ exports.LoggerRepositoryImpl = LoggerRepositoryImpl;
58
+ //# sourceMappingURL=logger_repository_impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_repository_impl.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/data/repositories/logger_repository_impl.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAG3D;;GAEG;AACH,MAAa,oBAAoB;IAC/B,YAAoB,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;IAAG,CAAC;IAEpD;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,OAAoB;QACzC,IAAI,CAAC,GAAG,CAAC,oBAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,OAAoB;QACxC,IAAI,CAAC,GAAG,CAAC,oBAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,OAAoB;QACxC,IAAI,CAAC,GAAG,CAAC,oBAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,OAAoB;QACzC,IAAI,CAAC,GAAG,CAAC,oBAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,OAAoB;QACxD,MAAM,KAAK,GAAa;YACtB,KAAK;YACL,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ;YAC3B,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO;YACzB,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO;SAC1B,CAAC;QAEF,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,KAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF;AArDD,oDAqDC"}
@@ -0,0 +1,16 @@
1
+ import { LogEntry } from '../entities/log_entry';
2
+ /**
3
+ * Interface for logger data source operations
4
+ */
5
+ export interface LoggerDataSource {
6
+ /**
7
+ * Log a message
8
+ * @param entry Log entry to write
9
+ */
10
+ log(entry: LogEntry): void;
11
+ /**
12
+ * Check if a log level is enabled
13
+ * @param level Log level to check
14
+ */
15
+ isLevelEnabled(level: string): boolean;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=logger_datasource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_datasource.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/datasources/logger_datasource.ts"],"names":[],"mappings":""}
@@ -0,0 +1,127 @@
1
+ import { LoggerRepository, LogOptions } from '../repositories/logger_repository';
2
+ import { LogMessage } from '../use_cases/log_message';
3
+ import { LogError } from '../use_cases/log_error';
4
+ import { LogLevel } from '../entities/log_level';
5
+ import { DetectableError } from '../entities/error_types';
6
+ /**
7
+ * Logger component interface for dependency injection
8
+ */
9
+ export interface LoggerComponent {
10
+ /**
11
+ * Log a debug message
12
+ * @param message Message to log
13
+ * @param options Optional log options (metadata, service, context)
14
+ */
15
+ debug(message: string, options?: LogOptions): void;
16
+ /**
17
+ * Log an info message
18
+ * @param message Message to log
19
+ * @param options Optional log options (metadata, service, context)
20
+ */
21
+ info(message: string, options?: LogOptions): void;
22
+ /**
23
+ * Log a warning message
24
+ * @param message Message to log
25
+ * @param options Optional log options (metadata, service, context)
26
+ */
27
+ warn(message: string, options?: LogOptions): void;
28
+ /**
29
+ * Log an error message
30
+ * @param message Message to log
31
+ * @param options Optional log options (metadata, service, context)
32
+ */
33
+ error(message: string, options?: LogOptions): void;
34
+ /**
35
+ * Log a message with a specific level, service, and context
36
+ * This method uses Pino internally to generate structured logs with:
37
+ * - Timestamp (ISO 8601)
38
+ * - Log level (INFO, WARN, ERROR, DEBUG)
39
+ * - Service / Module name
40
+ * - Context of the event (e.g., login, reconnection, retransmission)
41
+ * - Clear message
42
+ *
43
+ * @param level Log level
44
+ * @param message Clear message describing the event
45
+ * @param options Log options including:
46
+ * - service: Service or module name
47
+ * - context: Event context (login, reconnection, etc.)
48
+ * - metadata: Additional structured data
49
+ *
50
+ * @example
51
+ * logger.log(LogLevel.INFO, 'User successfully logged in', {
52
+ * service: 'AuthService',
53
+ * context: 'login',
54
+ * metadata: { userId: '123', method: 'oauth' }
55
+ * });
56
+ */
57
+ log(level: LogLevel, message: string, options?: LogOptions): void;
58
+ /**
59
+ * Check if a log level is enabled
60
+ */
61
+ isLevelEnabled(level: LogLevel): boolean;
62
+ /**
63
+ * Get the logger repository
64
+ */
65
+ getRepository(): LoggerRepository;
66
+ /**
67
+ * Get the log message use case
68
+ */
69
+ getLogMessageUseCase(): LogMessage;
70
+ /**
71
+ * Log an error with automatic type detection and level determination
72
+ *
73
+ * Automatically detects if the error is from:
74
+ * - Axios: Extracts status, URL, method, response data
75
+ * - Fetch: Extracts status, URL, response
76
+ * - Standard Error: Extracts message and stack
77
+ *
78
+ * Determines log level based on HTTP status:
79
+ * - Status 400-499: WARN (client errors)
80
+ * - Status 500+: ERROR (server errors)
81
+ * - Other errors: ERROR
82
+ *
83
+ * @param message Clear message describing what failed
84
+ * @param error The error object (Axios, Fetch, Error, or any)
85
+ * @param options Optional service, context, and additional metadata
86
+ *
87
+ * @example
88
+ * // Axios error (status 404 → WARN)
89
+ * try {
90
+ * await axios.get('/api/user/123');
91
+ * } catch (error) {
92
+ * logger.logError('Failed to fetch user', error, {
93
+ * service: 'user-service',
94
+ * context: 'user-fetch'
95
+ * });
96
+ * }
97
+ *
98
+ * @example
99
+ * // Fetch error (status 500 → ERROR)
100
+ * try {
101
+ * const res = await fetch('/api/data');
102
+ * } catch (error) {
103
+ * logger.logError('Failed to fetch data', error, {
104
+ * service: 'api-service',
105
+ * context: 'data-fetch'
106
+ * });
107
+ * }
108
+ *
109
+ * @example
110
+ * // Standard error (→ ERROR)
111
+ * try {
112
+ * throw new Error('Database connection failed');
113
+ * } catch (error) {
114
+ * logger.logError('Database error', error, {
115
+ * service: 'database-service',
116
+ * context: 'connection'
117
+ * });
118
+ * }
119
+ */
120
+ logError(message: string, error: DetectableError, options?: Omit<LogOptions, 'metadata'> & {
121
+ metadata?: Record<string, unknown>;
122
+ }): void;
123
+ /**
124
+ * Get the log error use case
125
+ */
126
+ getLogErrorUseCase(): LogError;
127
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=logger_component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_component.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/di/logger_component.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Types for error detection and handling
3
+ */
4
+ export interface AxiosError extends Error {
5
+ isAxiosError: true;
6
+ response?: {
7
+ status: number;
8
+ statusText: string;
9
+ data?: any;
10
+ headers?: any;
11
+ };
12
+ request?: any;
13
+ config?: {
14
+ url?: string;
15
+ method?: string;
16
+ headers?: any;
17
+ data?: any;
18
+ };
19
+ code?: string;
20
+ }
21
+ export interface FetchError extends Error {
22
+ response?: Response;
23
+ status?: number;
24
+ statusText?: string;
25
+ }
26
+ export type DetectableError = Error | AxiosError | FetchError | unknown;
27
+ export interface ErrorInfo {
28
+ errorMessage: string;
29
+ errorStack?: string;
30
+ errorName?: string;
31
+ errorType: 'axios' | 'fetch' | 'standard' | 'unknown';
32
+ statusCode?: number;
33
+ statusText?: string;
34
+ url?: string;
35
+ method?: string;
36
+ responseData?: any;
37
+ requestData?: any;
38
+ errorCode?: string;
39
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Types for error detection and handling
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=error_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error_types.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/entities/error_types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -0,0 +1,3 @@
1
+ export * from './log_level';
2
+ export * from './log_entry';
3
+ export * from './logger_config';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./log_level"), exports);
5
+ tslib_1.__exportStar(require("./log_entry"), exports);
6
+ tslib_1.__exportStar(require("./logger_config"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/entities/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,sDAA4B;AAC5B,0DAAgC"}
@@ -0,0 +1,13 @@
1
+ import { LogLevel } from './log_level';
2
+ /**
3
+ * Represents a log entry
4
+ */
5
+ export interface LogEntry {
6
+ level: LogLevel;
7
+ message: string;
8
+ timestamp: Date;
9
+ metadata?: Record<string, unknown>;
10
+ prefix?: string;
11
+ service?: string;
12
+ context?: string;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=log_entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log_entry.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/entities/log_entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Log levels in order of severity
3
+ */
4
+ export declare enum LogLevel {
5
+ DEBUG = "debug",
6
+ INFO = "info",
7
+ WARN = "warn",
8
+ ERROR = "error"
9
+ }
10
+ /**
11
+ * Numeric values for log level comparison
12
+ */
13
+ export declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LOG_LEVEL_PRIORITY = exports.LogLevel = void 0;
4
+ /**
5
+ * Log levels in order of severity
6
+ */
7
+ var LogLevel;
8
+ (function (LogLevel) {
9
+ LogLevel["DEBUG"] = "debug";
10
+ LogLevel["INFO"] = "info";
11
+ LogLevel["WARN"] = "warn";
12
+ LogLevel["ERROR"] = "error";
13
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
14
+ /**
15
+ * Numeric values for log level comparison
16
+ */
17
+ exports.LOG_LEVEL_PRIORITY = {
18
+ [LogLevel.DEBUG]: 0,
19
+ [LogLevel.INFO]: 1,
20
+ [LogLevel.WARN]: 2,
21
+ [LogLevel.ERROR]: 3,
22
+ };
23
+ //# sourceMappingURL=log_level.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log_level.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/entities/log_level.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAED;;GAEG;AACU,QAAA,kBAAkB,GAA6B;IAC1D,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IACnB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAClB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAClB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;CACpB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { LogLevel } from './log_level';
2
+ /**
3
+ * Configuration options for the logger
4
+ */
5
+ export interface LoggerConfig {
6
+ /**
7
+ * Minimum log level to display
8
+ * @default LogLevel.INFO
9
+ */
10
+ minLevel?: LogLevel;
11
+ /**
12
+ * Enable timestamp in logs
13
+ * @default true
14
+ */
15
+ enableTimestamps?: boolean;
16
+ /**
17
+ * Enable colored console output
18
+ * @default true
19
+ */
20
+ enableColors?: boolean;
21
+ /**
22
+ * Custom prefix for all log messages
23
+ * @default undefined
24
+ */
25
+ prefix?: string;
26
+ /**
27
+ * Service or module name
28
+ * @default undefined
29
+ */
30
+ service?: string;
31
+ /**
32
+ * Use Pino for logging instead of console
33
+ * @default false
34
+ */
35
+ usePino?: boolean;
36
+ /**
37
+ * Pino pretty print options
38
+ * @default undefined
39
+ */
40
+ prettyPrint?: boolean;
41
+ /**
42
+ * Custom output function (useful for testing or custom transports)
43
+ * @default console.log
44
+ */
45
+ outputFn?: (message: string) => void;
46
+ }
47
+ /**
48
+ * Default logger configuration
49
+ */
50
+ export declare const DEFAULT_LOGGER_CONFIG: Required<Omit<LoggerConfig, 'outputFn'>> & {
51
+ outputFn?: (message: string) => void;
52
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_LOGGER_CONFIG = void 0;
4
+ const log_level_1 = require("./log_level");
5
+ /**
6
+ * Default logger configuration
7
+ */
8
+ exports.DEFAULT_LOGGER_CONFIG = {
9
+ minLevel: log_level_1.LogLevel.INFO,
10
+ enableTimestamps: true,
11
+ enableColors: true,
12
+ prefix: '',
13
+ service: '',
14
+ usePino: false,
15
+ prettyPrint: false,
16
+ outputFn: console.log,
17
+ };
18
+ //# sourceMappingURL=logger_config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_config.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/entities/logger_config.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAuDvC;;GAEG;AACU,QAAA,qBAAqB,GAAwF;IACxH,QAAQ,EAAE,oBAAQ,CAAC,IAAI;IACvB,gBAAgB,EAAE,IAAI;IACtB,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,OAAO,CAAC,GAAG;CACtB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { LogLevel } from '../entities/log_level';
2
+ export interface LogOptions {
3
+ metadata?: Record<string, unknown>;
4
+ service?: string;
5
+ context?: string;
6
+ }
7
+ /**
8
+ * Interface for logger repository operations
9
+ */
10
+ export interface LoggerRepository {
11
+ /**
12
+ * Log a debug message
13
+ * @param message Message to log
14
+ * @param options Optional log options (metadata, service, context)
15
+ */
16
+ debug(message: string, options?: LogOptions): void;
17
+ /**
18
+ * Log an info message
19
+ * @param message Message to log
20
+ * @param options Optional log options (metadata, service, context)
21
+ */
22
+ info(message: string, options?: LogOptions): void;
23
+ /**
24
+ * Log a warning message
25
+ * @param message Message to log
26
+ * @param options Optional log options (metadata, service, context)
27
+ */
28
+ warn(message: string, options?: LogOptions): void;
29
+ /**
30
+ * Log an error message
31
+ * @param message Message to log
32
+ * @param options Optional log options (metadata, service, context)
33
+ */
34
+ error(message: string, options?: LogOptions): void;
35
+ /**
36
+ * Log a message with a specific level, service, and context
37
+ * @param level Log level
38
+ * @param message Message to log
39
+ * @param options Log options (metadata, service, context)
40
+ */
41
+ log(level: LogLevel, message: string, options?: LogOptions): void;
42
+ /**
43
+ * Check if a log level is enabled
44
+ * @param level Log level to check
45
+ */
46
+ isLevelEnabled(level: LogLevel): boolean;
47
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=logger_repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_repository.js","sourceRoot":"","sources":["../../../../../../packages/logger/src/domain/repositories/logger_repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import { LoggerRepository, LogOptions } from '../repositories/logger_repository';
2
+ import { DetectableError } from '../entities/error_types';
3
+ /**
4
+ * Use case for intelligent error logging
5
+ * Automatically detects error type and determines appropriate log level
6
+ */
7
+ export declare class LogError {
8
+ private repository;
9
+ constructor(repository: LoggerRepository);
10
+ /**
11
+ * Log an error with automatic type detection and level determination
12
+ *
13
+ * Rules:
14
+ * - Axios/Fetch errors with status 400-499: WARN
15
+ * - Axios/Fetch errors with status 500+: ERROR
16
+ * - All other errors: ERROR
17
+ *
18
+ * @param message Clear message describing what failed
19
+ * @param error The error object to analyze
20
+ * @param options Additional log options (service, context, metadata)
21
+ */
22
+ execute(message: string, error: DetectableError, options?: Omit<LogOptions, 'metadata'> & {
23
+ metadata?: Record<string, unknown>;
24
+ }): void;
25
+ /**
26
+ * Analyze error and extract relevant information
27
+ */
28
+ private analyzeError;
29
+ /**
30
+ * Determine log level based on error info
31
+ */
32
+ private determineLogLevel;
33
+ /**
34
+ * Check if error is an Axios error
35
+ */
36
+ private isAxiosError;
37
+ /**
38
+ * Check if error is a Fetch error
39
+ */
40
+ private isFetchError;
41
+ /**
42
+ * Extract information from Axios error
43
+ */
44
+ private extractAxiosErrorInfo;
45
+ /**
46
+ * Extract information from Fetch error
47
+ */
48
+ private extractFetchErrorInfo;
49
+ /**
50
+ * Extract information from standard Error
51
+ */
52
+ private extractStandardErrorInfo;
53
+ /**
54
+ * Extract information from unknown error
55
+ */
56
+ private extractUnknownErrorInfo;
57
+ }