Class TakionLogger

java.lang.Object
me.croabeast.takion.logger.TakionLogger

public class TakionLogger extends Object
A sophisticated logger that bridges between Bukkit's built-in logging system and enhanced logging capabilities provided by external APIs (such as Paper and Prismatic).

The TakionLogger offers advanced message formatting, including prefix replacement, text colorization, and alignment based on configurable settings. It dynamically adapts to the server environment: if running on a Paper server with a supported version, it uses the PaperLogger implementation; otherwise, it falls back to Bukkit's logger.

Key Features:

  • Enhanced message formatting using a chain of text transformations.
  • Dynamic selection of logging backend (Paper or Bukkit).
  • Integration with external APIs like Prismatic for colorization and stripping of JSON formatting.

Usage Example:


 TakionLib lib = TakionLib.fromPlugin(myPlugin);
 TakionLogger logger = new TakionLogger(lib);
 logger.setColored(true).setStripPrefix(false);

 // Log multiple messages at INFO level
 logger.log(LogLevel.INFO, "This is a test message", "Another log entry");

 // Create a Bukkit-compatible logger for integration with other systems
 Logger bukkitLogger = TakionLogger.createBukkit(myPlugin);
 bukkitLogger.info("Bukkit log message with enhanced formatting!");
 
See Also:
  • Constructor Details

    • TakionLogger

      public TakionLogger(@NotNull @NotNull TakionLib lib, boolean usePlugin)
      Constructs a new TakionLogger.

      If usePlugin is true and a plugin is available from lib, the plugin's PluginLogger is used; otherwise, the global Bukkit.getLogger() is used. If running on Paper ≥ 1.18.2, initializes a new PaperLogger.

      Parameters:
      lib - the TakionLib instance
      usePlugin - whether to use the plugin-specific logger
    • TakionLogger

      public TakionLogger(@NotNull @NotNull TakionLib lib)
      Constructs a new TakionLogger using the plugin logger by default.
      Parameters:
      lib - the TakionLib instance
  • Method Details

    • log

      public void log(LogLevel level, Collection<String> messages)
      Logs a collection of messages at the given level.
      Parameters:
      level - the LogLevel to use (INFO if null)
      messages - the messages to log
    • log

      public void log(LogLevel level, String... messages)
      Logs multiple messages at the specified level.
      Parameters:
      level - the LogLevel to use (INFO if null)
      messages - the messages to log
    • log

      public void log(String... messages)
      Logs multiple messages at the default level (INFO).
      Parameters:
      messages - the messages to log
    • createBukkit

      public static Logger createBukkit(org.bukkit.plugin.Plugin plugin)
      Creates a Bukkit-compatible logger that applies enhanced formatting using the TakionLib formatter.

      This logger wraps a PluginLogger and overrides the log(LogRecord) method to process the message before output.

      Parameters:
      plugin - the plugin for which to create the logger
      Returns:
      a Logger instance that integrates with Bukkit's logging system