]> git.stg.codes - stg.git/blob - stglibs/stg_logger.lib/stg_logger.h
Remove const qualifier from function definitions
[stg.git] / stglibs / stg_logger.lib / stg_logger.h
1 #ifndef STG_LOGGER_H
2 #define STG_LOGGER_H
3
4 #include <pthread.h>
5
6 #include <string>
7
8 #include "stg/noncopyable.h"
9
10 const char * LogDate(time_t t);
11 //-----------------------------------------------------------------------------
12 class STG_LOGGER;
13 STG_LOGGER & GetStgLogger();
14 //-----------------------------------------------------------------------------
15 class STG_LOGGER_LOCKER : private NONCOPYABLE
16 {
17 public:
18     STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); };
19     ~STG_LOGGER_LOCKER() { pthread_mutex_unlock(mutex); };
20 private:
21     pthread_mutex_t * mutex;
22 };
23 //-----------------------------------------------------------------------------
24 class STG_LOGGER
25 {
26 friend STG_LOGGER & GetStgLogger();
27
28 public:
29     ~STG_LOGGER();
30     void SetLogFileName(const std::string & fn);
31     void operator()(const char * fmt, ...);
32
33 private:
34     STG_LOGGER();
35     const char * LogDate(time_t t);
36
37     std::string fileName;
38     pthread_mutex_t mutex;
39 };
40 //-----------------------------------------------------------------------------
41
42 #endif //STG_LOGGER_H