replugged
    Preparing search index...

    Class Logger

    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.

    import { Logger } from "replugged";

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

    Constructors

    • Parameters

      • type: LoggerType

        The context type of this logger, e.g. "Plugin" or "Coremod".

      • name: string

        The context name of this logger, e.g. the name of the plugin or coremod.

      • color: string = DEFAULT_COLOR

        The color of the prefix. This should be a valid CSS color string. If not specified, it defaults to a blurple color.

      Returns logger.Logger

    Properties

    color: string
    name: string

    Methods

    • Logs a message at the "error" level, which is visually distinct from regular logs and warnings. This is useful for logging error messages that indicate a failure or problem that needs attention.

      Parameters

      • ...data: any[]

        The item(s) to log.

      Returns void

    • Logs a message at the "info" level, which is visually distinct from regular logs. This is useful for logging informational messages that are more important than regular logs, but not as severe as warnings or errors.

      Parameters

      • ...data: any[]

        The item(s) to log.

      Returns void

    • Logs a message at the "log" level, which is the default logging level. This is useful for logging general messages that are not warnings or errors.

      Parameters

      • ...data: any[]

        The item(s) to log.

      Returns void

    • Logs a message at the "verbose" level, which is only visible when verbose logging is enabled in the console. This is useful for logging detailed information that may be too noisy for regular logging, but can be helpful for debugging.

      Parameters

      • ...data: any[]

        The item(s) to log.

      Returns void

    • Logs a message at the "warn" level, which is visually distinct from regular logs. This is useful for logging warning messages that indicate a potential issue or something that should be noted, but may not necessarily be a problem.

      Parameters

      • ...data: any[]

        The item(s) to log.

      Returns void

    • Internal

      Convenience method to create a new Logger for an API.

      Parameters

      • name: string

        The name of the API.

      • Optionalcolor: string

        The color of the prefix. This should be a valid CSS color string. If not specified, it defaults to a blurple color.

      Returns logger.Logger

      A Logger instance with the type set to "API".

    • Internal

      Convenience method to create a new Logger for a coremod.

      Parameters

      • name: string

        The name of the coremod.

      • Optionalcolor: string

        The color of the prefix. This should be a valid CSS color string. If not specified, it defaults to a blurple color.

      Returns logger.Logger

      A Logger instance with the type set to "Coremod".

    • Internal

      Convenience method to create a new Logger for a manager.

      Parameters

      • name: string

        The name of the manager.

      • Optionalcolor: string

        The color of the prefix. This should be a valid CSS color string. If not specified, it defaults to a blurple color.

      Returns logger.Logger

      A Logger instance with the type set to "Manager".

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

      Parameters

      • name: string

        The name of the plugin.

      • Optionalcolor: string

        The color of the prefix. This should be a valid CSS color string. If not specified, it defaults to a blurple color.

      Returns logger.Logger

      A Logger instance with the type set to "Plugin".