]> git.stg.codes - stg.git/blobdiff - stglibs/logger.lib/include/stg/logger.h
Massive refactoring.
[stg.git] / stglibs / logger.lib / include / stg / logger.h
index 2c9c93fc2951fc77ba75e3c9203587ad0c6b44e8..c55801ac2a32570fb41348b2f74a2d604332122b 100644 (file)
@@ -5,16 +5,14 @@
 
 #include <string>
 
-const char * LogDate(time_t t);
-//-----------------------------------------------------------------------------
 class STG_LOGGER;
 STG_LOGGER & GetStgLogger();
 //-----------------------------------------------------------------------------
 class STG_LOGGER_LOCKER
 {
 public:
-    STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); };
-    ~STG_LOGGER_LOCKER() { pthread_mutex_unlock(mutex); };
+    STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); }
+    ~STG_LOGGER_LOCKER() { pthread_mutex_unlock(mutex); }
 
 private:
     STG_LOGGER_LOCKER(const STG_LOGGER_LOCKER & rvalue);
@@ -31,17 +29,17 @@ friend class PLUGIN_LOGGER;
 public:
     ~STG_LOGGER();
     void SetLogFileName(const std::string & fn);
-    void operator()(const char * fmt, ...);
+    void operator()(const char * fmt, ...) const;
 
 private:
     STG_LOGGER();
     STG_LOGGER(const STG_LOGGER & rvalue);
     STG_LOGGER & operator=(const STG_LOGGER & rvalue);
 
-    const char * LogDate(time_t t);
+    const char * LogDate(time_t t) const;
 
     std::string fileName;
-    pthread_mutex_t mutex;
+    mutable pthread_mutex_t mutex;
 };
 //-----------------------------------------------------------------------------
 class PLUGIN_LOGGER : private STG_LOGGER
@@ -50,7 +48,7 @@ friend PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER & logger, const std::strin
 
 public:
     PLUGIN_LOGGER(const PLUGIN_LOGGER & rhs);
-    void operator()(const char * fmt, ...);
+    void operator()(const char * fmt, ...) const;
 
 private:
     PLUGIN_LOGGER(const STG_LOGGER & logger, const std::string & pn);