Revised July 3, 2007

Singleton(2.2)

Design, code and test a class, caller a logger, to log messages to a file. Only one instance of this class should exist in an entire program. The key method of the class, log, takes a string and appends it to a file. This method is called from various locations of an application to record "interesting events" of the execution.

Parameterize the logger with the name of the log file and an integer verbosity level (the higher the level the more verbose the log). These parameters do not change during the lifetime of the logger.

Code a driver program to test the logger. Obviously, you will use the Singleton pattern for your implementation. Would there be any advantage or disadvantage in advoiding the creation of an object and using only static methods?