Permalink
Please sign in to comment.
Showing
with
62 additions
and 7 deletions.
| @@ -0,0 +1,31 @@ | ||
| +#ifndef LOG_H_ | ||
| +#define LOG_H_ | ||
| + | ||
| +#include <iostream> | ||
| +#include "threading.h" | ||
| + | ||
| +class SyncLogger { | ||
| +public: | ||
| + SyncLogger() { | ||
| + MUTEX_INIT(lock_); | ||
| + } | ||
| + | ||
| + void msg(const char *s) { | ||
| + MUTEX_LOCK(lock_); | ||
| + std::cout << s << std::endl; | ||
| + MUTEX_UNLOCK(lock_); | ||
| + } | ||
| + | ||
| + void msg(const std::string& s) { | ||
| + MUTEX_LOCK(lock_); | ||
| + std::cout << s << std::endl; | ||
| + MUTEX_UNLOCK(lock_); | ||
| + } | ||
| + | ||
| +private: | ||
| + MUTEX_T lock_; | ||
| +}; | ||
| + | ||
| +extern SyncLogger glog; | ||
| + | ||
| +#endif /*LOG_H_*/ |
0 comments on commit
cb0599f