The Logger singleton

For easiness the Logger API provides a singleton implementation of an ILogWrapper (the Logger singleton class).

This allows the programmer to use from several locations the same Logger instance if he wishes so without having himself to provide such a functionality. Not that it is difficult, but being so common we decided to include one in Logger out-of-the-box. It's purpose is to keep it as simple as possible so we decided do implement the default logger Log4J implementation. It you wish a different one you will have to create your own singleton access class.

Here's a simple usage example. The previous code implemented by Logger calls:

 1      public static void main(String[] args) {
 2              Logger.getLogger("Sample logger title", LogLevel.DEBUG);
 3              
 4              Logger.getLogger().debug("Sample log message 1...");
 5              Logger.getLogger().debug("Sample log message 2...");
 6
 7              Logger.getLogger().increaseIndentation();
 8              
 9              for (int i = 1; i<=5; i++)
10                      Logger.getLogger().debug("Iterating: cycle = " + i);
11              
12              Logger.getLogger().decreaseIndentation();
13              
14              Logger.getLogger().debug("end log!");
15      }

Note: Line 2 is intended to be the instanciator of the Logger, but if any previous call go getLogger (regardless of the arguments passed was made then the Logger will already have been instanciated and so the initialization parameters will be ignored.