|
LRAUV
revA
|
Wraps around another LogWriter to write LogEntries to a file. More...
#include <FileLogWriter.h>


Public Types | |
| enum | FlushFreq { FLUSH_ONCE = 0, FLUSH_PER_CYCLE = 1, FLUSH_PER_WRITE } |
Public Types inherited from LogWriter | |
| enum | ServiceType { NO_SERVICE = -1, SERVICE_COURIER, SERVICE_EXPRESS, SERVICE_PRIORITY, SERVICE_NORMAL, SERVICE_BULK, SERVICE_COUNT, SERVICE_MULTI } |
Public Member Functions | |
| FileLogWriter (const Str &filename, LogWriter *logWriter, const bool append=false, FileEncoder *fileEncoder=NULL) | |
| Constructor with filename & specified flushFreq. More... | |
| FileLogWriter (FILE *file, LogWriter *logWriter) | |
| Constructor with FILE. More... | |
| virtual | ~FileLogWriter () |
| Destructor, closes file if open. More... | |
| virtual void | resetInputs () |
| Reset cached input settings. More... | |
| virtual bool | valid (void) |
| Is the LogWriter valid? More... | |
| virtual unsigned int | write (const LogEntry *entry, const Unit *unit=NULL) |
| Write. More... | |
| virtual void | endCycle () |
| If flushFreq_ is FLUSH_PER_CYCLE, this causes an output flush. More... | |
| unsigned int | getBytesInFile (void) |
| Accessors. More... | |
| unsigned int | getEntriesWritten (void) |
| virtual const Str & | getFilename () |
| void | resetFilename (const Str &filename) |
| bool | isWritable (void) |
| Keep track of whether the stream is open. More... | |
Public Member Functions inherited from LogWriter | |
| virtual | ~LogWriter () |
| Destructor. More... | |
| virtual unsigned int | writeHeader () |
| Write the log header, if any. More... | |
| virtual void | setOutStream (OutStream &outStream) |
| Sets the OutStream. More... | |
| virtual bool | isValid () |
| Return true if logStream_ is available. More... | |
| virtual unsigned int | writeFooter () |
| Write the log footer, if any. More... | |
| virtual void | config (Logger &logger) |
| Configure from a config file. More... | |
| void | addParent () |
| void | removeParent () |
| int | getParentCount () |
| virtual void | activate () |
| virtual void | deactivate () |
| virtual bool | isActive () |
| virtual void | lockWrites () |
| virtual void | unlockWrites () |
Public Member Functions inherited from HasFilename | |
| virtual | ~HasFilename () |
Protected Member Functions | |
| bool | open (const char *filename, const bool append) |
| Open the stream to the named file. More... | |
| void | close (void) |
| Close the currently open file. More... | |
| void | setFlushFreq (const FlushFreq flushFreq) |
| FileEncoder * | getFileEncoder () |
| void | setFilename (const Str &filename) |
Protected Member Functions inherited from LogWriter | |
| LogWriter () | |
| Protected constructor for pure virtual class. More... | |
| LogWriter (OutStream &outStream) | |
| Protected constructor for pure virtual class. More... | |
Protected Member Functions inherited from HasFilename | |
| HasFilename () | |
Protected Attributes | |
| LogWriter * | logWriter_ |
| The LogWriter that does the actual writing. More... | |
Protected Attributes inherited from LogWriter | |
| OutStream * | logStream_ |
| Stores an OutStream. More... | |
| bool | wroteHeader_ |
| bool | wroteFooter_ |
| Mutex | writeMutex_ |
| int | parentCount_ |
| bool | active_ |
Private Member Functions | |
| FileLogWriter (const FileLogWriter &old) | |
Private Attributes | |
| FileOutStream | fileStream_ |
| The output file stream. More... | |
| unsigned int | entriesWritten_ |
| Total entries written. More... | |
| unsigned int | bytesInFile_ |
| Total bytes written. More... | |
| bool | initFilename_ |
| True if a file name is specified in constructor. More... | |
| Str | filename_ |
| Name of the current file. More... | |
| FlushFreq | flushFreq_ |
| bool | writtenInCycle_ |
| FileEncoder * | fileEncoder_ |
Additional Inherited Members | |
Static Public Member Functions inherited from LogWriter | |
| static ServiceType | Str2ServiceType (const char *const serviceTypeStr, int len=-1) |
| static const char * | ServiceType2Str (LogWriter::ServiceType serviceType) |
| static size_t | ServiceType2Strlen (LogWriter::ServiceType serviceType) |
Static Public Attributes inherited from LogWriter | |
| static const char *const | SERVICE_TYPE_STRS [SERVICE_COUNT] |
| static size_t const | SERVICE_TYPE_STRLEN [SERVICE_COUNT] |
Wraps around another LogWriter to write LogEntries to a file.
Designed around assumption that it always has a log file open, though it does keep track of whether the stream is open or close, which it uses to determine if it's valid.
| FileLogWriter::FileLogWriter | ( | const Str & | filename, |
| LogWriter * | logWriter, | ||
| const bool | append = false, |
||
| FileEncoder * | fileEncoder = NULL |
||
| ) |
Constructor with filename & specified flushFreq.
| filename | Name of file to write to |
| logWriter | logWriter that provides input for file logging |
| append | if true, append to file, otherwise overwrite. |
| fileEncoder | optional encoder to run whenever the file closes |
References LogWriter::addParent(), Str::cStr(), fileStream_, initFilename_, logWriter_, open(), and LogWriter::setOutStream().
| FileLogWriter::FileLogWriter | ( | FILE * | file, |
| LogWriter * | logWriter | ||
| ) |
Constructor with FILE.
| file | FILE to write to |
| logWriter | logWriter that provides input for file logging |
References LogWriter::addParent(), fileStream_, logWriter_, LogWriter::setOutStream(), and LogWriter::writeHeader().
|
virtual |
Destructor, closes file if open.
Destructor.
Closes file if open
References close(), fileEncoder_, LogWriter::getParentCount(), logWriter_, and LogWriter::removeParent().
|
private |
|
protected |
Close the currently open file.
Close the file stream.
References bytesInFile_, FileOutStream::close(), Str::cStr(), FileEncoder::encode(), fileEncoder_, filename_, fileStream_, initFilename_, isWritable(), logWriter_, and LogWriter::writeFooter().
Referenced by open(), resetFilename(), SplitFileLogWriter::split(), and ~FileLogWriter().
|
virtual |
If flushFreq_ is FLUSH_PER_CYCLE, this causes an output flush.
Reimplemented from LogWriter.
References fileStream_, FileOutStream::flush(), FLUSH_PER_CYCLE, flushFreq_, and writtenInCycle_.
|
inline |
|
inline |
References entriesWritten_.
|
inlineprotected |
References fileEncoder_.
Referenced by SplitFileLogWriter::split().
|
inlinevirtual |
|
inline |
Keep track of whether the stream is open.
References fileStream_, and FileOutStream::isWritable().
Referenced by close(), open(), SplitFileLogWriter::split(), valid(), SplitFileLogWriter::write(), and write().
|
protected |
Open the stream to the named file.
Open the given file.
| filename | Name of system log. |
| append | If true, open the file in append mode (otherwise overwrite) |
References bytesInFile_, close(), entriesWritten_, filename_, fileStream_, isWritable(), logWriter_, FileOutStream::open(), LogWriter::writeHeader(), and LogWriter::wroteFooter_.
Referenced by FileLogWriter(), resetFilename(), SplitFileLogWriter::split(), and SplitFileLogWriter::write().
| void FileLogWriter::resetFilename | ( | const Str & | filename | ) |
References close(), Str::cStr(), and open().
Referenced by Supervisor::RestartLogs().
|
virtual |
Reset cached input settings.
Reimplemented from LogWriter.
References logWriter_, and LogWriter::resetInputs().
|
inlineprotected |
References flushFreq_.
|
inlinevirtual |
Is the LogWriter valid?
References isWritable().
Write.
Implements LogWriter.
Reimplemented in SplitFileLogWriter.
References bytesInFile_, entriesWritten_, fileStream_, FileOutStream::flush(), FLUSH_PER_WRITE, flushFreq_, isWritable(), logWriter_, LogWriter::write(), LogWriter::writeMutex_, and writtenInCycle_.
Referenced by SplitFileLogWriter::write().
|
private |
Total bytes written.
Referenced by close(), getBytesInFile(), open(), and write().
|
private |
Total entries written.
Referenced by getEntriesWritten(), open(), and write().
|
private |
Referenced by close(), getFileEncoder(), and ~FileLogWriter().
|
private |
Name of the current file.
Referenced by close(), getFilename(), open(), and setFilename().
|
private |
The output file stream.
Referenced by close(), endCycle(), FileLogWriter(), isWritable(), open(), and write().
|
private |
Referenced by endCycle(), setFlushFreq(), and write().
|
private |
True if a file name is specified in constructor.
Referenced by close(), and FileLogWriter().
|
protected |
The LogWriter that does the actual writing.
Referenced by close(), FileLogWriter(), open(), SplitFileLogWriter::resetFileBase(), resetInputs(), write(), and ~FileLogWriter().
|
private |
Referenced by endCycle(), and write().