|
LRAUV
revA
|
Writes LogEntries to files that are split over time or capacity. More...
#include <SplitFileLogWriter.h>


Public Member Functions | |
| SplitFileLogWriter (const Str &filebase, LogWriter *logWriter, FileEncoder *fileEncoder=NULL, int nextFilenum=0) | |
| Constructor for manual split. More... | |
| SplitFileLogWriter (const Str &filebase, unsigned int capacity, LogWriter *logWriter, FileEncoder *fileEncoder=NULL, int nextFilenum=0) | |
| Constructor for capacity split. More... | |
| SplitFileLogWriter (const Str &filebase, const Timespan &span, LogWriter *logWriter, FileEncoder *fileEncoder=NULL, int nextFilenum=0) | |
| Constructor for Timespan split. More... | |
| virtual | ~SplitFileLogWriter () |
| Destructor, closes file if open. More... | |
| virtual unsigned int | write (const LogEntry *entry, const Unit *unit=NULL) |
| Write. More... | |
| virtual void | split (bool andReopen=true, int nextFilenum=-1) |
| Split the file. More... | |
| virtual void | resetFileBase (const Str &filebase, int nextFilenum=0) |
| Change file destination. More... | |
Public Member Functions inherited from FileLogWriter | |
| 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 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 | |
| virtual Str | nextFilename (int nextFilenum=-1) |
| Uses nextFilenum_ to determine the next filename. More... | |
Protected Member Functions inherited from FileLogWriter | |
| 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 () | |
Private Member Functions | |
| SplitFileLogWriter (const SplitFileLogWriter &old) | |
Private Attributes | |
| Str | filebase_ |
| const unsigned int | capacity_ |
| unsigned int | nextFilenum_ |
| const Timespan | span_ |
| Timestamp | splitTime_ |
Additional Inherited Members | |
Public Types inherited from FileLogWriter | |
| 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 } |
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] |
Protected Attributes inherited from FileLogWriter | |
| 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_ |
Writes LogEntries to files that are split over time or capacity.
| SplitFileLogWriter::SplitFileLogWriter | ( | const Str & | filebase, |
| LogWriter * | logWriter, | ||
| FileEncoder * | fileEncoder = NULL, |
||
| int | nextFilenum = 0 |
||
| ) |
Constructor for manual split.
| filebase | Basename of file to write to |
| logWriter | logWriter that provides input for file logging |
| fileEncoder | If non-NULL, object that encodes the file after saving |
| nextFilenum | File number to start with, defaults to zero |
| filebase | Basename of file to write to |
| logWriter | logWriter that provides input for file logging |
| fileEncoder | In non-NULL, object that encodes the file after saving |
| SplitFileLogWriter::SplitFileLogWriter | ( | const Str & | filebase, |
| unsigned int | capacity, | ||
| LogWriter * | logWriter, | ||
| FileEncoder * | fileEncoder = NULL, |
||
| int | nextFilenum = 0 |
||
| ) |
Constructor for capacity split.
| filebase | Basename of file to write to |
| capacity | maximum size, in bytes, of each split file. |
| logWriter | logWriter that provides input for file logging |
| fileEncoder | If non-NULL, object that encodes the file after saving |
| nextFilenum | File number to start with, defaults to zero |
| filebase | Basename of file to write to |
| capacity | maximum size, in bytes, of each split file. |
| logWriter | logWriter that provides input for file logging |
| fileEncoder | In non-NULL, object that encodes the file after saving |
| SplitFileLogWriter::SplitFileLogWriter | ( | const Str & | filebase, |
| const Timespan & | span, | ||
| LogWriter * | logWriter, | ||
| FileEncoder * | fileEncoder = NULL, |
||
| int | nextFilenum = 0 |
||
| ) |
Constructor for Timespan split.
| filebase | Basename of file to write to |
| span | timespan to contain within each file split |
| logWriter | logWriter that provides input for file logging |
| fileEncoder | If non-NULL, object that encodes the file after saving |
| nextFilenum | File number to start with, defaults to zero |
| filebase | Basename of file to write to |
| span | timespan to contain within each file split |
| logWriter | logWriter that provides input for file logging |
| fileEncoder | In non-NULL, object that encodes the file after saving |
|
virtual |
|
private |
|
protectedvirtual |
Uses nextFilenum_ to determine the next filename.
References Str::cStr(), filebase_, and nextFilenum_.
|
virtual |
Change file destination.
References filebase_, LogWriter::lockWrites(), FileLogWriter::logWriter_, nextFilenum_, split(), LogWriter::unlockWrites(), and LogWriter::writeFooter().
Referenced by DecimationLogManager::resetFileBases(), and Supervisor::RestartLogs().
|
virtual |
Split the file.
Do the split.
Normally just closes the file, but descendant classes may do otherwise.
References FileLogWriter::close(), Str::cStr(), Str::EMPTY_STR, FileEncoder::encode(), FileLogWriter::getFileEncoder(), FileLogWriter::getFilename(), FileLogWriter::isWritable(), nextFilename(), and FileLogWriter::open().
Referenced by resetFileBase(), DecimationLogManager::splits(), write(), and ~SplitFileLogWriter().
Write.
Reimplemented from FileLogWriter.
References capacity_, Str::cStr(), FileLogWriter::getBytesInFile(), LogEntry::getTimestamp(), Timespan::INVALID_TIMESPAN, FileLogWriter::isWritable(), nextFilename(), Timestamp::NOT_SET_TIME, FileLogWriter::open(), span_, split(), splitTime_, and FileLogWriter::write().
|
private |
Referenced by write().
|
private |
Referenced by nextFilename(), and resetFileBase().
|
private |
Referenced by nextFilename(), and resetFileBase().