Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
orxonox::LogWriter Class Reference

The LogWriter class inherits from BaseWriter and writes output to a log-file. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/util/output/LogWriter.h>

Inheritance diagram for orxonox::LogWriter:
orxonox::BaseWriter orxonox::SubcontextOutputListener orxonox::OutputListener

Public Member Functions

 LogWriter ()
 Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file. More...
 
virtual ~LogWriter ()
 Destructor, closes the log-file. More...
 
const std::ofstream & getFile () const
 Returns the open file stream. More...
 
std::string getPath () const
 Returns the path to the logfile. More...
 
void setLogDirectory (const std::string &directory)
 Changes the path of the log-file. More...
 
- Public Member Functions inherited from orxonox::BaseWriter
 BaseWriter (const std::string &name, bool bRegister=true)
 Constructor: Initializes the config-values. More...
 
virtual ~BaseWriter ()
 Destructor. More...
 
void changedConfigurableAdditionalContexts ()
 Called if the config-vector of accepted contexts has changed, updates the masks in SubcontextOutputListener. More...
 
void changedConfigurableAdditionalContextsLevel ()
 Called if the config value has changed, updates the corresponding mask in OutputListener. More...
 
void changedConfigurableLevel ()
 Called if the config value has changed, updates the corresponding mask in OutputListener. More...
 
std::string getConfigurableAdditionalContextsMaxLevelName () const
 Returns the name of the config value which defines the maximum output level of additional context. More...
 
std::string getConfigurableAdditionalContextsName () const
 Returns the name of the config vector which defines the additional contexts (and sub-contexts) More...
 
std::string getConfigurableMaxLevelName () const
 Returns the name of the config value which defines the maximum output level (independent of contexts). More...
 
const std::string & getName () const
 Returns the name of this instance. More...
 
void setAdditionalContextsLevelMax (OutputLevel max)
 Overwritten implementation of the function inherited from OutputListener, sets also the corresponding config-value. More...
 
void setLevelMax (OutputLevel max)
 Overwritten implementation of the function inherited from OutputListener, sets also the corresponding config-value. More...
 
- Public Member Functions inherited from orxonox::SubcontextOutputListener
 SubcontextOutputListener (bool bRegister=true)
 Constructor, initializes the context masks. More...
 
virtual ~SubcontextOutputListener ()
 Destructor. More...
 
virtual bool acceptsOutput (OutputLevel level, const OutputContextContainer &context) const override
 Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks, as well as the set of accepted sub-contexts. More...
 
const std::set< OutputContextSubID > & getSubcontexts () const
 
virtual void setAdditionalContextsMask (OutputContextMask mask) override
 Overwritten implementation of the function defined by OutputListener. More...
 
void setAdditionalSubcontexts (const std::set< const OutputContextContainer * > &subcontexts)
 Defines the set of accepted sub-contexts. More...
 
- Public Member Functions inherited from orxonox::OutputListener
 OutputListener (bool bRegister=true)
 Constructor, initializes the values and registers the instance at OutputManager if requested. More...
 
virtual ~OutputListener ()
 Destructor, unregisters the instance from OutputManager. More...
 
OutputLevel getAdditionalContextsLevelMask () const
 Returns the additional contexts level mask. More...
 
OutputContextMask getAdditionalContextsMask () const
 Returns the additional contexts mask. More...
 
OutputLevel getLevelMask () const
 Returns the level mask. More...
 
void registerListener (AdditionalContextListener *listener)
 Adds a listener to the list. More...
 
void setAdditionalContextsLevelMask (OutputLevel mask)
 Defines the level mask of additional contexts. More...
 
void setAdditionalContextsLevelMax (OutputLevel max)
 Defines the level mask of additional contexts in a way which accepts all output up to the level max. More...
 
void setAdditionalContextsLevelRange (OutputLevel min, OutputLevel max)
 Defines the level mask of additional contexts in a way which accepts all output between the levels min and max. More...
 
void setLevelMask (OutputLevel mask)
 Defines the level mask. More...
 
void setLevelMax (OutputLevel max)
 Defines the level mask in a way which accepts all output up to the level max. More...
 
void setLevelRange (OutputLevel min, OutputLevel max)
 Defines the level mask in a way which accepts all output between the levels min and max. More...
 
virtual void unfilteredOutput (OutputLevel level, const OutputContextContainer &context, const std::vector< std::string > &lines)
 Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function. More...
 
void unregisterListener (AdditionalContextListener *listener)
 Removes a listener from the list. More...
 

Protected Member Functions

virtual void printLine (const std::string &line, OutputLevel level) override
 Inherited function from BaseWriter, writers output together with a timestamp to the log-file. More...
 
- Protected Member Functions inherited from orxonox::BaseWriter
virtual void output (OutputLevel level, const OutputContextContainer &context, const std::vector< std::string > &lines) override
 This function is inherited from OutputListener, each message is split into lines and sent to printLine(). More...
 
- Protected Member Functions inherited from orxonox::OutputListener
const std::vector< AdditionalContextListener * > & getListeners () const
 

Private Member Functions

 LogWriter (const LogWriter &)=delete
 
void archive (int index=0)
 Archives old copies of the log file by adding increasing numbers to the filename. More...
 
void closeFile ()
 Closes the log-file. More...
 
std::string getArchivedPath (int index) const
 Returns the path for archived copies of the logfile (based on the archive index) More...
 
void openFile ()
 Opens the log-file in order to write output to it. More...
 
LogWriteroperator= (const LogWriter &)=delete
 

Private Attributes

std::string directory_
 The directory where the log-file resided (without file-name) More...
 
std::ofstream file_
 The output file stream. More...
 
std::string filename_
 The name of the log-file (without directory) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from orxonox::BaseWriter
static std::string getConfigurableSectionName ()
 Returns the (static) name of the section wherein the config-values are defined. More...
 
- Public Attributes inherited from orxonox::BaseWriter
std::vector< std::string > configurableAdditionalContexts_
 Config vector, used to define the additional contexts (and sub-contexts) More...
 
int configurableAdditionalContextsMaxLevel_
 Config value, used to define the maximum output level of additional context. More...
 
int configurableMaxLevel_
 Config value, used to define the maximum output level (independent of contexts) More...
 

Detailed Description

The LogWriter class inherits from BaseWriter and writes output to a log-file.

The path of the file can be changed, in which case the file is rewritten by using the output stored by MemoryWriter. This adds the possibility to change the desired output levels before changing the path in order to get the complete output with the new output levels at the new path.

Constructor & Destructor Documentation

orxonox::LogWriter::LogWriter ( )

Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.

By default, LogWriter receives all output up to level::internal_info. The log-file has a default name which usually doesn't change. The path is initialized with a temporary directory, depending on the system, and can be changed later.

orxonox::LogWriter::~LogWriter ( )
virtual

Destructor, closes the log-file.

orxonox::LogWriter::LogWriter ( const LogWriter )
privatedelete

Member Function Documentation

void orxonox::LogWriter::archive ( int  index = 0)
private

Archives old copies of the log file by adding increasing numbers to the filename.

void orxonox::LogWriter::closeFile ( )
private

Closes the log-file.

std::string orxonox::LogWriter::getArchivedPath ( int  index) const
private

Returns the path for archived copies of the logfile (based on the archive index)

const std::ofstream& orxonox::LogWriter::getFile ( ) const
inline

Returns the open file stream.

std::string orxonox::LogWriter::getPath ( ) const
inline

Returns the path to the logfile.

void orxonox::LogWriter::openFile ( )
private

Opens the log-file in order to write output to it.

LogWriter& orxonox::LogWriter::operator= ( const LogWriter )
privatedelete
void orxonox::LogWriter::printLine ( const std::string &  line,
OutputLevel  level 
)
overrideprotectedvirtual

Inherited function from BaseWriter, writers output together with a timestamp to the log-file.

Implements orxonox::BaseWriter.

void orxonox::LogWriter::setLogDirectory ( const std::string &  directory)

Changes the path of the log-file.

Re-writes the log-file by using MemoryWriter.

Member Data Documentation

std::string orxonox::LogWriter::directory_
private

The directory where the log-file resided (without file-name)

std::ofstream orxonox::LogWriter::file_
private

The output file stream.

std::string orxonox::LogWriter::filename_
private

The name of the log-file (without directory)


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