Simpact Cyan
Population based event driven simulation using mNRM
logfile.h
Go to the documentation of this file.
1 #ifndef LOGFILE_H
2 
3 #define LOGFILE_H
4 
9 #include "errut/errorbase.h"
10 #include <stdio.h>
11 #include <vector>
12 
14 class LogFile : public errut::ErrorBase
15 {
16 public:
17  LogFile();
18  ~LogFile();
19 
21  bool open(const std::string &fileName);
22 
24  std::string getFileName() const { return m_fileName; }
25 
27  void print(const char *format, ...);
28 
30  void printNoNewLine(const char *format, ...);
31 
33  void close();
34 
37  static void writeToAllLogFiles(const std::string &str);
38 private:
39  FILE *m_pFile;
40  std::string m_fileName;
41 
42  static std::vector<LogFile *> s_allLogFiles;
43 };
44 
45 #endif // LOGFILE_H
bool open(const std::string &fileName)
Opens the specified file for writing.
Definition: logfile.cpp:32
Base class which allows an error message to be set.
Definition: errorbase.h:49
Helper class to write to a log file.
Definition: logfile.h:14
void close()
Finalizes and closes the log file.
Definition: logfile.cpp:61
static void writeToAllLogFiles(const std::string &str)
Method to write something to all currently open log files, useful when program aborts and a message s...
Definition: logfile.cpp:98
std::string getFileName() const
Returns the filename from the 'open' call.
Definition: logfile.h:24
void print(const char *format,...)
Writes the specified parameters (similar to printf) to the logfile, automatically appending a newline...
Definition: logfile.cpp:70
void printNoNewLine(const char *format,...)
Writes the specified parameters (similar to printf) to the logfile.
Definition: logfile.cpp:84