A convenient way to manage logging things to the console with colorful prefixes indicating their context. Each Logger instance stores its context type, context name, and prefix color, so you can use its log, warn, and error methods in the same manner that you would use the console methods with the same names. The prefix will be generated and prepended to the appropriate console message automatically.

If you are only logging a single message with a prefix in your plugin, you may use log, warn, or error instead of creating a Logger. Otherwise, using this class is much more convenient than specifying the type, name, and color for every message.

Example usage:

import { Logger } from "replugged";

const pluginLogger = Logger.plugin("SilentTyping");
pluginLogger.log("Hello", "world"); // Logs `[Replugged:Plugin:SilentTyping] Hello world`

Constructors

Properties

Methods

Constructors

  • Parameters

    • type: LoggerType

      Type of the context (e.g. API, Plugin, Coremod...)

    • name: string

      Name of the context (e.g. Notices, SilentTyping, Badges...)

    • color: string = blurple

      Color of the prefix as hex or a CSS color

    Returns Logger

Properties

color: string
name: string

Methods

  • Logs an error to the console, with an identifying prefix managed by the Logger instance.

    Parameters

    • Rest...data: [message?: any, ...optionalParams: any[]]

      Item(s) to print as an error

    Returns void

    The arguments for this method are the same as the arguments for console.error.

  • Logs a message to the console, with an identifying prefix managed by the Logger instance.

    Parameters

    • Rest...data: [message?: any, ...optionalParams: any[]]

      Item(s) to print as a message

    Returns void

    The arguments for this method are the same as the arguments for console.log.

  • Logs a warning to the console, with an identifying prefix managed by the Logger instance.

    Parameters

    • Rest...data: [message?: any, ...optionalParams: any[]]

      Item(s) to print as a warning

    Returns void

    The arguments for this method are the same as the arguments for console.warn.

  • Internal

    Convenience method to create a new Logger for a coremod.

    Parameters

    • name: string

      Name of the coremod

    • Optionalcolor: string

      Color of the prefix as hex or a CSS color (default: blurple)

    Returns Logger

    Logger with type "Coremod"

  • Convenience method to create a new Logger for a plugin.

    Parameters

    • name: string

      Name of the plugin

    • Optionalcolor: string

      Color of the prefix as hex or a CSS color (default: blurple)

    Returns Logger

    Logger with type "Plugin"