SoftNet-Consult Java Utility Library

com.softnetConsult.utils.log
Class ScreenFileLoggerFactory

java.lang.Object
  extended by com.softnetConsult.utils.log.ScreenFileLoggerFactory

public final class ScreenFileLoggerFactory
extends java.lang.Object

This class provides a number of convenience methods for creating ScreenFileLogger objects.

This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.

File: ScreenFileLoggerFactory.java
Library API version: "2.02"
Java compliance version: "1.5"

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:

1. Redistributions of source code must retain the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version:
"2.02"
Author:
Greg Paperin (http://www.paperin.org)

Field Summary
private static int defaultIndentationLen
          Default indentation length in characters.
private static java.lang.String defaultLogfileExt
          Default file extension for log files.
private static java.lang.String defaultLogfileName
          Default base name for log files.
 
Constructor Summary
private ScreenFileLoggerFactory()
          Prevents instances of this class from being created as this class contains only static utility methods.
 
Method Summary
static ScreenFileLogger createLogger()
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(char[] indentationStr)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.io.File logFile)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.io.File logFile, boolean append)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.io.File logFile, boolean append, int indentLen)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.io.File logFile, int indentLen)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logPath)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logPath, boolean append)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logPath, boolean append, int indentLen)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logPath, int indentLen)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logDir, java.lang.String logName)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logDir, java.lang.String logName, boolean append)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logDir, java.lang.String logName, boolean append, int indentLen)
          Creates a new logger that logs to screen only.
static ScreenFileLogger createLogger(java.lang.String logDir, java.lang.String logName, int indentLen)
          Creates a new logger that logs to screen only.
static java.lang.String getIndentStr(int len)
          Constructs an indentation string of the required length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultIndentationLen

private static final int defaultIndentationLen
Default indentation length in characters.

See Also:
Constant Field Values

defaultLogfileName

private static final java.lang.String defaultLogfileName
Default base name for log files.

See Also:
Constant Field Values

defaultLogfileExt

private static final java.lang.String defaultLogfileExt
Default file extension for log files.

See Also:
Constant Field Values
Constructor Detail

ScreenFileLoggerFactory

private ScreenFileLoggerFactory()
Prevents instances of this class from being created as this class contains only static utility methods.

Method Detail

getIndentStr

public static java.lang.String getIndentStr(int len)
Constructs an indentation string of the required length.

Parameters:
len - Length of the indentation string.
Returns:
A string consisting of len white spaces.

createLogger

public static ScreenFileLogger createLogger()
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: off.
logFile: null.
append: no, overwrite.
indentation: a string consisting of defaultIndentationLen white spaces.

Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(char[] indentationStr)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: off.
logFile: null.
append: no, overwrite.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
indentationStr - A string to use for indentation (one copy per indent-level), it does not necessarily need to consist of white spaces.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logPath,
                                            boolean append,
                                            int indentLen)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: as specified.
indentation: a string consisting of the specified number of white spaces.

Parameters:
logPath - The file for logging. If null, a unique default file will be created in the program start directory.
append - Whether to append (or overwrite) the log file.
indentLen - The length of the indentation string.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logDir,
                                            java.lang.String logName,
                                            boolean append,
                                            int indentLen)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: as specified.
indentation: a string consisting of the specified number of white spaces.

Parameters:
logDir - The directory for for log file. If null, the program start directory will be used.
logName - The file for logging (relative to the specified directory). If null, a unique default file will be created in the specified directory.
append - Whether to append (or overwrite) the log file.
indentLen - The length of the indentation string.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.io.File logFile,
                                            boolean append,
                                            int indentLen)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: as specified.
indentation: a string consisting of the specified number of white spaces.

Parameters:
logFile - The file for logging. If null, a unique default file will be created in the program start directory. If the file specified a directory, a unique default file will be created within that directory.
append - Whether to append (or overwrite) the log file.
indentLen - The length of the indentation string.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logPath)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: yes.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
logPath - The file for logging. If null, a unique default file will be created in the program start directory.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logDir,
                                            java.lang.String logName)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: yes.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
logDir - The directory for for log file. If null, the program start directory will be used.
logName - The file for logging (relative to the specified directory). If null, a unique default file will be created in the specified directory.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.io.File logFile)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: yes.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
logFile - The file for logging. If null, a unique default file will be created in the program start directory. If the file specified a directory, a unique default file will be created within that directory.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logPath,
                                            boolean append)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: as specified.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
logPath - The file for logging. If null, a unique default file will be created in the program start directory.
append - Whether to append (or overwrite) the log file.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logDir,
                                            java.lang.String logName,
                                            boolean append)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: as specified.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
logDir - The directory for for log file. If null, the program start directory will be used.
logName - The file for logging (relative to the specified directory). If null, a unique default file will be created in the specified directory.
append - Whether to append (or overwrite) the log file.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.io.File logFile,
                                            boolean append)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: as specified.
indentation: a string consisting of defaultIndentationLen white spaces.

Parameters:
logFile - The file for logging. If null, a unique default file will be created in the program start directory. If the file specified a directory, a unique default file will be created within that directory.
append - Whether to append (or overwrite) the log file.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logPath,
                                            int indentLen)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: yes.
indentation: a string consisting of the specified number of white spaces.

Parameters:
logPath - The file for logging. If null, a unique default file will be created in the program start directory.
indentLen - The length of the indentation string.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.lang.String logDir,
                                            java.lang.String logName,
                                            int indentLen)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: yes.
indentation: a string consisting of the specified number of white spaces.

Parameters:
logDir - The directory for for log file. If null, the program start directory will be used.
logName - The file for logging (relative to the specified directory). If null, a unique default file will be created in the specified directory.
indentLen - The length of the indentation string.
Returns:
A new logger.

createLogger

public static ScreenFileLogger createLogger(java.io.File logFile,
                                            int indentLen)
Creates a new logger that logs to screen only. The logger created by this method has the following properties:
logToScreen: on.
logToFile: on.
logFile: as specified.
append: yes.
indentation: a string consisting of the specified number of white spaces.

Parameters:
logFile - The file for logging. If null, a unique default file will be created in the program start directory. If the file specified a directory, a unique default file will be created within that directory.
indentLen - The length of the indentation string.
Returns:
A new logger.

SoftNet-Consult Java Utility Library is a member of SourceForge.net