Skip to content

Logger.warn

Summary

The warn method formats a warning message with a yellow color and returns it along with any additional parameters.

Example Usage

javascript
import { Logger } from 'utility/Logger.js';

Logger.includeTrace = true; // optional for more information

const formattedWarnMessage = logger.warn("This is a warning message", {
  additional: "info",
});
console.log(...formattedWarnMessage);

Code Analysis

Inputs

  • message: The main warning message to format.
  • ...optionalParams: Additional parameters to include with the formatted message.

Flow

  1. The method receives a message and any number of optionalParams.
  2. It calls the _formatMessage method with 'WARN' as the level and the provided message.
  3. The formatted message is then colored yellow using chalk.yellow.
  4. The method returns an array containing the yellow-colored message and any optionalParams.

Outputs

  • An array containing the yellow-colored formatted warning message and any additional parameters.