Class | Description |
---|---|
Level |
A class representing a logging level.
|
Logger |
A
Messaging extension for logging. |
LoggerConfigurator |
A
LoggerConfigurator makes it possible to separate the configuration of any and all Logger s from the use of them. |
LoggerMessage |
A
Message extension containing various information about a log from a Logger . |
CIT Logger is a library that extends the library CIT Messaging with an API for logging.
This library mainly provides an abstraction for logging and not so much logging itself. This means that you will either have to use an existing extension of it, or build your own, in order to use it in a real scenario.
To use this library, you need to understand the concepts provided. So here follows an overview of the concepts.
Logger
is an implementation of Messaging
that provides methods for logging.Level
is a class that represents a logging level without any naming restrictions.LoggerConfigurator
is a mechanism that allows you to configure a Logger
in numerous ways.LoggerMessage
is a Message
implementation used as the message in a log by this API.The following example demonstrates how you can use this library.
Logger logger = Logger.newInstance();
logger.getMessageChannel().addMessageChannelObserver((messageChannel, message) -> System.out.printf("%s%n", message));
logger.start();
logger.info("Hello, World!");
The above example demonstrates the fact that a Logger
is nothing more than an empty shell by default. But it's flexible and allows you to configure it in many different ways. However, most of the time, you're
just interested in getting that Logger
, so you can log whatever it is that you want to log. You don't want to spend a lot of time configuring it every now and then. It's good, then, that we've taken care of that
for you.
The methods getInstance()
, getInstance(Class<?>)
and getInstance(String)
will delegate the responsibility of configuring to the current LoggerConfigurator
. But only the first time, when
they're created.