-
Notifications
You must be signed in to change notification settings - Fork 0
Using the "Logger"
Logger consists of adding processing to allow the transmission and storage of messages following events.
This class is a default Logger if the user does not want to create one himself by implementing ILogger, by default all Levels are activated.
/**
* This constructor allows you to create a Logger. It is usually created from the Factory itself.
*
* @param name The name of the Logger.
* @param loggerFactory The Logger Factory.
*/
public Logger(@NotNull final String name, @NotNull final ILoggerFactory loggerFactory) {
this.name = name;
this.loggerFactory = loggerFactory;
}
Primarily the Logger will serve from a classroom, but it can also be used for other purposes coming from the imagination of the user. You will find some examples of use below.
final ILogger logger1 = this.loggerFactory.getLogger("Logger1");
final Logger logger1_ = (Logger) logger1;
final Logger mainClassLogger = (Logger) this.loggerFactory.getLogger(this.getClass());
final ILogger mainClassLogger_ = mainClassLogger;
final Logger _mainClassLogger = (Logger) this.loggerFactory.getLogger(MainClass.class);
final ILogger _mainClassLogger_ = _mainClassLogger;
The Levels in the Logger?
By default all Levels are enabled. But you can turn them off and back on as you like. You can also check if a Levels is active.
logger1.isDebugging();
logger1.activateDebugging();
logger1.deactivateDebugging();
logger1.isInforming();
logger1.activateInforming();
logger1.deactivateInforming();
logger1.isErroring();
logger1.activateErroring();
logger1.deactivateErroring();
logger1.isTracing();
logger1.activateTracing();
logger1.deactivateTracing();
logger1.isWarning();
logger1.activateWarning();
logger1.deactivateWarning();
Depending on the Levels you want to log you could do in several ways, some of which are presented to you.
logger1.debug("message");
logger1.info("message", new Throwable("with errors"));
logger1.error("{MessageFormater}", new Object());
logger1.trace("{MessageFormater}", new Object(), new Object());
logger1.warn("{MessageFormater}", new Object(), new Object(), ...);
RemasteredLogger is a logger as simple as it is complex, it uses SLF4j as an API base. This logger provides the developer with ease of use for a wide variety of utility. This also allows the simplicity of saving under several loggers but also the complexity of being able to create “Class” or single event loggers.
Class | Version | Security |
---|---|---|
Logger | ||
ILogger | ||
LoggerFactory | ||
ILoggerFactory |
// https://mvnrepository.com/artifact/codes.wesley-dev/remasteredlogger
implementation group: 'codes.wesley-dev', name: 'remasteredlogger', version: '1.1.4'
Jetbrains Annotations
SLF4j
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.0-alpha1'
// https://mvnrepository.com/artifact/org.jetbrains/annotations
implementation group: 'org.jetbrains', name: 'annotations', version: '20.1.0'
Version | Java Compatibility |
---|---|
1.1.4 | Java 8 and Upper |
1.1.3 | Java 9 and Upper |
<= 1.1.2 | ❌ (Security and Compatibility) |
Wesley Levasseur — Creator, Initial Work - KanekiReal