Logger.writeWarn
Summary
The writeWarn method logs a warning message to the console with a yellow color. It formats the message with a timestamp, log level, and optionally includes the function name and stack trace information.
Example Usage
javascript
import { Logger } from 'utility/Logger.js';
Logger.includeTrace = true; // optional for more information
Logger.writeWarn("This is a warning message", { additional: "info" });Code Analysis
Inputs
message: The main warning message to log....optionalParams: Additional parameters to log alongside the message.
Flow
- The method receives a
messageand any number ofoptionalParams. - It calls the
_formatMessagemethod to format the message with a timestamp and log level. - The formatted message is colored yellow using
chalk.yellow. - The method logs the colored message and any additional parameters to the console using
console.warn.
Outputs
- Logs a formatted and colored warning message to the console.