-
Notifications
You must be signed in to change notification settings - Fork 0
Usage Guide
Welcome to the usage guide, here all methods that are important for general use are mentioned with an explanation.
Installation is covered in quickstart please refer there for information regarding that.
To use the logger initialize with your preferred configuration and then just call the log methods. This will then show your log messages in the console highlighted with colours, if your command line supports ANSI colour codes. Below is a detailed list of methods and what they do/return.
All methods have their own contained error handling and should never cause the program they are logging to exit. On a non-recoverable error it will be reported and the Logger will fallback to Console logging only.
All methods intended for use have been detailed here. More public methods are included in the API, using these outside of the logger may cause undefined behavior, do so at your own risk.
Ensure that all app names are acceptable in your filing system, there is a builtin check but this may not be comprehensive. Do not include restricted characters or names as this may cause the logger to not work as expected.
// Start an application called app1 which is console only with default visibility
Logger.initializeLogger("app1", true);
// Start an application called app1 which is console only with customised visibility
Logger.initializeLogger("app1", LoggingType.logVisibilityAllFalse(), true);All log messages return a String that is a timestamp in the format "YYYY-MM-DD-HH:MM:SS". They also will create a log in the relevant file if the initialization specified to do so.
// Log an error message
Logger.logerror("This is an Error message");
// Log a progress message
Logger.logprogress("This is a progress message");
// Log an info message
Logger.loginfo("This is an info message");
// Log a warning message
Logger.logwarn("This is a warning message");
// Log a debug message
Logger.logdebug("This is a debug message");
// Log a miscellaneous message
Logger.logmiscellaneous("This is a miscellaneous message");It is important to note that hiding visibility does not stop the log being output to a file. That will occur regardless unless running in a console only environment.
// Change the currently held visibility of a single log type
Logger.changeLogVisibility(LoggingType.ERRORS, false);
// Change the currently help visibility map to a customised one
Logger.changeLogVisibilityMap(LoggingType.logVisibilityAllTrue());
// Get the current log visibility for a single log type
Logger.viewLogVisibility(LoggingType.WARN);
// Get the log visibility map
Logger.viewLogVisibilityMap();// Get the name of the application that is currently being logged for
Logger.getApplicationName();This class is used for working with the String timestamps produced by the Logger. Methods here do not directly check that a timestamp is valid. A malformed timestamp may crash an application.
// Decode a timestamp into a File object
TimestampDecoder.timestampToFile("2025-07-21-22:07:10");This enum class provides the core enum class which allows for logging different message types, it also provides methods which create LogVisibility HashMaps.
// Logging enum type
LoggingType.MISCELLANEOUS
LoggingType.INFO
LoggingType.WARN
LoggingType.DEBUG
LoggingType.PROGRESS
LoggingType.ERROR
// All logs will be visible
LoggingType.logVisibilityAllTrue();
// All logs will be hidden
LoggingType.logVisibilityAllFalse();
// Only error logs will be visible
LoggingType.errorOnlyHashMap();Created by @rhys-h-walker