SPH
Public Types | Public Member Functions | List of all members
FileLogger Class Reference

File output logger. More...

#include <Logger.h>

Inheritance diagram for FileLogger:
ILogger Polymorphic Noncopyable

Public Types

enum class  Options { KEEP_OPENED = 0 , OPEN_WHEN_WRITING = 1 << 0 , APPEND = 1 << 1 , ADD_TIMESTAMP = 1 << 2 }
 

Public Member Functions

 FileLogger (const Path &path, const Flags< Options > flags=EMPTY_FLAGS)
 
 ~FileLogger ()
 
virtual void writeString (const std::string &s) override
 Logs a string message. More...
 
- Public Member Functions inherited from ILogger
template<typename... TArgs>
void write (TArgs &&... args)
 Creates and logs a message by concatenating arguments. More...
 
void setPrecision (const Size newPrecision)
 Changes the precision of printed numbers. More...
 
void setScientific (const bool newScientific)
 Sets/unsets scientific notation. More...
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 
- Public Member Functions inherited from Noncopyable
 Noncopyable ()=default
 
 Noncopyable (const Noncopyable &)=delete
 
 Noncopyable (Noncopyable &&)=default
 
Noncopyableoperator= (const Noncopyable &)=delete
 
Noncopyableoperator= (Noncopyable &&)=default
 

Detailed Description

File output logger.

Definition at line 160 of file Logger.h.

Member Enumeration Documentation

◆ Options

enum FileLogger::Options
strong
Enumerator
KEEP_OPENED 

Opens the associated file when the logger is constructed and closes it in destructor. This is the default behavior of the logger, nevertheless this option can be explicitly specified to increase readability of the code.

OPEN_WHEN_WRITING 

Open the file only for writing and close it immediately afterwards. If the file cannot be opened, the message is not written into the log without throwing any exception. This option implies appending to existing content.

APPEND 

If the file already exists, the new messages are appended to existing content instead of erasing the file.

ADD_TIMESTAMP 

Adds a time of writing before each message.

Definition at line 162 of file Logger.h.

Constructor & Destructor Documentation

◆ FileLogger()

FileLogger::FileLogger ( const Path path,
const Flags< Options flags = EMPTY_FLAGS 
)

Definition at line 40 of file Logger.cpp.

◆ ~FileLogger()

FileLogger::~FileLogger ( )
default

Member Function Documentation

◆ writeString()

void FileLogger::writeString ( const std::string &  s)
overridevirtual

Logs a string message.

Todo:
different types (log, warning, error, ...) and levels of verbosity

Implements ILogger.

Definition at line 56 of file Logger.cpp.


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