LogHelper.hpp
Go to the documentation of this file.
1 
18 #pragma once
19 
20 #include <string>
21 #include <sstream>
22 
23 #include <fstream>
24 #include <iostream>
25 
26 #include <boost/shared_ptr.hpp>
27 #include <boost/filesystem/path.hpp>
28 
29 #include "typedef.hpp"
30 
31 namespace ISM {
32 
33 using boost::filesystem::path;
34 
36 
37  class LogHelper
38  {
39 
40  public:
41  LogHelper(path logFilePath, LogLevel level);
42 
43  const static char* LOG_COLOR_DEFAULT;
44  const static char* LOG_COLOR_BLUE;
45  const static char* LOG_COLOR_RED;
46  const static char* LOG_COLOR_GREEN;
47  const static char* LOG_COLOR_YELLOW;
48  const static char* LOG_COLOR_MAGENTA;
49 
50  static void init(path logFilePath, LogLevel level);
51  static void close();
52  static LogHelperPtr getInstance();
53 
54  static void logMessage(const std::string & message, LogLevel logLevel = LOG_INFO, const char* logColor = LOG_COLOR_DEFAULT);
55  static void logLine(LogLevel logLevel = LOG_INFO);
56  static void displayProgress(double progress);
57 
58  private:
60 
61  std::ofstream mLogFile;
63 
64  static unsigned int mBarWidth;
65 
66  void log(const std::string & message, LogLevel logLevel = LOG_INFO, const char *logColor = LOG_COLOR_DEFAULT);
67  LogHelper(const LogHelper&);
69 
70  std::string getLogLevelString(LogLevel level);
71  std::string getTimeString();
72 
73  };
74 
75 
76 }
static unsigned int mBarWidth
Definition: LogHelper.hpp:64
static const char * LOG_COLOR_GREEN
Definition: LogHelper.hpp:46
void log(const std::string &message, LogLevel logLevel=LOG_INFO, const char *logColor=LOG_COLOR_DEFAULT)
Definition: LogHelper.cpp:60
static void logLine(LogLevel logLevel=LOG_INFO)
Definition: LogHelper.cpp:101
static void displayProgress(double progress)
Definition: LogHelper.cpp:147
LogHelper(path logFilePath, LogLevel level)
Definition: LogHelper.cpp:40
std::string getTimeString()
Definition: LogHelper.cpp:139
LogLevel mLogLevel
Definition: LogHelper.hpp:62
boost::shared_ptr< LogHelper > LogHelperPtr
Definition: typedef.hpp:49
static LogHelperPtr mInstance
Definition: LogHelper.hpp:59
static const char * LOG_COLOR_DEFAULT
Definition: LogHelper.hpp:43
static void logMessage(const std::string &message, LogLevel logLevel=LOG_INFO, const char *logColor=LOG_COLOR_DEFAULT)
Definition: LogHelper.cpp:96
std::string getLogLevelString(LogLevel level)
Definition: LogHelper.cpp:133
static const char * LOG_COLOR_YELLOW
Definition: LogHelper.hpp:47
LogLevel
Definition: LogHelper.hpp:35
static LogHelperPtr getInstance()
Definition: LogHelper.cpp:122
static void init(path logFilePath, LogLevel level)
Definition: LogHelper.cpp:106
static const char * LOG_COLOR_BLUE
Definition: LogHelper.hpp:44
static const char * LOG_COLOR_MAGENTA
Definition: LogHelper.hpp:48
static const char * LOG_COLOR_RED
Definition: LogHelper.hpp:45
this namespace contains all generally usable classes.
LogHelper & operator=(const LogHelper &)
std::ofstream mLogFile
Definition: LogHelper.hpp:61
static void close()
Definition: LogHelper.cpp:116


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40