The SKIRT project
advanced radiative transfer for astrophysics
FileLog Class Reference

#include <FileLog.hpp>

Inheritance diagram for FileLog:

Public Member Functions

 FileLog ()
 FileLog (SimulationItem *parent)
Public Member Functions inherited from Log
void error (string message, bool store=true)
vector< stringerrorsIssued ()
void info (string message)
void infoIfElapsed (string message, size_t numDone)
void infoSetElapsed (size_t numTotal, int seconds=5)
LoglinkedLog () const
Level lowestLevel () const
bool memoryLogging () const
void setLinkedLog (Log *log)
void setLowestLevel (Level level)
void setMemoryLogging (bool value)
void setVerbose (bool value)
void success (string message)
bool verbose () const
void warning (string message, bool store=true)
vector< stringwarningsIssued ()
Public Member Functions inherited from SimulationItem
template<class T>
T * find (bool setup=true) const
template<class T>
T * interface (int levels=-999999, bool setup=true) const
virtual string itemName () const
void setup ()
string typeAndName () const
Public Member Functions inherited from Item
 Item (const Item &)=delete
virtual ~Item ()
void addChild (Item *child)
const vector< Item * > & children () const
virtual void clearItemListProperty (const PropertyDef *property)
void destroyChild (Item *child)
virtual bool getBoolProperty (const PropertyDef *property) const
virtual vector< double > getDoubleListProperty (const PropertyDef *property) const
virtual double getDoubleProperty (const PropertyDef *property) const
virtual string getEnumProperty (const PropertyDef *property) const
virtual int getIntProperty (const PropertyDef *property) const
virtual vector< Item * > getItemListProperty (const PropertyDef *property) const
virtual ItemgetItemProperty (const PropertyDef *property) const
virtual string getStringProperty (const PropertyDef *property) const
int getUtilityProperty (string name) const
virtual void insertIntoItemListProperty (const PropertyDef *property, int index, Item *item)
Itemoperator= (const Item &)=delete
Itemparent () const
virtual void removeFromItemListProperty (const PropertyDef *property, int index)
virtual void setBoolProperty (const PropertyDef *property, bool value)
virtual void setDoubleListProperty (const PropertyDef *property, vector< double > value)
virtual void setDoubleProperty (const PropertyDef *property, double value)
virtual void setEnumProperty (const PropertyDef *property, string value)
virtual void setIntProperty (const PropertyDef *property, int value)
virtual void setItemProperty (const PropertyDef *property, Item *item)
virtual void setStringProperty (const PropertyDef *property, string value)
void setUtilityProperty (string name, int value)
virtual string type () const

Protected Member Functions

void output (string message, Level level) override
void setupSelfBefore () override
Protected Member Functions inherited from Log
 Log ()
string processName ()
void setupSelfBefore () override
Protected Member Functions inherited from SimulationItem
 SimulationItem ()
virtual bool offersInterface (const std::type_info &interfaceTypeInfo) const
virtual void setupSelfAfter ()
Protected Member Functions inherited from Item
 Item ()

Private Member Functions

void open ()

Private Attributes

std::mutex _mutex
std::ofstream _out

Additional Inherited Members

Public Types inherited from Log
enum class  Level { Info , Warning , Success , Error }

Detailed Description

FileLog inherits from Log and implements thread-safe logging to a file. The file has a fixed name prefix_log.txt and is placed in the output filepath provided by the FilePaths instance attached to the simulation hierarchy at setup time. The log text is written in UTF-8 encoding. The output() function in this class is thread-safe.

Constructor & Destructor Documentation

◆ FileLog() [1/2]

FileLog::FileLog ( )

This constructor creates a file log object that is not hooked into a simulation item hierarchy, and has not been setup. The caller is responsible for calling the setup() function and for destroying the object. Alternatively, the object can be linked into a simulation item hierarchy by passing it to the setLinkedLog() function of another log object.

◆ FileLog() [2/2]

FileLog::FileLog ( SimulationItem * parent)
explicit

This constructor creates a file log object that is hooked up as a child to the specified parent in the simulation hierarchy, so that it will automatically be deleted. The setup() function is not called by this constructor.

Member Function Documentation

◆ open()

void FileLog::open ( )
private

This function provides the implementation of opening the file, called by setupSelfBefore(). With multiple processes and when not in verbose mode, this function can be called later on when a warning or error is encountered on one of the processes.

◆ output()

void FileLog::output ( string message,
Level level )
overrideprotectedvirtual

This function outputs a message to the file. It overrides the pure virtual function in the base class. This function is thread-safe.

Implements Log.

◆ setupSelfBefore()

void FileLog::setupSelfBefore ( )
overrideprotectedvirtual

This function constructs the filename and opens the log file, overwriting any existing file with the same name.

Reimplemented from SimulationItem.


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