Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsLogWriter.h
Go to the documentation of this file.
1 /*
2  *
3  * Filename: WsLogWriter.h
4  *
5  * Description: Writes log data to file using atomic operation
6  * This class is a singleton and is Thread Safe
7  *
8  * Created: 02/16/12 10:13:45
9  *
10  * Author: Benoit Daccache, ben.daccache@gmail.com
11  *
12  */
13 
14 
15 #ifndef WS_LOG_WRITER_H__
16 #define WS_LOG_WRITER_H__
17 
18 #include <iostream>
19 #include <fstream>
20 
21 #include <boost/date_time/posix_time/posix_time.hpp>
22 using namespace boost::posix_time;
23 
24 class WsGlobalProperties;
25 
26 
30 class WsLogWriter {
31 public:
36  static WsLogWriter* instance();
37 
43  void write(const int& level, const std::string& message);
44 
48  ~WsLogWriter();
49 
50 protected:
55  WsLogWriter();
60  std::string toString(int level);
64  void readConf();
65 
66 private:
68  pthread_mutex_t m_mutex;
69  std::ofstream m_logfile;
71  std::string m_path;
72 };
73 
74 #endif
std::string m_path
Definition: WsLogWriter.h:71
Global properties class.
static WsLogWriter * m_instance
Definition: WsLogWriter.h:67
LogWriter, writes logs to file or screen.
Definition: WsLogWriter.h:30
pthread_mutex_t m_mutex
Definition: WsLogWriter.h:68
int m_logLevel
Definition: WsLogWriter.h:70
std::ofstream m_logfile
Definition: WsLogWriter.h:69