![]() |
PhoenixPresentation
2.0.0
Set of cmake function to automate presentation generation
|
Phoenix Logger. More...
#include <PLog.h>
Public Types | |
enum | Level { DEBUG = 1 , INFO = 2 , WARNING = 3 , ERROR = 4 , CRITICAL = 5 , ALWAYS = 6 } |
Log level to be used in the logger. More... | |
enum | Mode { FILE_ONLY , STRING_ONLY , STDOUT_ONLY , FILE_CAPTURE_STDOUT_STDERR , DISABLE } |
Mode to be used on the logger. More... | |
Public Member Functions | |
void | appendLog (std::stringstream &str) |
Append the log (STRING_ONLY mode) into an other log. More... | |
void | clear () |
Clear the children of the current PLog. More... | |
void | close () |
Close the current PLog and its children. More... | |
const PPath & | getFileName () const |
Get the filename of the current log. More... | |
std::ostream & | getLog (PLog::Level logLevel=PLog::INFO) |
Write log into the PLog. More... | |
PLog & | getLog (size_t threadIndex) |
Get the PLog at given index. More... | |
std::ostream & | getLogAlways () |
Write always message into the PLog. More... | |
std::ostream & | getLogCritical () |
Write critical message into the PLog. More... | |
std::ostream & | getLogDebug () |
Write debug message into the PLog. More... | |
std::ostream & | getLogError () |
Write error message into the PLog. More... | |
std::ofstream & | getLogFile () |
Get the current log file. More... | |
std::ostream & | getLogInfo () |
Write info message into the PLog. More... | |
PLog::Level | getLogLevel () const |
Get the log level of the current PLog. More... | |
std::stringstream & | getLogString () |
Get the log string. More... | |
std::ostream & | getLogWarning () |
Write warning message into the PLog. More... | |
PLog::Mode | getMode () const |
Get the mode of the current PLog. More... | |
size_t | getThreadIndex () const |
Get the thread index of the current PLog. More... | |
bool | isOpen () const |
Say if the current PLog is opened or not. More... | |
bool | open () |
Open the current PLog and its children. More... | |
PLog () | |
Default constructor of PLog. More... | |
void | resize (size_t nbThread) |
Resize the number of cihldren log file. More... | |
void | setFileName (const PPath &fileName) |
Set the output filename of the current PLog. More... | |
void | setLogLevel (PLog::Level logLevel) |
Set the log level of the current PLog. More... | |
void | setMode (PLog::Mode mode) |
Set the mode of the current PLog. More... | |
void | setThreadIndex (size_t threadIndex) |
Set the thread index of the current PLog. More... | |
virtual | ~PLog () |
Destructor of PLog. More... | |
Private Member Functions | |
void | allocateStream (std::streambuf *buffer) |
Allocate the stream. More... | |
void | initialisationPLog () |
Initialisation function of the class PLog. More... | |
bool | streamOpen () |
Open the streams. More... | |
Private Attributes | |
PPath | p_fileName |
Output filename of the current PLog. More... | |
bool | p_isOpen |
True of the log is opened. More... | |
std::ofstream | p_logFile |
Current log file to be used. More... | |
PLog::Level | p_logLevel |
Current log level of the PLog (all log greater or equal to the p_logLevel will be logged) More... | |
std::stringstream | p_logString |
Log string. More... | |
PLog::Mode | p_mode |
Mode of the logger. More... | |
std::ostream * | p_nullStream |
Stream used to disable log output. More... | |
std::streambuf * | p_oldStdCerrBuffer |
Old std::cerr buffer. More... | |
std::streambuf * | p_oldStdCoutBuffer |
Old std::cout buffer. More... | |
std::ostream * | p_stream |
Current stream to be used to log things. More... | |
size_t | p_threadIndex |
Index of the current thread. More... | |
std::vector< PLog * > | p_vecLog |
Vector of sur log file to be used (mainly for multithreaded programs) More... | |
enum PLog::Level |
enum PLog::Mode |
PLog::PLog | ( | ) |
Default constructor of PLog.
Definition at line 46 of file PLog.cpp.
References initialisationPLog().
Referenced by resize().
|
virtual |
|
private |
Allocate the stream.
buffer | : buffer to be used |
Definition at line 299 of file PLog.cpp.
References p_stream.
Referenced by streamOpen().
void PLog::appendLog | ( | std::stringstream & | str | ) |
Append the log (STRING_ONLY mode) into an other log.
str | : log string to be appended |
Definition at line 168 of file PLog.cpp.
References ALWAYS, and getLog().
Referenced by testStringLogAppend().
void PLog::clear | ( | ) |
Clear the children of the current PLog.
Definition at line 153 of file PLog.cpp.
References p_vecLog.
Referenced by resize(), and ~PLog().
void PLog::close | ( | ) |
Close the current PLog and its children.
Definition at line 123 of file PLog.cpp.
References close(), getLogAlways(), p_isOpen, p_logFile, p_oldStdCerrBuffer, p_oldStdCoutBuffer, p_stream, p_vecLog, and phoenix_getDate().
Referenced by close(), testLogCoutDedirectInFile(), testLogDisable(), testLogStdoutOnly(), testStringLogAppend(), and ~PLog().
const PPath & PLog::getFileName | ( | ) | const |
Get the filename of the current log.
Definition at line 252 of file PLog.cpp.
References p_fileName.
Referenced by testStringPLog(), and testStringPLogLevel().
std::ostream & PLog::getLog | ( | PLog::Level | logLevel = PLog::INFO | ) |
Write log into the PLog.
logLevel | : log level of the current line |
Definition at line 197 of file PLog.cpp.
References p_logLevel, p_nullStream, p_stream, p_threadIndex, phoenix_getDateCompact(), phoenix_getTime(), and phoenix_logLevelToStr().
PLog & PLog::getLog | ( | size_t | threadIndex | ) |
Get the PLog at given index.
Definition at line 175 of file PLog.cpp.
References p_vecLog.
Referenced by appendLog(), getLogAlways(), getLogCritical(), getLogDebug(), getLogError(), getLogInfo(), getLogWarning(), testLogCoutDedirectInFile(), testLogDisable(), testLogStdoutOnly(), testStringLogAppend(), testStringMultiPLog(), testStringPLog(), and testStringPLogLevel().
std::ostream & PLog::getLogAlways | ( | ) |
std::ostream & PLog::getLogCritical | ( | ) |
Write critical message into the PLog.
Definition at line 237 of file PLog.cpp.
References CRITICAL, and getLog().
Referenced by testStringLogAppend(), and testStringPLogLevel().
std::ostream & PLog::getLogDebug | ( | ) |
Write debug message into the PLog.
Definition at line 209 of file PLog.cpp.
References DEBUG, and getLog().
Referenced by testStringLogAppend(), and testStringPLogLevel().
std::ostream & PLog::getLogError | ( | ) |
Write error message into the PLog.
Definition at line 230 of file PLog.cpp.
References ERROR, and getLog().
Referenced by testStringLogAppend(), and testStringPLogLevel().
std::ofstream & PLog::getLogFile | ( | ) |
std::ostream & PLog::getLogInfo | ( | ) |
Write info message into the PLog.
Definition at line 216 of file PLog.cpp.
References getLog(), and INFO.
Referenced by testStringLogAppend(), and testStringPLogLevel().
PLog::Level PLog::getLogLevel | ( | ) | const |
std::stringstream & PLog::getLogString | ( | ) |
Get the log string.
Definition at line 189 of file PLog.cpp.
References p_logString.
Referenced by testStringLogAppend().
std::ostream & PLog::getLogWarning | ( | ) |
Write warning message into the PLog.
Definition at line 223 of file PLog.cpp.
References getLog(), and WARNING.
Referenced by testStringLogAppend(), and testStringPLogLevel().
PLog::Mode PLog::getMode | ( | ) | const |
size_t PLog::getThreadIndex | ( | ) | const |
Get the thread index of the current PLog.
Definition at line 273 of file PLog.cpp.
References p_threadIndex.
Referenced by testStringPLog().
|
private |
Initialisation function of the class PLog.
Definition at line 285 of file PLog.cpp.
References FILE_ONLY, INFO, p_isOpen, p_logLevel, p_mode, p_nullStream, p_oldStdCerrBuffer, p_oldStdCoutBuffer, p_stream, and p_threadIndex.
Referenced by PLog().
bool PLog::isOpen | ( | ) | const |
bool PLog::open | ( | ) |
Open the current PLog and its children.
Definition at line 104 of file PLog.cpp.
References getLogAlways(), getLogLevel(), open(), p_isOpen, p_vecLog, phoenix_getDate(), phoenix_logLevelToStr(), and streamOpen().
Referenced by open(), testLogCoutDedirectInFile(), testLogDisable(), testLogStdoutOnly(), testStringLogAppend(), testStringMultiPLog(), testStringPLog(), and testStringPLogLevel().
void PLog::resize | ( | size_t | nbThread | ) |
Resize the number of cihldren log file.
nbThread | : number of sub log files to be created (typically the number of threads of a program) |
Definition at line 88 of file PLog.cpp.
References clear(), PPath::eraseExtension(), PPath::getExtension(), p_fileName, p_logLevel, p_mode, p_vecLog, PLog(), and valueToString().
Referenced by testStringMultiPLog().
void PLog::setFileName | ( | const PPath & | fileName | ) |
Set the output filename of the current PLog.
fileName | : output filename of the current PLog |
Definition at line 60 of file PLog.cpp.
References p_fileName.
Referenced by testLogCoutDedirectInFile(), testLogDisable(), testLogStdoutOnly(), testStringLogAppend(), testStringMultiPLog(), testStringPLog(), and testStringPLogLevel().
void PLog::setLogLevel | ( | PLog::Level | logLevel | ) |
Set the log level of the current PLog.
logLevel | : log level of the current PLog |
Definition at line 74 of file PLog.cpp.
References p_logLevel.
Referenced by testStringLogAppend(), and testStringPLogLevel().
void PLog::setMode | ( | PLog::Mode | mode | ) |
Set the mode of the current PLog.
mode | : mode of the current PLog |
Definition at line 67 of file PLog.cpp.
References p_mode.
Referenced by testLogCoutDedirectInFile(), testLogDisable(), testLogStdoutOnly(), and testStringLogAppend().
void PLog::setThreadIndex | ( | size_t | threadIndex | ) |
Set the thread index of the current PLog.
threadIndex | : thread index of the current PLog |
Definition at line 81 of file PLog.cpp.
References p_threadIndex.
Referenced by testStringLogAppend(), and testStringPLog().
|
private |
Open the streams.
Definition at line 309 of file PLog.cpp.
References allocateStream(), DISABLE, FILE_CAPTURE_STDOUT_STDERR, FILE_ONLY, p_fileName, p_logFile, p_logString, p_mode, p_oldStdCerrBuffer, p_oldStdCoutBuffer, STDOUT_ONLY, and STRING_ONLY.
Referenced by open().
|
private |
Output filename of the current PLog.
Definition at line 80 of file PLog.h.
Referenced by getFileName(), resize(), setFileName(), and streamOpen().
|
private |
|
private |
Current log file to be used.
Definition at line 82 of file PLog.h.
Referenced by close(), getLogFile(), and streamOpen().
|
private |
Current log level of the PLog (all log greater or equal to the p_logLevel will be logged)
Definition at line 78 of file PLog.h.
Referenced by getLog(), getLogLevel(), initialisationPLog(), resize(), and setLogLevel().
|
private |
|
private |
Mode of the logger.
Definition at line 76 of file PLog.h.
Referenced by getMode(), initialisationPLog(), resize(), setMode(), and streamOpen().
|
private |
Stream used to disable log output.
Definition at line 88 of file PLog.h.
Referenced by getLog(), initialisationPLog(), and ~PLog().
|
private |
Old std::cerr buffer.
Definition at line 90 of file PLog.h.
Referenced by close(), initialisationPLog(), and streamOpen().
|
private |
Old std::cout buffer.
Definition at line 92 of file PLog.h.
Referenced by close(), initialisationPLog(), and streamOpen().
|
private |
Current stream to be used to log things.
Definition at line 86 of file PLog.h.
Referenced by allocateStream(), close(), getLog(), and initialisationPLog().
|
private |
Index of the current thread.
Definition at line 98 of file PLog.h.
Referenced by getLog(), getThreadIndex(), initialisationPLog(), and setThreadIndex().
|
private |