LRAUV  revA
TextLogWriter Class Reference

Defines a simple LogWriter that takes LogEntries and serializes them as text values to a stream. More...

#include <TextLogWriter.h>

Inheritance diagram for TextLogWriter:
Collaboration diagram for TextLogWriter:

Public Member Functions

 TextLogWriter (bool withDirectory=false)
 Default Constructor Assumes that the stream will be assigned later via setOutStream() More...
 
 TextLogWriter (OutStream &stream, bool withDirectory=false)
 Constructor, takes an OutStream. More...
 
virtual ~TextLogWriter ()
 Destructor. More...
 
virtual unsigned int writeHeader ()
 Start the text log. More...
 
virtual unsigned int write (const LogEntry *entry, const Unit *unit=NULL)
 Write an entry to the text log. More...
 
- Public Member Functions inherited from LogWriter
virtual ~LogWriter ()
 Destructor. More...
 
virtual void setOutStream (OutStream &outStream)
 Sets the OutStream. More...
 
virtual bool isValid ()
 Return true if logStream_ is available. More...
 
virtual void endCycle ()
 Do what needs to be done at the end of the cycle. More...
 
virtual unsigned int writeFooter ()
 Write the log footer, if any. More...
 
virtual void config (Logger &logger)
 Configure from a config file. More...
 
virtual void resetInputs ()
 Reset cached input settings. More...
 
void addParent ()
 
void removeParent ()
 
int getParentCount ()
 
virtual void activate ()
 
virtual void deactivate ()
 
virtual bool isActive ()
 
virtual void lockWrites ()
 
virtual void unlockWrites ()
 

Private Attributes

bool withDirectory_
 

Additional Inherited Members

- 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 Member Functions inherited from LogWriter
 LogWriter ()
 Protected constructor for pure virtual class. More...
 
 LogWriter (OutStream &outStream)
 Protected constructor for pure virtual class. More...
 
- Protected Attributes inherited from LogWriter
OutStreamlogStream_
 Stores an OutStream. More...
 
bool wroteHeader_
 
bool wroteFooter_
 
Mutex writeMutex_
 
int parentCount_
 
bool active_
 

Detailed Description

Defines a simple LogWriter that takes LogEntries and serializes them as text values to a stream.

See FileLogWriter for output to the filesystem.

Constructor & Destructor Documentation

TextLogWriter::TextLogWriter ( bool  withDirectory = false)

Default Constructor Assumes that the stream will be assigned later via setOutStream()

Parameters
withDirectoryIf true, include DirectoryEntry entries.
TextLogWriter::TextLogWriter ( OutStream stream,
bool  withDirectory = false 
)

Constructor, takes an OutStream.

Parameters
streamAn OutStream for output.
withDirectoryIf true, include DirectoryEntry entries.
TextLogWriter::~TextLogWriter ( )
virtual

Destructor.

Member Function Documentation

unsigned int TextLogWriter::write ( const LogEntry entry,
const Unit unit = NULL 
)
virtual

Write an entry to the text log.

Write the given Entry to the OutStream.

Pipes the toString() method of the entry to the OutStream with some formatting.

Implements LogWriter.

References Str::cStr(), LogWriter::isValid(), Str::length(), LogWriter::logStream_, LogEntry::toString(), OutStream::write(), OutStream::writeChar(), and LogWriter::writeMutex_.

unsigned int TextLogWriter::writeHeader ( )
virtual

Start the text log.

Reimplemented from LogWriter.

References OutStream::isWritable(), LogWriter::logStream_, withDirectory_, and DirectoryEntry::write().

Member Data Documentation

bool TextLogWriter::withDirectory_
private

Referenced by writeHeader().


The documentation for this class was generated from the following files: