@wgtechlabs/log-engine 1.0.1 â 1.0.2
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/README.md +57 -13
- package/dist/formatter.js +54 -1
- package/dist/index.js +71 -1
- package/dist/logger.js +41 -0
- package/dist/types/index.js +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Log Engine
|
|
1
|
+
# Log Engine đđ [](https://github.com/wgtechlabs)
|
|
2
2
|
|
|
3
|
-
[](https://github.com/wgtechlabs/log-engine/actions/workflows/test.yml) [](https://codecov.io/gh/wgtechlabs/log-engine) [](https://www.npmjs.com/package/@wgtechlabs/log-engine) [](https://github.com/sponsors/wgtechlabs) [](https://github.com/wgtechlabs/log-engine/releases) [](https://github.com/wgtechlabs/log-engine/stargazers) [](https://github.com/wgtechlabs/log-engine/blob/main/license)
|
|
4
4
|
|
|
5
5
|
[](https://github.com/wgtechlabs/log-engine)
|
|
6
6
|
|
|
7
|
-
WG's Log Engine is the **ultimate logging solution for Node.js developers** - a lightweight, battle-tested utility specifically engineered for Discord bots, Telegram bots, web servers, APIs, and server-side applications. Born from real-world development challenges and proven in production environments like the [Unthread Discord Bot](https://github.com/wgtechlabs/unthread-discord-bot/), Log Engine delivers enterprise-grade logging with zero complexity.
|
|
7
|
+
WG's Log Engine is the **ultimate logging solution for Node.js developers** - a lightweight, battle-tested utility specifically engineered for Discord bots, Telegram bots, web servers, APIs, and server-side applications. Born from real-world development challenges and proven in production environments like the [Unthread Discord Bot](https://github.com/wgtechlabs/unthread-discord-bot/), Log Engine delivers enterprise-grade logging with zero complexity and beautiful color-coded console output.
|
|
8
8
|
|
|
9
|
-
**Stop wrestling with logging configurations and start building amazing applications.** Whether you're creating the next viral Discord community bot, building high-performance APIs, developing microservices, or deploying production servers, Log Engine provides intelligent terminal-based logging that scales with your application's growth - from your first "Hello World" to handling millions of requests across distributed systems.
|
|
9
|
+
**Stop wrestling with logging configurations and start building amazing applications.** Whether you're creating the next viral Discord community bot, building high-performance APIs, developing microservices, or deploying production servers, Log Engine provides intelligent terminal-based logging with vibrant colors that scales with your application's growth - from your first "Hello World" to handling millions of requests across distributed systems.
|
|
10
10
|
|
|
11
11
|
## âŖī¸ Motivation
|
|
12
12
|
|
|
@@ -18,22 +18,24 @@ Log Engine transforms your development experience from chaotic debugging session
|
|
|
18
18
|
|
|
19
19
|
- **Lightweight & Fast**: Minimal overhead with maximum performance - designed to enhance your application, not slow it down.
|
|
20
20
|
- **No Learning Curve**: Dead simple API that you can master in seconds. No extensive documentation, complex configurations, or setup required - Log Engine works instantly.
|
|
21
|
+
- **Colorized Console Output**: Beautiful ANSI color-coded log levels with intelligent terminal formatting - instantly identify message severity at a glance with color-coded output.
|
|
21
22
|
- **Multiple Log Levels**: Support for DEBUG, INFO, WARN, ERROR, and SILENT levels with smart filtering - just set your level and let it handle the rest.
|
|
22
23
|
- **Auto-Configuration**: Intelligent environment-based setup using NODE_ENV variables. No config files, initialization scripts, or manual setup - Log Engine works perfectly out of the box.
|
|
23
|
-
- **
|
|
24
|
+
- **Enhanced Formatting**: Structured log entries with dual timestamps (ISO + human-readable) and colored level indicators for maximum readability.
|
|
24
25
|
- **TypeScript Ready**: Full TypeScript support with comprehensive type definitions for a seamless development experience.
|
|
25
26
|
- **Zero Dependencies**: No external dependencies for maximum compatibility and security - keeps your bundle clean and your project simple.
|
|
26
27
|
- **Easy Integration**: Simple API that works seamlessly with existing Node.js applications. Just `import` and start logging - no middleware, plugins, or configuration required.
|
|
27
28
|
|
|
28
29
|
## đ¤ How It Works
|
|
29
|
-
|
|
30
|
+
<!-- markdownlint-disable MD051 -->
|
|
30
31
|
1. Log Engine automatically detects your environment using `NODE_ENV` and sets appropriate log levels for optimal performance
|
|
31
32
|
2. When you call logging methods, messages are filtered based on the configured severity level (only messages at or above the set level are displayed)
|
|
32
33
|
3. Each log message is instantly formatted with precise timestamps in both ISO and human-readable formats
|
|
33
|
-
4. Messages are output to the console with
|
|
34
|
+
4. Messages are output to the console with **colorized level indicators and timestamps**, making debugging and monitoring effortless - errors show in red, warnings in yellow, info in blue, and debug in purple
|
|
35
|
+
5. ANSI color codes ensure compatibility across different terminal environments while maintaining beautiful, readable output
|
|
34
36
|
|
|
35
37
|
Ready to streamline your application logging? Get started in seconds with our [simple installation](#đĻ-installation)!
|
|
36
|
-
|
|
38
|
+
<!-- markdownlint-enable MD051 -->
|
|
37
39
|
## đ¤ Special Thanks
|
|
38
40
|
|
|
39
41
|
<!-- markdownlint-disable MD033 -->
|
|
@@ -43,6 +45,12 @@ Ready to streamline your application logging? Get started in seconds with our [s
|
|
|
43
45
|
| <div align="center"><a href="https://unthread.com" target="_blank"><b>Unthread</b></a><br/>Streamlined support ticketing for modern teams.</div> |
|
|
44
46
|
<!-- markdownlint-enable MD033 -->
|
|
45
47
|
|
|
48
|
+
## đ¸ Sponsored Ads
|
|
49
|
+
|
|
50
|
+
Open source development is resource-intensive. These **sponsored ads help keep Log Engine free and actively maintained** while connecting you with tools and services that support open-source development.
|
|
51
|
+
|
|
52
|
+
[](https://gitads.dev/v1/ad-track?source=wgtechlabs/log-engine@github)
|
|
53
|
+
|
|
46
54
|
## đĻ Installation
|
|
47
55
|
|
|
48
56
|
Install the package using npm:
|
|
@@ -94,6 +102,27 @@ LogEngine.warn('Warning message');
|
|
|
94
102
|
LogEngine.error('Error message');
|
|
95
103
|
```
|
|
96
104
|
|
|
105
|
+
### Color-Coded Output đ¨
|
|
106
|
+
|
|
107
|
+
Log Engine now features beautiful, color-coded console output that makes debugging and monitoring a breeze:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { LogEngine } from '@wgtechlabs/log-engine';
|
|
111
|
+
|
|
112
|
+
// Each log level gets its own distinct color for instant recognition
|
|
113
|
+
LogEngine.debug('đ Debugging user authentication flow'); // Purple/Magenta
|
|
114
|
+
LogEngine.info('âšī¸ User successfully logged in'); // Blue
|
|
115
|
+
LogEngine.warn('â ī¸ API rate limit at 80% capacity'); // Yellow
|
|
116
|
+
LogEngine.error('â Database connection timeout'); // Red
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Why Colors Matter:**
|
|
120
|
+
|
|
121
|
+
- **Instant Recognition**: Quickly spot errors, warnings, and debug info without reading every line
|
|
122
|
+
- **Better Debugging**: Visually separate different types of messages during development
|
|
123
|
+
- **Production Monitoring**: Easily scan logs for critical issues in terminal environments
|
|
124
|
+
- **Enhanced Readability**: Color-coded timestamps and level indicators reduce eye strain
|
|
125
|
+
|
|
97
126
|
### Log Levels
|
|
98
127
|
|
|
99
128
|
Log Engine supports the following levels (in order of severity):
|
|
@@ -115,12 +144,24 @@ Log Engine automatically configures itself based on the `NODE_ENV` environment v
|
|
|
115
144
|
|
|
116
145
|
### Log Format
|
|
117
146
|
|
|
118
|
-
Log messages are formatted with timestamps and
|
|
147
|
+
Log messages are beautifully formatted with colorized timestamps, levels, and smart terminal output:
|
|
119
148
|
|
|
120
|
-
```
|
|
121
|
-
|
|
149
|
+
```bash
|
|
150
|
+
# Example colorized output (colors visible in terminal)
|
|
151
|
+
[2025-05-29T16:57:45.678Z][4:57 PM][DEBUG]: Debugging application flow
|
|
152
|
+
[2025-05-29T16:57:46.123Z][4:57 PM][INFO]: Server started successfully
|
|
153
|
+
[2025-05-29T16:57:47.456Z][4:57 PM][WARN]: API rate limit approaching
|
|
154
|
+
[2025-05-29T16:57:48.789Z][4:57 PM][ERROR]: Database connection failed
|
|
122
155
|
```
|
|
123
156
|
|
|
157
|
+
**Color Scheme:**
|
|
158
|
+
|
|
159
|
+
- đŖ **DEBUG**: Magenta/Purple - Detailed debugging information
|
|
160
|
+
- đĩ **INFO**: Blue - General informational messages
|
|
161
|
+
- đĄ **WARN**: Yellow - Warning messages that need attention
|
|
162
|
+
- đ´ **ERROR**: Red - Error messages requiring immediate action
|
|
163
|
+
- âĢ **Timestamps**: Gray (ISO) and Cyan (local time) for easy scanning
|
|
164
|
+
|
|
124
165
|
## đŦ Community Discussions
|
|
125
166
|
|
|
126
167
|
Join our community discussions to get help, share ideas, and connect with other users:
|
|
@@ -136,11 +177,12 @@ Join our community discussions to get help, share ideas, and connect with other
|
|
|
136
177
|
### Getting Help
|
|
137
178
|
|
|
138
179
|
Need assistance with the library? Here's how to get help:
|
|
139
|
-
|
|
180
|
+
<!-- markdownlint-disable MD051 -->
|
|
140
181
|
- **Community Support**: Check the [Help & Support](https://github.com/wgtechlabs/log-engine/discussions/categories/help-support) category in our GitHub Discussions for answers to common questions.
|
|
141
182
|
- **Ask a Question**: Create a [new discussion](https://github.com/wgtechlabs/log-engine/discussions/new?category=help-support) if you can't find answers to your specific issue.
|
|
142
183
|
- **Documentation**: Review the [usage instructions](#đšī¸-usage) in this README for common examples and configurations.
|
|
143
184
|
- **Known Issues**: Browse [existing issues](https://github.com/wgtechlabs/log-engine/issues) to see if your problem has already been reported.
|
|
185
|
+
<!-- markdownlint-enable MD051 -->
|
|
144
186
|
|
|
145
187
|
### Reporting Issues
|
|
146
188
|
|
|
@@ -187,4 +229,6 @@ This project is created by **[Waren Gonzaga](https://github.com/warengonzaga)**
|
|
|
187
229
|
|
|
188
230
|
---
|
|
189
231
|
|
|
190
|
-
đģ with â¤ī¸ by [Waren Gonzaga](https://warengonzaga.com) under [WG Technology Labs](https://wgtechlabs.com), and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) đ
|
|
232
|
+
đģ with â¤ī¸ by [Waren Gonzaga](https://warengonzaga.com) under [WG Technology Labs](https://wgtechlabs.com), and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) đ
|
|
233
|
+
|
|
234
|
+
<!-- GitAds-Verify: O4MESJK7VTBCELWNTFQAWB5HDX57H9MS -->
|
package/dist/formatter.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Log message formatter that provides colorized console output with timestamps
|
|
4
|
+
* Handles ANSI color codes and structured log message formatting
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.LogFormatter = void 0;
|
|
4
8
|
const types_1 = require("./types");
|
|
9
|
+
/**
|
|
10
|
+
* LogFormatter class responsible for formatting log messages with colors and timestamps
|
|
11
|
+
* Creates readable, colored console output with ISO timestamps and local time
|
|
12
|
+
*/
|
|
5
13
|
class LogFormatter {
|
|
14
|
+
/**
|
|
15
|
+
* Formats a log message with timestamp, level indicator, and appropriate coloring
|
|
16
|
+
* Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message
|
|
17
|
+
* @param level - The log level to format for
|
|
18
|
+
* @param message - The message content to format
|
|
19
|
+
* @returns Formatted string with ANSI colors and timestamps
|
|
20
|
+
*/
|
|
6
21
|
static format(level, message) {
|
|
7
22
|
const now = new Date();
|
|
8
23
|
const isoTimestamp = now.toISOString();
|
|
@@ -12,8 +27,18 @@ class LogFormatter {
|
|
|
12
27
|
hour12: true
|
|
13
28
|
});
|
|
14
29
|
const levelName = this.getLevelName(level);
|
|
15
|
-
|
|
30
|
+
const levelColor = this.getLevelColor(level);
|
|
31
|
+
// Apply colors to each component for better readability
|
|
32
|
+
const coloredTimestamp = `${this.colors.gray}[${isoTimestamp}]${this.colors.reset}`;
|
|
33
|
+
const coloredTimeString = `${this.colors.cyan}[${timeString}]${this.colors.reset}`;
|
|
34
|
+
const coloredLevel = `${levelColor}[${levelName}]${this.colors.reset}`;
|
|
35
|
+
return `${coloredTimestamp}${coloredTimeString}${coloredLevel}: ${message}`;
|
|
16
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts LogLevel enum to human-readable string
|
|
39
|
+
* @param level - The LogLevel to convert
|
|
40
|
+
* @returns String representation of the log level
|
|
41
|
+
*/
|
|
17
42
|
static getLevelName(level) {
|
|
18
43
|
switch (level) {
|
|
19
44
|
case types_1.LogLevel.DEBUG: return 'DEBUG';
|
|
@@ -24,5 +49,33 @@ class LogFormatter {
|
|
|
24
49
|
default: return 'UNKNOWN';
|
|
25
50
|
}
|
|
26
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Maps LogLevel to appropriate ANSI color code
|
|
54
|
+
* Colors help quickly identify message severity in console output
|
|
55
|
+
* @param level - The LogLevel to get color for
|
|
56
|
+
* @returns ANSI color escape sequence
|
|
57
|
+
*/
|
|
58
|
+
static getLevelColor(level) {
|
|
59
|
+
switch (level) {
|
|
60
|
+
case types_1.LogLevel.DEBUG: return this.colors.magenta; // Purple for debug info
|
|
61
|
+
case types_1.LogLevel.INFO: return this.colors.blue; // Blue for general info
|
|
62
|
+
case types_1.LogLevel.WARN: return this.colors.yellow; // Yellow for warnings
|
|
63
|
+
case types_1.LogLevel.ERROR: return this.colors.red; // Red for errors
|
|
64
|
+
case types_1.LogLevel.SILENT: return this.colors.dim; // Dim for silent (shouldn't be used)
|
|
65
|
+
default: return this.colors.white; // White for unknown levels
|
|
66
|
+
}
|
|
67
|
+
}
|
|
27
68
|
}
|
|
28
69
|
exports.LogFormatter = LogFormatter;
|
|
70
|
+
// ANSI color codes for terminal output styling
|
|
71
|
+
LogFormatter.colors = {
|
|
72
|
+
reset: '\x1b[0m', // Reset all formatting
|
|
73
|
+
dim: '\x1b[2m', // Dim/faded text
|
|
74
|
+
red: '\x1b[31m', // Red text (errors)
|
|
75
|
+
yellow: '\x1b[33m', // Yellow text (warnings)
|
|
76
|
+
blue: '\x1b[34m', // Blue text (info)
|
|
77
|
+
magenta: '\x1b[35m', // Magenta text (debug)
|
|
78
|
+
cyan: '\x1b[36m', // Cyan text (timestamps)
|
|
79
|
+
white: '\x1b[37m', // White text (default)
|
|
80
|
+
gray: '\x1b[90m' // Gray text (timestamps)
|
|
81
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for the Log Engine library
|
|
4
|
+
* Provides a simple, configurable logging interface with environment-based auto-configuration
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.LogLevel = exports.LogEngine = void 0;
|
|
4
8
|
const logger_1 = require("./logger");
|
|
5
9
|
const types_1 = require("./types");
|
|
10
|
+
// Create singleton logger instance
|
|
6
11
|
const logger = new logger_1.Logger();
|
|
7
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Determines the appropriate default log level based on NODE_ENV
|
|
14
|
+
* - production: WARN (reduce noise in production)
|
|
15
|
+
* - development: DEBUG (verbose logging for development)
|
|
16
|
+
* - test: ERROR (minimal logging during tests)
|
|
17
|
+
* - default: INFO (balanced logging for other environments)
|
|
18
|
+
* @returns The appropriate LogLevel for the current environment
|
|
19
|
+
*/
|
|
8
20
|
const getDefaultLogLevel = () => {
|
|
9
21
|
const nodeEnv = process.env.NODE_ENV;
|
|
10
22
|
switch (nodeEnv) {
|
|
@@ -18,12 +30,70 @@ const getDefaultLogLevel = () => {
|
|
|
18
30
|
return types_1.LogLevel.INFO;
|
|
19
31
|
}
|
|
20
32
|
};
|
|
33
|
+
// Initialize logger with environment-appropriate default level
|
|
21
34
|
logger.configure({ level: getDefaultLogLevel() });
|
|
35
|
+
/**
|
|
36
|
+
* Main LogEngine API - provides all logging functionality with a clean interface
|
|
37
|
+
* Auto-configured based on NODE_ENV, but can be reconfigured at runtime
|
|
38
|
+
*/
|
|
22
39
|
exports.LogEngine = {
|
|
40
|
+
/**
|
|
41
|
+
* Configure the logger with custom settings
|
|
42
|
+
* @param config - Partial configuration object containing level and/or environment
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* LogEngine.configure({ level: LogLevel.DEBUG });
|
|
46
|
+
* LogEngine.configure({ level: LogLevel.WARN, environment: 'staging' });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
23
49
|
configure: (config) => logger.configure(config),
|
|
50
|
+
/**
|
|
51
|
+
* Log a debug message (lowest priority)
|
|
52
|
+
* Only shown when log level is DEBUG or lower
|
|
53
|
+
* Useful for detailed diagnostic information during development
|
|
54
|
+
* @param message - The debug message to log
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* LogEngine.debug('User authentication flow started');
|
|
58
|
+
* LogEngine.debug(`Processing ${items.length} items`);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
24
61
|
debug: (message) => logger.debug(message),
|
|
62
|
+
/**
|
|
63
|
+
* Log an informational message
|
|
64
|
+
* General information about application flow and state
|
|
65
|
+
* Shown when log level is INFO or lower
|
|
66
|
+
* @param message - The info message to log
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* LogEngine.info('Application started successfully');
|
|
70
|
+
* LogEngine.info('User logged in: john@example.com');
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
25
73
|
info: (message) => logger.info(message),
|
|
74
|
+
/**
|
|
75
|
+
* Log a warning message
|
|
76
|
+
* Indicates potential issues that don't prevent operation
|
|
77
|
+
* Shown when log level is WARN or lower
|
|
78
|
+
* @param message - The warning message to log
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* LogEngine.warn('API rate limit approaching');
|
|
82
|
+
* LogEngine.warn('Deprecated function called');
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
26
85
|
warn: (message) => logger.warn(message),
|
|
86
|
+
/**
|
|
87
|
+
* Log an error message (highest priority)
|
|
88
|
+
* Indicates serious problems that need attention
|
|
89
|
+
* Always shown unless log level is SILENT
|
|
90
|
+
* @param message - The error message to log
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* LogEngine.error('Database connection failed');
|
|
94
|
+
* LogEngine.error('Authentication token expired');
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
27
97
|
error: (message) => logger.error(message)
|
|
28
98
|
};
|
|
29
99
|
var types_2 = require("./types");
|
package/dist/logger.js
CHANGED
|
@@ -1,38 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Core Logger class that handles log message output with configurable levels
|
|
4
|
+
* Supports DEBUG, INFO, WARN, ERROR levels with intelligent filtering
|
|
5
|
+
* Uses colorized console output with timestamps for better readability
|
|
6
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.Logger = void 0;
|
|
4
9
|
const types_1 = require("./types");
|
|
5
10
|
const formatter_1 = require("./formatter");
|
|
11
|
+
/**
|
|
12
|
+
* Logger class responsible for managing log output and configuration
|
|
13
|
+
* Provides level-based filtering and formatted console output
|
|
14
|
+
*/
|
|
6
15
|
class Logger {
|
|
7
16
|
constructor() {
|
|
17
|
+
// Internal configuration state with sensible defaults
|
|
8
18
|
this.config = {
|
|
9
19
|
level: types_1.LogLevel.INFO
|
|
10
20
|
};
|
|
11
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Updates logger configuration with new settings
|
|
24
|
+
* Merges provided config with existing settings (partial update)
|
|
25
|
+
* @param config - Partial configuration object to apply
|
|
26
|
+
*/
|
|
12
27
|
configure(config) {
|
|
13
28
|
this.config = { ...this.config, ...config };
|
|
14
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Determines if a message should be logged based on current log level
|
|
32
|
+
* Messages are shown only if their level >= configured minimum level
|
|
33
|
+
* @param level - The log level of the message to check
|
|
34
|
+
* @returns true if message should be logged, false otherwise
|
|
35
|
+
*/
|
|
15
36
|
shouldLog(level) {
|
|
16
37
|
return level >= this.config.level;
|
|
17
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Log a debug message with DEBUG level formatting
|
|
41
|
+
* Uses console.log for output with purple/magenta coloring
|
|
42
|
+
* @param message - The debug message to log
|
|
43
|
+
*/
|
|
18
44
|
debug(message) {
|
|
19
45
|
if (this.shouldLog(types_1.LogLevel.DEBUG)) {
|
|
20
46
|
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.DEBUG, message);
|
|
21
47
|
console.log(formatted);
|
|
22
48
|
}
|
|
23
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Log an informational message with INFO level formatting
|
|
52
|
+
* Uses console.log for output with blue coloring
|
|
53
|
+
* @param message - The info message to log
|
|
54
|
+
*/
|
|
24
55
|
info(message) {
|
|
25
56
|
if (this.shouldLog(types_1.LogLevel.INFO)) {
|
|
26
57
|
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.INFO, message);
|
|
27
58
|
console.log(formatted);
|
|
28
59
|
}
|
|
29
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Log a warning message with WARN level formatting
|
|
63
|
+
* Uses console.warn for output with yellow coloring
|
|
64
|
+
* @param message - The warning message to log
|
|
65
|
+
*/
|
|
30
66
|
warn(message) {
|
|
31
67
|
if (this.shouldLog(types_1.LogLevel.WARN)) {
|
|
32
68
|
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.WARN, message);
|
|
33
69
|
console.warn(formatted);
|
|
34
70
|
}
|
|
35
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Log an error message with ERROR level formatting
|
|
74
|
+
* Uses console.error for output with red coloring
|
|
75
|
+
* @param message - The error message to log
|
|
76
|
+
*/
|
|
36
77
|
error(message) {
|
|
37
78
|
if (this.shouldLog(types_1.LogLevel.ERROR)) {
|
|
38
79
|
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.ERROR, message);
|
package/dist/types/index.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for the Log Engine library
|
|
4
|
+
* Provides strongly-typed interfaces for configuration and log levels
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.LogLevel = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Log levels in order of priority (lowest to highest)
|
|
10
|
+
* Higher numeric values represent higher priority levels
|
|
11
|
+
* When a level is set, only messages at that level or higher are shown
|
|
12
|
+
*/
|
|
4
13
|
var LogLevel;
|
|
5
14
|
(function (LogLevel) {
|
|
15
|
+
/** Detailed diagnostic information, typically only of interest during development */
|
|
6
16
|
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
17
|
+
/** General information about application flow and state */
|
|
7
18
|
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
19
|
+
/** Potentially harmful situations that don't prevent operation */
|
|
8
20
|
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
21
|
+
/** Error events that might still allow the application to continue */
|
|
9
22
|
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
23
|
+
/** Completely disable all logging output */
|
|
10
24
|
LogLevel[LogLevel["SILENT"] = 4] = "SILENT";
|
|
11
25
|
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|