Simple Log 2.0.1
[grlea]

org.grlea.log
Class SimpleLog

java.lang.Object
  extended byorg.grlea.log.SimpleLog

public final class SimpleLog
extends java.lang.Object

Controls the configuration and formatting of a group of SimpleLoggers.

SimpleLog has a default instance, which is probably the only one that anyone will ever use. If you use the default instance, you don't even really need to know anything about SimpleLog - just use the basic SimpleLogger constructor and you'll never even know nor care.

Version:
$Revision: 1.2 $
Author:
$Author: grlea $

Constructor Summary
SimpleLog(java.util.Properties properties)
          Creates a new SimpleLog configured by the given properties object.
SimpleLog(java.net.URL configurationSource)
          Creates a new SimpleLog configured by a properties file read from the given URL.
 
Method Summary
static SimpleLog defaultInstance()
          Returns the default instance of SimpleLog.
 java.text.DateFormat getDateFormat()
          Returns this SimpleLog's default date format.
 DebugLevel getDefaultLevel()
          Returns this SimpleLog's default level.
 java.io.PrintWriter getWriter()
          Returns the print writer that is the destination for all of this SimpleLog's output.
 boolean isDefaultTracing()
          Returns this SimpleLog's default tracing flag.
 boolean isPipingOutputToConsole()
          Returns whether this SimpleLog, when printing output to a file, will also print the output to the console.
 void reloadProperties()
          Reloads this SimpleLog's configuration.
 void setDateFormat(java.text.DateFormat newDateFormat)
          Sets this SimpleLog's default date format.
 void setDefaultLevel(DebugLevel defaultLevel)
          Sets this SimpleLog's default level.
 void setDefaultTracing(boolean defaultTracing)
          Sets this SimpleLog's default tracing flag.
 void setPipingOutputToConsole(boolean pipeOutputToConsole)
          Sets whether this SimpleLog, when printing output to a file, should also print the output to the console.
 void setWriter(java.io.PrintWriter out)
          Sets the print writer to be used as the destination for all of this SimpleLog's output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLog

public SimpleLog(java.util.Properties properties)
Creates a new SimpleLog configured by the given properties object.
All SimpleLogs log to System.err by default.

Parameters:
properties - a properties object containing properties that will be used to configure the SimpleLog.
Throws:
java.lang.IllegalArgumentException - if properties is null.

SimpleLog

public SimpleLog(java.net.URL configurationSource)
          throws java.io.IOException
Creates a new SimpleLog configured by a properties file read from the given URL.
All SimpleLogs log to System.err by default.

Parameters:
configurationSource - the properties file to use to configure the SimpleLog instance.
Throws:
java.io.IOException - if the properties file cannot be read from the given URL.
Method Detail

reloadProperties

public void reloadProperties()
Reloads this SimpleLog's configuration.


defaultInstance

public static SimpleLog defaultInstance()

Returns the default instance of SimpleLog.

The default instance is either configured from a properties file found on the classpath with the name 'simplelog.properties', or not configured at all (if the file cannot be found).
If the instance is not configured at all, it will not produce any output unless a writer is programmatically assigned to it (see setWriter(java.io.PrintWriter)).

Returns:
the default instance of SimpleLog.

getDefaultLevel

public DebugLevel getDefaultLevel()
Returns this SimpleLog's default level.


setDefaultLevel

public void setDefaultLevel(DebugLevel defaultLevel)
Sets this SimpleLog's default level.

Parameters:
defaultLevel - the new default debug level
Throws:
java.lang.IllegalArgumentException - if defaultLevel is null.

isDefaultTracing

public boolean isDefaultTracing()
Returns this SimpleLog's default tracing flag.


setDefaultTracing

public void setDefaultTracing(boolean defaultTracing)
Sets this SimpleLog's default tracing flag.

Parameters:
defaultTracing - the new default trace value (true for on, false for off).

getDateFormat

public java.text.DateFormat getDateFormat()
Returns this SimpleLog's default date format.


setDateFormat

public void setDateFormat(java.text.DateFormat newDateFormat)
Sets this SimpleLog's default date format. If the given value is null, the default date format will be used.

Parameters:
newDateFormat - the new date format. May be null.

getWriter

public java.io.PrintWriter getWriter()
Returns the print writer that is the destination for all of this SimpleLog's output.

Returns:
the print writer being used by this SimpleLog, or null if it doesn't have one.

setWriter

public void setWriter(java.io.PrintWriter out)
Sets the print writer to be used as the destination for all of this SimpleLog's output.

Parameters:
out - the print to be used by this SimpleLog, or null if it should not create any output.

isPipingOutputToConsole

public boolean isPipingOutputToConsole()
Returns whether this SimpleLog, when printing output to a file, will also print the output to the console. This attribute has no effect when output is not going to a file.

Returns:
true if output will be piped to the console, false if it won't.

setPipingOutputToConsole

public void setPipingOutputToConsole(boolean pipeOutputToConsole)
Sets whether this SimpleLog, when printing output to a file, should also print the output to the console. This attribute has no effect when output is not going to a file.

Parameters:
pipeOutputToConsole - true if output should be piped to the console as well as the output file, false if it should not.

Copyright (c) 2004-2006, Graham Lea. All rights reserved.