org.deegree.commons.utils
Class LogUtils

java.lang.Object
  extended by org.deegree.commons.utils.LogUtils

public class LogUtils
extends Object

This class contains static utility methods for writing files when a log is set to debug.

Version:
$Revision: 22943 $, $Date: 2010-03-09 16:56:32 +0100 (Tue, 09 Mar 2010) $
Author:
Oliver Tonnhofer, last edited by: $Author: mschneider $

Constructor Summary
LogUtils()
           
 
Method Summary
static String createDurationTimeString(String message, long startTime, boolean roundToMinutes)
          Create a string as follows: ${message} + took: ...
static String createTimeString(String message, long startTime, long endTime, boolean roundToMinutes)
          Create a string as follows: ${message} + took: ...
static void writeBinaryFile(org.slf4j.Logger log, File file, byte[] data)
          Writes the given binary data to the specified file, if the log level is set to debug.
static void writeBinaryTempFile(org.slf4j.Logger log, String filePrefix, String fileSuffix, byte[] data)
          Writes the given binary data to a temporary file (created from specified prefix and suffix), if the log level is set to debug.
static void writeFile(org.slf4j.Logger log, File file, String content)
          Writes the given String to the specified file, if the log level is set to debug
static void writeTempFile(org.slf4j.Logger log, String filePrefix, String fileSuffix, String content)
          Writes the given String to a temporary file (created from specified prefix and suffix), if the log level is set to debug.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogUtils

public LogUtils()
Method Detail

writeFile

public static void writeFile(org.slf4j.Logger log,
                             File file,
                             String content)
Writes the given String to the specified file, if the log level is set to debug. *

Parameters:
log - the log to check for the log level
file - file to write to
content -

writeTempFile

public static void writeTempFile(org.slf4j.Logger log,
                                 String filePrefix,
                                 String fileSuffix,
                                 String content)
Writes the given String to a temporary file (created from specified prefix and suffix), if the log level is set to debug.

Parameters:
log - the log to check for the log level
filePrefix - prefix for the temp file name, must be at least three characters long
fileSuffix - suffix for the temp file name, can be null (then ".tmp" is used)
content -
See Also:
*

writeBinaryFile

public static void writeBinaryFile(org.slf4j.Logger log,
                                   File file,
                                   byte[] data)
Writes the given binary data to the specified file, if the log level is set to debug.

Parameters:
log - the log to check for the log level
file - file to write to
data - binary data to be written

writeBinaryTempFile

public static void writeBinaryTempFile(org.slf4j.Logger log,
                                       String filePrefix,
                                       String fileSuffix,
                                       byte[] data)
Writes the given binary data to a temporary file (created from specified prefix and suffix), if the log level is set to debug.

Parameters:
log - the log to check for the log level
filePrefix - prefix for the temp file name, must be at least three characters long
fileSuffix - suffix for the temp file name, can be null (then ".tmp" is used)
data - binary data to be written
See Also:
*

createDurationTimeString

public static String createDurationTimeString(String message,
                                              long startTime,
                                              boolean roundToMinutes)
Create a string as follows: ${message} + took: ... {[ms]}{[second|minute][s]} the current time millis will be used as the end time.

Parameters:
message - to start with
startTime -
roundToMinutes - if true the second| minutes syntax will be used, if falls only ms will be appended.
Returns:
a string as follows: ${message} + took: ... [second|minute][s]

createTimeString

public static String createTimeString(String message,
                                      long startTime,
                                      long endTime,
                                      boolean roundToMinutes)
Create a string as follows: ${message} + took: ... {[ms]}{[second|minute][s]}

Parameters:
message - to start with
startTime -
endTime -
roundToMinutes - if true the second| minutes syntax will be used, if falls only ms will be appended.
Returns:
a string as follows: ${message} + took: ... [second|minute][s]


Copyright © 2011. All Rights Reserved.