PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
main.cpp File Reference
#include <time.h>
#include <iostream>
#include "phoenix_assert.h"
#include "PLog.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
void testLogCoutDedirectInFile ()
 Test if the std::cout redirection is working. More...
 
void testLogDisable ()
 Test if the std::cout redirection is working. More...
 
void testLogLevelToString ()
 Test the conversion of log level into string. More...
 
void testLogStdoutOnly ()
 Test if the std::cout redirection is working. More...
 
void testStringLogAppend ()
 Test if the STRING_ONLY log mode works. More...
 
void testStringMultiPLog ()
 Test the PLog. More...
 
void testStringPLog ()
 Test the PLog. More...
 
void testStringPLogLevel ()
 Test the PLog. More...
 
void testStringToLogLevel ()
 Test the conversion of string into log level. More...
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 157 of file main.cpp.

157  {
160  testStringPLog();
165  testLogDisable();
167  return 0;
168 }
void testLogStdoutOnly()
Test if the std::cout redirection is working.
Definition: main.cpp:96
void testStringMultiPLog()
Test the PLog.
Definition: main.cpp:67
void testStringToLogLevel()
Test the conversion of string into log level.
Definition: main.cpp:24
void testStringLogAppend()
Test if the STRING_ONLY log mode works.
Definition: main.cpp:120
void testLogDisable()
Test if the std::cout redirection is working.
Definition: main.cpp:109
void testLogLevelToString()
Test the conversion of log level into string.
Definition: main.cpp:14
void testStringPLogLevel()
Test the PLog.
Definition: main.cpp:47
void testStringPLog()
Test the PLog.
Definition: main.cpp:34
void testLogCoutDedirectInFile()
Test if the std::cout redirection is working.
Definition: main.cpp:82

References testLogCoutDedirectInFile(), testLogDisable(), testLogLevelToString(), testLogStdoutOnly(), testStringLogAppend(), testStringMultiPLog(), testStringPLog(), testStringPLogLevel(), and testStringToLogLevel().

+ Here is the call graph for this function:

◆ testLogCoutDedirectInFile()

void testLogCoutDedirectInFile ( )

Test if the std::cout redirection is working.

Definition at line 82 of file main.cpp.

82  {
83  PLog log;
84  log.setFileName(PPath("logFileRedirectCoutCerr.log"));
86  phoenix_assert(log.open());
87 
88  std::cout << "Some redirected std::cout stuff" << std::endl;
89  std::cerr << "Some redirected std::cerr stuff" << std::endl;
90  log.getLog() << "Some classic log" << std::endl;
91 
92  log.close(); //Stops the redirection
93 }
Phoenix Logger.
Definition: PLog.h:21
void setFileName(const PPath &fileName)
Set the output filename of the current PLog.
Definition: PLog.cpp:60
void close()
Close the current PLog and its children.
Definition: PLog.cpp:123
PLog & getLog(size_t threadIndex)
Get the PLog at given index.
Definition: PLog.cpp:175
void setMode(PLog::Mode mode)
Set the mode of the current PLog.
Definition: PLog.cpp:67
@ FILE_CAPTURE_STDOUT_STDERR
Definition: PLog.h:28
bool open()
Open the current PLog and its children.
Definition: PLog.cpp:104
Path of a directory or a file.
Definition: PPath.h:17
#define phoenix_assert(isOk)

References PLog::close(), PLog::FILE_CAPTURE_STDOUT_STDERR, PLog::getLog(), PLog::open(), phoenix_assert, PLog::setFileName(), and PLog::setMode().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testLogDisable()

void testLogDisable ( )

Test if the std::cout redirection is working.

Definition at line 109 of file main.cpp.

109  {
110  PLog log;
111  log.setFileName(PPath("logFileDisable.log"));
112  log.setMode(PLog::DISABLE);
113  phoenix_assert(log.open());
114  log.getLog() << "Some log message" << std::endl;
115  log.getLog() << "Some classic log" << std::endl;
116  log.close(); //Stops the redirection
117 }
@ DISABLE
Definition: PLog.h:29

References PLog::close(), PLog::DISABLE, PLog::getLog(), PLog::open(), phoenix_assert, PLog::setFileName(), and PLog::setMode().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testLogLevelToString()

void testLogLevelToString ( )

Test the conversion of log level into string.

Definition at line 14 of file main.cpp.

14  {
21 }
PString phoenix_logLevelToStr(PLog::Level logLevel)
Convert the log level into a PString.
Definition: PLog.cpp:15
@ CRITICAL
Definition: PLog.h:37
@ INFO
Definition: PLog.h:34
@ DEBUG
Definition: PLog.h:33
@ ERROR
Definition: PLog.h:36
@ ALWAYS
Definition: PLog.h:38
@ WARNING
Definition: PLog.h:35

References PLog::ALWAYS, PLog::CRITICAL, PLog::DEBUG, PLog::ERROR, PLog::INFO, phoenix_assert, phoenix_logLevelToStr(), and PLog::WARNING.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testLogStdoutOnly()

void testLogStdoutOnly ( )

Test if the std::cout redirection is working.

Definition at line 96 of file main.cpp.

96  {
97  PLog log;
98  log.setFileName(PPath("logFileStdOutOnly.log"));
100  phoenix_assert(log.open());
101 
102  log.getLog() << "Some log message" << std::endl;
103  log.getLog() << "Some classic log" << std::endl;
104 
105  log.close(); //Stops the redirection
106 }
@ STDOUT_ONLY
Definition: PLog.h:27

References PLog::close(), PLog::getLog(), PLog::open(), phoenix_assert, PLog::setFileName(), PLog::setMode(), and PLog::STDOUT_ONLY.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testStringLogAppend()

void testStringLogAppend ( )

Test if the STRING_ONLY log mode works.

Definition at line 120 of file main.cpp.

120  {
121  PLog log;
122  log.setFileName(PPath("logFileStringAppend.log"));
124  phoenix_assert(log.open());
125  log.getLogInfo() << "Let's test log append" << std::endl;
126 
127  PLog logStr;
128  logStr.setThreadIndex(1lu);
129  logStr.setLogLevel(PLog::DEBUG);
130  logStr.setMode(PLog::STRING_ONLY);
131  phoenix_assert(logStr.open());
132 
133  logStr.getLog(PLog::DEBUG) << "Some debug log entry" << std::endl;
134  logStr.getLogDebug() << "Some other debug log entry" << std::endl;
135  logStr.getLog(PLog::INFO) << "Some info log entry" << std::endl;
136  logStr.getLog() << "Some other info log entry" << std::endl;
137  logStr.getLogInfo() << "Some other info log entry (again)" << std::endl;
138 
139  log.getLogInfo() << "Some log info at the same time (should be before log append)" << std::endl;
140 
141  logStr.getLog(PLog::WARNING) << "Some warning log entry" << std::endl;
142  logStr.getLogWarning() << "Some other warning log entry" << std::endl;
143  logStr.getLog(PLog::ERROR) << "Some error log entry" << std::endl;
144  logStr.getLogError() << "Some other error log entry" << std::endl;
145  logStr.getLog(PLog::CRITICAL) << "Some critical log entry" << std::endl;
146  logStr.getLogCritical() << "Some other critical log entry" << std::endl;
147 
148  log.getLogInfo() << "Just before log append" << std::endl;
149 // logStr.close();
150  log.appendLog(logStr.getLogString());
151  logStr.close();
152  log.getLogInfo() << "Just after log append" << std::endl;
153 
154  log.close();
155 }
void setThreadIndex(size_t threadIndex)
Set the thread index of the current PLog.
Definition: PLog.cpp:81
std::stringstream & getLogString()
Get the log string.
Definition: PLog.cpp:189
std::ostream & getLogDebug()
Write debug message into the PLog.
Definition: PLog.cpp:209
std::ostream & getLogInfo()
Write info message into the PLog.
Definition: PLog.cpp:216
std::ostream & getLogWarning()
Write warning message into the PLog.
Definition: PLog.cpp:223
@ STRING_ONLY
Definition: PLog.h:26
@ FILE_ONLY
Definition: PLog.h:25
void setLogLevel(PLog::Level logLevel)
Set the log level of the current PLog.
Definition: PLog.cpp:74
std::ostream & getLogCritical()
Write critical message into the PLog.
Definition: PLog.cpp:237
void appendLog(std::stringstream &str)
Append the log (STRING_ONLY mode) into an other log.
Definition: PLog.cpp:168
std::ostream & getLogError()
Write error message into the PLog.
Definition: PLog.cpp:230

References PLog::appendLog(), PLog::close(), PLog::CRITICAL, PLog::DEBUG, PLog::ERROR, PLog::FILE_ONLY, PLog::getLog(), PLog::getLogCritical(), PLog::getLogDebug(), PLog::getLogError(), PLog::getLogInfo(), PLog::getLogString(), PLog::getLogWarning(), PLog::INFO, PLog::open(), phoenix_assert, PLog::setFileName(), PLog::setLogLevel(), PLog::setMode(), PLog::setThreadIndex(), PLog::STRING_ONLY, and PLog::WARNING.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testStringMultiPLog()

void testStringMultiPLog ( )

Test the PLog.

Definition at line 67 of file main.cpp.

67  {
68  PLog log;
69  log.setFileName(PPath("logMultiFile.log")); //Always set the file name first
70  size_t nbThread(4lu);
71  log.resize(nbThread); //Then, set the number of threads
72  phoenix_assert(log.open()); //Then, open all log file
73  log.getLog() << "Log of all threads" << std::endl;
74  for(size_t i(0lu); i < nbThread; ++i){
75  PLog & subLog = log.getLog(i);
76  subLog.getLog() << " i = "<<i<<", Some log entry" << std::endl;
77  subLog.getLog() << " i = "<<i<<", Some other log entry" << std::endl;
78  }
79 }
void resize(size_t nbThread)
Resize the number of cihldren log file.
Definition: PLog.cpp:88

References PLog::getLog(), PLog::open(), phoenix_assert, PLog::resize(), and PLog::setFileName().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testStringPLog()

void testStringPLog ( )

Test the PLog.

Definition at line 34 of file main.cpp.

34  {
35  PLog log;
36  log.setFileName(PPath("logFile.log"));
37  log.setThreadIndex(2lu);
38  phoenix_assert(log.open());
39  phoenix_assert(log.getThreadIndex() == 2lu);
40  phoenix_assert(log.getFileName() == "logFile.log");
41  phoenix_assert(log.isOpen());
42  log.getLog() << "Some log entry" << std::endl;
43  log.getLog() << "Some other log entry" << std::endl;
44 }
const PPath & getFileName() const
Get the filename of the current log.
Definition: PLog.cpp:252
size_t getThreadIndex() const
Get the thread index of the current PLog.
Definition: PLog.cpp:273
bool isOpen() const
Say if the current PLog is opened or not.
Definition: PLog.cpp:280

References PLog::getFileName(), PLog::getLog(), PLog::getThreadIndex(), PLog::isOpen(), PLog::open(), phoenix_assert, PLog::setFileName(), and PLog::setThreadIndex().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testStringPLogLevel()

void testStringPLogLevel ( )

Test the PLog.

Definition at line 47 of file main.cpp.

47  {
48  PLog log;
49  log.setFileName(PPath("logLevelFile.log"));
51  phoenix_assert(log.open());
52  phoenix_assert(log.getFileName() == "logLevelFile.log");
53  log.getLog(PLog::DEBUG) << "Some debug log entry" << std::endl;
54  log.getLogDebug() << "Some other debug log entry" << std::endl;
55  log.getLog(PLog::INFO) << "Some info log entry" << std::endl;
56  log.getLog() << "Some other info log entry" << std::endl;
57  log.getLogInfo() << "Some other info log entry (again)" << std::endl;
58  log.getLog(PLog::WARNING) << "Some warning log entry" << std::endl;
59  log.getLogWarning() << "Some other warning log entry" << std::endl;
60  log.getLog(PLog::ERROR) << "Some error log entry" << std::endl;
61  log.getLogError() << "Some other error log entry" << std::endl;
62  log.getLog(PLog::CRITICAL) << "Some critical log entry" << std::endl;
63  log.getLogCritical() << "Some other critical log entry" << std::endl;
64 }

References PLog::CRITICAL, PLog::DEBUG, PLog::ERROR, PLog::getFileName(), PLog::getLog(), PLog::getLogCritical(), PLog::getLogDebug(), PLog::getLogError(), PLog::getLogInfo(), PLog::getLogWarning(), PLog::INFO, PLog::open(), phoenix_assert, PLog::setFileName(), PLog::setLogLevel(), and PLog::WARNING.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testStringToLogLevel()

void testStringToLogLevel ( )

Test the conversion of string into log level.

Definition at line 24 of file main.cpp.

24  {
31 }
PLog::Level phoenix_strToLogLevel(const PString &str)
Convert a string into a log level.
Definition: PLog.cpp:36

References PLog::ALWAYS, PLog::CRITICAL, PLog::DEBUG, PLog::ERROR, PLog::INFO, phoenix_assert, phoenix_strToLogLevel(), and PLog::WARNING.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: