Console debugging utility.
HashLogger is a log-level based logger which permits, at runtime, to filter logs gravity.
🇫🇷 Egalement disponible en Français !
DEBUG
, INFO
, ERROR
, WARNING
, CRITICAL
, FATAL
Code :
/* ⬇️ Mandatory in order to log anything. */
public class Test implements HashLoggable {
HashLogger logger = new HashLogger(this, LogLevel.INFO);
/* ⬆️ Asked for a more precise targeting. */
public static void main(String[] args) {
/* ⬇️ Here is the targeting. */
logger.debug(this, "Debugging log.");
logger.info(this, "Information log.");
logger.error(this, "Error log.");
logger.warning(this, "Warning log.");
logger.critical(this, "Critical log.");
logger.fatal(this, "Fatal log.");
}
}
Console :
HashLogger instance created. Log level: INFO
[Tekore: Test.java] <INFO> Information log.
[Tekore: Test.java] <ERROR> Error log.
[Tekore: Test.java] <WARNING> Warning log.
[Tekore: Test.java] <CRITICAL> Critical log.
[Tekore: Test.java] <FATAL> Fatal log.
Tip
It is strongly recommended to have only one instance of HashLogger
at the root of your program.
- Timestamp logging.
logger.setShowTimestamp(true);
>>> [Tekore: Test.java] (02/02/2024 - 02:42:04) <ERROR> Error log.
- Short logging.
logger.setShortDisplay(true);
>>> [Tekore: Test.java] <ERR> Error log.
Exception
stack trace logging (uniquement pour les niveaux de logERROR
,CRITICAL
etFATAL
).
...
} catch (Exception exception) {
logger.critical(this, "Error while fetching data.", exception);
}
>>> [HashLogger: SQLManager.java] <CRITICAL> Error while fetching data.
Exception at fr.hashtek.hashlogger.HashLogger [...]
- Log history
logger.getHistory(); // Returns a list of HashLog
- Colors!