Package org.omegazero.common.logging
Class FileLoggerOutput
java.lang.Object
org.omegazero.common.logging.FileLoggerOutput
- All Implemented Interfaces:
LoggerOutput
- Direct Known Subclasses:
RotatingFileLoggerOutput
A
LoggerOutput
writing to a file.- Since:
- 2.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
System propertyorg.omegazero.common.logging.logBufferSize
static final int
System propertyorg.omegazero.common.logging.saveInterval
static final boolean
System propertyorg.omegazero.common.logging.syncFlush
protected PrintWriter
The output writer. -
Constructor Summary
ConstructorsConstructorDescriptionFileLoggerOutput
(String logFile) Creates a newFileLoggerOutput
, writing to the givenlogFile
.FileLoggerOutput
(String logFile, int logBufferBytes, int saveInterval) Creates a newFileLoggerOutput
, writing to the givenlogFile
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes thisLoggerOutput
, flushing any remaining data and freeing resources.void
flush()
Flushes any buffered data to the underlying output.Returns the file name log messages are written to.protected void
reopen()
Closes and re-opens the file output stream where data is written to.void
setSyncFlush
(boolean syncFlush) Sets whether the log buffer should be flushed for every message.void
Writes the given log line to thisLoggerOutput
.
-
Field Details
-
SAVE_INTERVAL
public static final int SAVE_INTERVALSystem propertyorg.omegazero.common.logging.saveInterval
The default interval in seconds between explicit data flushes to the log file.
Default:
300
-
LOG_BUFFER_BYTES
public static final int LOG_BUFFER_BYTESSystem propertyorg.omegazero.common.logging.logBufferSize
The default size of the internal log data buffer.
Default:
100KB
- Since:
- 2.11.0
-
SYNC_FLUSH_DEFAULT
public static final boolean SYNC_FLUSH_DEFAULTSystem propertyorg.omegazero.common.logging.syncFlush
Sets the default value for
syncFlush
.Default:
false
- Since:
- 2.11.0
-
writer
The output writer.
-
-
Constructor Details
-
FileLoggerOutput
Creates a newFileLoggerOutput
, writing to the givenlogFile
.- Parameters:
logFile
- The name of the output log file- Throws:
IOException
- If an IO error occurs while opening the file- See Also:
-
FileLoggerOutput
Creates a newFileLoggerOutput
, writing to the givenlogFile
.- Parameters:
logFile
- The name of the output log filelogBufferBytes
- The size of the internal log data buffer. If this value is nonpositive, thedefault
is usedsaveInterval
- The save interval. If this value is nonpositive, thedefault
is used- Throws:
IOException
- If an IO error occurs while opening the file- Since:
- 2.11.0
-
-
Method Details
-
setSyncFlush
public void setSyncFlush(boolean syncFlush) Sets whether the log buffer should be flushed for every message.- Parameters:
syncFlush
-true
to synchronously flush the log buffer
-
getLogFile
Returns the file name log messages are written to.- Returns:
- The configured log file
-
reopen
Closes and re-opens the file output stream where data is written to.- Throws:
IOException
- Since:
- 2.11.0
-
writeLine
Description copied from interface:LoggerOutput
Writes the given log line to thisLoggerOutput
.- Specified by:
writeLine
in interfaceLoggerOutput
- Parameters:
line
- The log messagemarkup
- Special terminal escape sequences used for text markup
-
flush
public void flush()Description copied from interface:LoggerOutput
Flushes any buffered data to the underlying output.- Specified by:
flush
in interfaceLoggerOutput
-
close
public void close()Description copied from interface:LoggerOutput
Closes thisLoggerOutput
, flushing any remaining data and freeing resources. After a call to this method, the behavior of other methods in this interfaces is undefined.- Specified by:
close
in interfaceLoggerOutput
-