@wgtechlabs/log-engine 1.0.2 → 1.0.3

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,34 @@
1
+ /**
2
+ * Log message formatter that provides colorized console output with timestamps
3
+ * Handles ANSI color codes and structured log message formatting
4
+ */
5
+ import { LogLevel } from './types';
6
+ /**
7
+ * LogFormatter class responsible for formatting log messages with colors and timestamps
8
+ * Creates readable, colored console output with ISO timestamps and local time
9
+ */
10
+ export declare class LogFormatter {
11
+ private static readonly colors;
12
+ /**
13
+ * Formats a log message with timestamp, level indicator, and appropriate coloring
14
+ * Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message
15
+ * @param level - The log level to format for
16
+ * @param message - The message content to format
17
+ * @returns Formatted string with ANSI colors and timestamps
18
+ */
19
+ static format(level: LogLevel, message: string): string;
20
+ /**
21
+ * Converts LogLevel enum to human-readable string
22
+ * @param level - The LogLevel to convert
23
+ * @returns String representation of the log level
24
+ */
25
+ private static getLevelName;
26
+ /**
27
+ * Maps LogLevel to appropriate ANSI color code
28
+ * Colors help quickly identify message severity in console output
29
+ * @param level - The LogLevel to get color for
30
+ * @returns ANSI color escape sequence
31
+ */
32
+ private static getLevelColor;
33
+ }
34
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC;;;GAGG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAU5B;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAoBvD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAU/B"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Main entry point for the Log Engine library
3
+ * Provides a simple, configurable logging interface with environment-based auto-configuration
4
+ */
5
+ import { LoggerConfig } from './types';
6
+ /**
7
+ * Main LogEngine API - provides all logging functionality with a clean interface
8
+ * Auto-configured based on NODE_ENV, but can be reconfigured at runtime
9
+ */
10
+ export declare const LogEngine: {
11
+ /**
12
+ * Configure the logger with custom settings
13
+ * @param config - Partial configuration object containing level and/or environment
14
+ * @example
15
+ * ```typescript
16
+ * LogEngine.configure({ level: LogLevel.DEBUG });
17
+ * LogEngine.configure({ level: LogLevel.WARN, environment: 'staging' });
18
+ * ```
19
+ */
20
+ configure: (config: Partial<LoggerConfig>) => void;
21
+ /**
22
+ * Log a debug message (lowest priority)
23
+ * Only shown when log level is DEBUG or lower
24
+ * Useful for detailed diagnostic information during development
25
+ * @param message - The debug message to log
26
+ * @example
27
+ * ```typescript
28
+ * LogEngine.debug('User authentication flow started');
29
+ * LogEngine.debug(`Processing ${items.length} items`);
30
+ * ```
31
+ */
32
+ debug: (message: string) => void;
33
+ /**
34
+ * Log an informational message
35
+ * General information about application flow and state
36
+ * Shown when log level is INFO or lower
37
+ * @param message - The info message to log
38
+ * @example
39
+ * ```typescript
40
+ * LogEngine.info('Application started successfully');
41
+ * LogEngine.info('User logged in: john@example.com');
42
+ * ```
43
+ */
44
+ info: (message: string) => void;
45
+ /**
46
+ * Log a warning message
47
+ * Indicates potential issues that don't prevent operation
48
+ * Shown when log level is WARN or lower
49
+ * @param message - The warning message to log
50
+ * @example
51
+ * ```typescript
52
+ * LogEngine.warn('API rate limit approaching');
53
+ * LogEngine.warn('Deprecated function called');
54
+ * ```
55
+ */
56
+ warn: (message: string) => void;
57
+ /**
58
+ * Log an error message (highest priority)
59
+ * Indicates serious problems that need attention
60
+ * Always shown unless log level is SILENT
61
+ * @param message - The error message to log
62
+ * @example
63
+ * ```typescript
64
+ * LogEngine.error('Database connection failed');
65
+ * LogEngine.error('Authentication token expired');
66
+ * ```
67
+ */
68
+ error: (message: string) => void;
69
+ };
70
+ export { LogLevel, LoggerConfig } from './types';
71
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAY,YAAY,EAAE,MAAM,SAAS,CAAC;AA8BjD;;;GAGG;AACH,eAAO,MAAM,SAAS;IAClB;;;;;;;;OAQG;wBACiB,OAAO,CAAC,YAAY,CAAC;IAEzC;;;;;;;;;;OAUG;qBACc,MAAM;IAEvB;;;;;;;;;;OAUG;oBACa,MAAM;IAEtB;;;;;;;;;;OAUG;oBACa,MAAM;IAEtB;;;;;;;;;;OAUG;qBACc,MAAM;CAC1B,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Core Logger class that handles log message output with configurable levels
3
+ * Supports DEBUG, INFO, WARN, ERROR levels with intelligent filtering
4
+ * Uses colorized console output with timestamps for better readability
5
+ */
6
+ import { LoggerConfig } from './types';
7
+ /**
8
+ * Logger class responsible for managing log output and configuration
9
+ * Provides level-based filtering and formatted console output
10
+ */
11
+ export declare class Logger {
12
+ private config;
13
+ /**
14
+ * Updates logger configuration with new settings
15
+ * Merges provided config with existing settings (partial update)
16
+ * @param config - Partial configuration object to apply
17
+ */
18
+ configure(config: Partial<LoggerConfig>): void;
19
+ /**
20
+ * Determines if a message should be logged based on current log level
21
+ * Messages are shown only if their level >= configured minimum level
22
+ * @param level - The log level of the message to check
23
+ * @returns true if message should be logged, false otherwise
24
+ */
25
+ private shouldLog;
26
+ /**
27
+ * Log a debug message with DEBUG level formatting
28
+ * Uses console.log for output with purple/magenta coloring
29
+ * @param message - The debug message to log
30
+ */
31
+ debug(message: string): void;
32
+ /**
33
+ * Log an informational message with INFO level formatting
34
+ * Uses console.log for output with blue coloring
35
+ * @param message - The info message to log
36
+ */
37
+ info(message: string): void;
38
+ /**
39
+ * Log a warning message with WARN level formatting
40
+ * Uses console.warn for output with yellow coloring
41
+ * @param message - The warning message to log
42
+ */
43
+ warn(message: string): void;
44
+ /**
45
+ * Log an error message with ERROR level formatting
46
+ * Uses console.error for output with red coloring
47
+ * @param message - The error message to log
48
+ */
49
+ error(message: string): void;
50
+ }
51
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAY,YAAY,EAAE,MAAM,SAAS,CAAC;AAGjD;;;GAGG;AACH,qBAAa,MAAM;IAEf,OAAO,CAAC,MAAM,CAEZ;IAEF;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAI9C;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAIjB;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO5B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO3B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO3B;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAM/B"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Type definitions for the Log Engine library
3
+ * Provides strongly-typed interfaces for configuration and log levels
4
+ */
5
+ /**
6
+ * Log levels in order of priority (lowest to highest)
7
+ * Higher numeric values represent higher priority levels
8
+ * When a level is set, only messages at that level or higher are shown
9
+ */
10
+ export declare enum LogLevel {
11
+ /** Detailed diagnostic information, typically only of interest during development */
12
+ DEBUG = 0,
13
+ /** General information about application flow and state */
14
+ INFO = 1,
15
+ /** Potentially harmful situations that don't prevent operation */
16
+ WARN = 2,
17
+ /** Error events that might still allow the application to continue */
18
+ ERROR = 3,
19
+ /** Completely disable all logging output */
20
+ SILENT = 4
21
+ }
22
+ /**
23
+ * Represents a single log entry with timestamp, level, and message
24
+ * Used internally for structured logging operations
25
+ */
26
+ export interface LogEntry {
27
+ /** When the log entry was created */
28
+ timestamp: Date;
29
+ /** The severity level of this log entry */
30
+ level: LogLevel;
31
+ /** The actual log message content */
32
+ message: string;
33
+ }
34
+ /**
35
+ * Configuration options for the logger
36
+ * All properties are optional to allow partial updates
37
+ */
38
+ export interface LoggerConfig {
39
+ /** Minimum log level to display (filters out lower priority messages) */
40
+ level: LogLevel;
41
+ /** Optional environment identifier for context (e.g., 'production', 'staging') */
42
+ environment?: string;
43
+ }
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,oBAAY,QAAQ;IAChB,qFAAqF;IACrF,KAAK,IAAI;IACT,2DAA2D;IAC3D,IAAI,IAAI;IACR,kEAAkE;IAClE,IAAI,IAAI;IACR,sEAAsE;IACtE,KAAK,IAAI;IACT,4CAA4C;IAC5C,MAAM,IAAI;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,qCAAqC;IACrC,SAAS,EAAE,IAAI,CAAC;IAChB,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,yEAAyE;IACzE,KAAK,EAAE,QAAQ,CAAC;IAChB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wgtechlabs/log-engine",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A lightweight and efficient logging utility designed specifically for bot applications running on Node.js.",
5
5
  "keywords": [
6
6
  "logging",