Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.meta.log
Class LogFactory

java.lang.Object
  extended by dk.rode.thesis.meta.log.LogFactory

public class LogFactory
extends Object

The log factory is the public interface to create and access logs.

Implementation notes:
Internally, the factory uses a LogManager according to the Singleton pattern. If the system property dk.rode.thesis.log is set to file, file logs will be created by this manager. Otherwise the default system out loggers.

Author:
Gunni Rode / rode.dk
See Also:
LogManager

Field Summary
private static LogManager manager
          The singleton log manager that handles the logs.
 
Constructor Summary
private LogFactory()
          Private no-arg constructor.
 
Method Summary
static Log getLog()
          Returns the global log.
static Log getLog(Class<?> clazz)
          Returns the log associated with the class supplied as clazz, or the global log if clazz is null.
static Log getLog(Object object)
          Returns the log associated with the class of the object supplied supplied as object, or the global log if object is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

private static LogManager manager
The singleton log manager that handles the logs.

If the system property dk.rode.thesis.log is set to file, file logs will be created by this manager. Otherwise the default system out loggers.

Never null.

Constructor Detail

LogFactory

private LogFactory()
Private no-arg constructor.

Method Detail

getLog

public static final Log getLog()
Returns the global log.

Returns:
The global log; never null.

getLog

public static final Log getLog(Class<?> clazz)
Returns the log associated with the class supplied as clazz, or the global log if clazz is null.

The class is tested on identity, and a given super or sub-class will not match.

Parameters:
clazz - The class to which the log is associated; can be null for the global log.
Returns:
The log to use; never null.

getLog

public static final Log getLog(Object object)
Returns the log associated with the class of the object supplied supplied as object, or the global log if object is null.

The class is tested on identity, and a given super or sub-class will not match.

Parameters:
object - The object to deliver the class; can be null for the global log.
Returns:
The log to use; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.