Skip to content

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

  1. The method receives a message and any number of optionalParams.
  2. It calls the _formatMessage method to format the message with a timestamp and log level.
  3. The formatted message is colored yellow using chalk.yellow.
  4. 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.