--- projects/cms/source/server/uk/org/iscream/cms/server/core/loggers/FileLogger.java 2001/01/22 12:01:46 1.4 +++ projects/cms/source/server/uk/org/iscream/cms/server/core/loggers/FileLogger.java 2001/01/28 19:57:59 1.5 @@ -18,7 +18,7 @@ import java.io.IOException; * logging ot a text file. * * @author $Author: tdb $ - * @version $Id: FileLogger.java,v 1.4 2001/01/22 12:01:46 tdb Exp $ + * @version $Id: FileLogger.java,v 1.5 2001/01/28 19:57:59 tdb Exp $ */ public class FileLogger implements LoggerImpl { @@ -27,7 +27,7 @@ public class FileLogger implements LoggerImpl { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.4 $"; + public final String REVISION = "$Revision: 1.5 $"; //---STATIC METHODS--- @@ -83,32 +83,34 @@ public class FileLogger implements LoggerImpl { * @param message The message to be logged. */ public synchronized void write(String source, int verbosity, String message) { - // Check to make sure file is open - if(open){ - // Produce a nicely formatted line for the logfile - String line = formatLogLine(source, message); - try{ - // We have to synchronize here due to problems with two write()'s being called before a newLine() - synchronized(writer){ - // Attempt to write the line - writer.write(line); - // Best to use newLine() as it will use the correct platform encoding - writer.newLine(); - } - // Make sure the line is written immeidiately - writer.flush(); - } - catch(IOException e){ - // We'd best log the error - System.out.println(formatLogLine(this.toString(), "Writing to logfile failed - " + e.getMessage())); - // As it's an IOException we should suspend logging - open = false; - } - } - else{ - // If file is not open we should print this to the screen - System.out.println(formatLogLine(this.toString(), "Write failed - file not open")); - } + if (verbosity <= _verbosityLevel) { + // Check to make sure file is open + if(open){ + // Produce a nicely formatted line for the logfile + String line = formatLogLine(source, message); + try{ + // We have to synchronize here due to problems with two write()'s being called before a newLine() + synchronized(writer){ + // Attempt to write the line + writer.write(line); + // Best to use newLine() as it will use the correct platform encoding + writer.newLine(); + } + // Make sure the line is written immeidiately + writer.flush(); + } + catch(IOException e){ + // We'd best log the error + System.out.println(formatLogLine(this.toString(), "Writing to logfile failed - " + e.getMessage())); + // As it's an IOException we should suspend logging + open = false; + } + } + else{ + // If file is not open we should print this to the screen + System.out.println(formatLogLine(this.toString(), "Write failed - file not open")); + } + } } /**