Class Logging
This class provides methods to log messages with different severity levels (INFO, DONE, ERROR, WARNING) along with timestamps. It also includes a method to print software information and a set to manage warning keys to prevent excessive logging.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getDate()
Returns the current timestamp formatted as a string.static String
Returns the current timestamp formatted as a string.static void
Logs a message indicating completion with a timestamp.static void
Logs an error message to the console with a timestamp.static void
Logs an informational message to the console with a timestamp.static void
logWarning
(String msg) Logs a warning message to the console with a timestamp.static void
logWarningOnce
(String key, String msg) Logs a warning message to the console with a timestamp, but only once for each unique key.static void
Prints the software information to the console.
-
Field Details
-
logDump
Set to keep track of logged warnings to avoid duplicate messages.
-
-
Constructor Details
-
Logging
public Logging()
-
-
Method Details
-
printSoftwareInfo
public static void printSoftwareInfo()Prints the software information to the console.This method displays the software name, version, and license in a formatted manner. The output is styled using ANSI escape codes for background and text color.
Note: The software information is retrieved from the
Musial
class. -
logInfo
Logs an informational message to the console with a timestamp.This method formats the message with a timestamp and a "STATUS" label styled using ANSI escape codes. The formatted message is then printed to the console.
- Parameters:
msg
- The informational message to be logged.
-
logDone
Logs a message indicating completion with a timestamp.This method formats the message with a timestamp and a "DONE" label styled using ANSI escape codes. The formatted message is then printed to the console.
- Parameters:
msg
- The message indicating completion to be logged.
-
logError
Logs an error message to the console with a timestamp.This method formats the message with a timestamp and an "ERROR" label styled using ANSI escape codes. The formatted message is then printed to the console.
- Parameters:
msg
- The error message to be logged.
-
logWarning
Logs a warning message to the console with a timestamp.This method formats the message with a timestamp and a "WARNING" label styled using ANSI escape codes. The formatted message is then printed to the console.
- Parameters:
msg
- The warning message to be logged.
-
logWarningOnce
Logs a warning message to the console with a timestamp, but only once for each unique key.This method checks if the warning message with the specified key has already been logged. If not, it logs the message and adds the key to the set of logged warnings.
- Parameters:
key
- The unique key for the warning message.msg
- The warning message to be logged.
-
getTimestamp
Returns the current timestamp formatted as a string.This method retrieves the current date and time, formats it using the specified date format, and returns it as a string.
- Returns:
- The current timestamp formatted as a string.
-
getDate
Returns the current timestamp formatted as a string.This method retrieves the current date, formats it using the specified date format, and returns it as a string.
- Returns:
- The current timestamp formatted as a string.
-