-
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.
-
BlueLib
Level: 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. -
logBluelib
Method: A targeted logging method designed to log messages at theBlueLib
level, 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
Enable general logging for BlueLib:BaseLogger.setLoggingEnabled(true);
-
Using Log Levels
TheBaseLogLevel
class provides these primary levels:-
BaseLogLevel.INFO
: Standard informational logs. -
BaseLogLevel.ERROR
: Error messages. -
BaseLogLevel.WARNING
: Warnings. -
BaseLogLevel.SUCCESS
: Success messages. -
Note:
BaseLogLevel.BlueLib
is for library-specific logs and should generally be avoided for mod operations.
-
// Enable general logging
BaseLogger.setLoggingEnabled(true);
// Log an info message
BaseLogger.log(BaseLogLevel.INFO, "Application started successfully.");
// Log an error with an exception
BaseLogger.log(BaseLogLevel.ERROR, "An error occurred during processing.", new RuntimeException("Sample Exception"));
Note: To ensure logging is enabled as early as possible, invoke
BaseLogger.setLoggingEnabled(true);
within the constructor of the mod.
- Global Control: Enable or disable logging globally.
-
Custom Log Levels: Utilize custom log levels for mod development while reserving
BlueLib
for library-only logs. - 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. You may also refer to our API Documentation.
Variant Loader
Logging
Interfaces
Utility Classes
- Conversion
- Math
- Minecraft