-
Notifications
You must be signed in to change notification settings - Fork 4
Getting Started (Logging)
The BaseLogger class in BlueLib provides a structured and versatile logging system that includes various log levels, allowing for precise tracking and debugging. This setup is tailored for BlueLib’s internal operations and is useful for keeping logs organized in library development.
The BaseLogLevel class introduces additional custom levels, including INFO, ERROR, WARNING, and SUCCESS. Notably, it includes the BlueLib log level, intended specifically for library-related messages within BlueLib.
While modders are free to utilize all logging levels and methods provided by BlueLib, the BlueLib level and the logBluelib method are specifically intended for library operations. They help maintain internal logs that are pertinent to BlueLib itself, such as debugging library-specific functionality or tracking library performance.
-
BlueLibLevel: Reserved for messages directly related to BlueLib’s internal processes. Using this level for mod-specific operations is not recommended, as it may obscure critical library logs. -
logBluelibMethod: A targeted logging method designed to log messages at theBlueLiblevel, ensuring they stand out as library-specific entries in the log files.
If you are developing a mod, avoid the BlueLib logging level and the logBluelib method to keep logs distinct and organized. Instead, use other log levels such as INFO, ERROR, Warning, or SUCCESS for mod-specific logs. This practice will help in distinguishing mod operations from the BlueLib library’s internal functionality.
-
Setting Up Logging
You can enable and disable the Logging through the Config that we setup! -
Using Log Levels
TheBaseLogLevelclass provides these primary levels:-
BaseLogLevel.INFO: Standard informational logs. -
BaseLogLevel.ERROR: Error messages. -
BaseLogLevel.WARNING: Warnings. -
BaseLogLevel.SUCCESS: Success messages. -
Note:
BaseLogLevel.BlueLibis for library-specific logs and should generally be avoided for mod operations.
-
-
Component-Based Logging
All messages passed into the logger useComponentinstances, allowing for styled, localized, and translatable text in the logs
// Log an info message
BaseLogger.log(BaseLogLevel.INFO, Component.literal("Application started successfully."));
// Log an error with an exception
BaseLogger.log(BaseLogLevel.ERROR, Component.literal("An error occurred during processing."), new RuntimeException("Sample Exception"));- Global Control: Enable or disable logging globally.
-
Custom Log Levels: Utilize custom log levels for mod development while reserving
BlueLibfor library-only logs. - Component System**: Logging uses Minecraft’s Component system to support translations and styled messages.
- Efficient Error Tracking: Log messages with exceptions for easier troubleshooting.
This setup offers a robust and customizable logging system for BlueLib, providing clarity and consistency across both library and mod development contexts. For further information and advanced customization options, refer to the official Discord community where you can seek help, share experiences, and learn from other developers.
Variant Loader
Data Pipeline
Network & Packets
Logging
Markdown
Utility Classes
- Conversion
- Math
- Minecraft
- Schedular