Package me.croabeast.takion.logger
Class TakionLogger
java.lang.Object
me.croabeast.takion.logger.TakionLogger
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 Summary
ConstructorsConstructorDescriptionTakionLogger(@NotNull TakionLib lib) Constructs a newTakionLoggerusing the plugin logger by default.TakionLogger(@NotNull TakionLib lib, boolean usePlugin) Constructs a newTakionLogger. -
Method Summary
Modifier and TypeMethodDescriptionstatic LoggercreateBukkit(org.bukkit.plugin.Plugin plugin) Creates a Bukkit-compatible logger that applies enhanced formatting using the TakionLib formatter.voidLogs multiple messages at the default level (INFO).voidLogs multiple messages at the specified level.voidlog(LogLevel level, Collection<String> messages) Logs a collection of messages at the given level.
-
Constructor Details
-
TakionLogger
Constructs a newTakionLogger.If
usePluginistrueand a plugin is available fromlib, the plugin'sPluginLoggeris used; otherwise, the globalBukkit.getLogger()is used. If running on Paper ≥ 1.18.2, initializes a newPaperLogger.- Parameters:
lib- theTakionLibinstanceusePlugin- whether to use the plugin-specific logger
-
TakionLogger
Constructs a newTakionLoggerusing the plugin logger by default.- Parameters:
lib- theTakionLibinstance
-
-
Method Details
-
log
Logs a collection of messages at the given level.- Parameters:
level- theLogLevelto use (INFO ifnull)messages- the messages to log
-
log
Logs multiple messages at the specified level.- Parameters:
level- theLogLevelto use (INFO ifnull)messages- the messages to log
-
log
Logs multiple messages at the default level (INFO).- Parameters:
messages- the messages to log
-
createBukkit
Creates a Bukkit-compatible logger that applies enhanced formatting using the TakionLib formatter.This logger wraps a
PluginLoggerand overrides thelog(LogRecord)method to process the message before output.- Parameters:
plugin- the plugin for which to create the logger- Returns:
- a
Loggerinstance that integrates with Bukkit's logging system
-