|
| 1 | +const ACL = require("../index"); |
| 2 | + |
| 3 | +// Create a logger instance with custom color configuration |
| 4 | +const logger = new ACL({ |
| 5 | + includeTimestamps: true, // Include timestamps in all log messages. |
| 6 | + includeMemoryUsage: true, // Track and display memory usage information in the logs. |
| 7 | + memoryDisplayMode: 2, // Memory display mode: (1 = MB, 2 = %, 3 = both MB and %). |
| 8 | + generateReport: true, // Generate a report at the end of the logging session showing log method usage statistics. |
| 9 | + |
| 10 | + // Caller Information Settings |
| 11 | + includeCallerInfo: 1, // Enable the inclusion of caller information (file, line, and column) in log messages. |
| 12 | + callerInfoLevel: 3, // Minimum log level to include caller information (0 = debug, 1 = log, 2 = info, 3 = warn, etc.). |
| 13 | + callerInfoDisplayMode: 2, // Format for caller information display: |
| 14 | + // 1 = Multi-line format (shows file, function, line, and column separately). |
| 15 | + // 2 = Inline format (compact single line: file:line:column). |
| 16 | + |
| 17 | + // Inline Caller Information Settings |
| 18 | + includeInlineCallerInfo: 1, // Display inline caller information within the log message (quick debugging reference). |
| 19 | + inlineCallerInfoLevel: 3, // Minimum log level to include inline caller information (similar to `callerInfoLevel`). |
| 20 | + |
| 21 | + terminateOnFatal: true, // Terminate the application on a `fatal` log message. |
| 22 | +}); |
| 23 | + |
| 24 | +// Logging with different levels to demonstrate color differences |
| 25 | +logger.debug("This is a debug message."); |
| 26 | +logger.log("This is a regular log message."); |
| 27 | +logger.info("This is an informational message."); |
| 28 | +logger.warn("This is a warning message, it will include caller information."); |
| 29 | +logger.error("This is an error message, it will include caller information."); |
| 30 | +logger.fatal("This is a fatal message, terminating the process."); |
0 commit comments