Add scoped_logger from waif
This commit is contained in:
parent
886a36ad5c
commit
011ac70a9d
12
log.cpp
12
log.cpp
@ -133,3 +133,15 @@ util::detail::log (level_t level, boost::format &&format) {
|
||||
<< format
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
scoped_logger::scoped_logger (const level_t _level,
|
||||
const std::string &_message):
|
||||
m_level (_level),
|
||||
m_message (_message)
|
||||
{ ; }
|
||||
|
||||
|
||||
scoped_logger::~scoped_logger () {
|
||||
log (m_level, m_message);
|
||||
}
|
||||
|
13
log.hpp
13
log.hpp
@ -20,6 +20,8 @@
|
||||
#ifndef __UTIL_LOG_HPP
|
||||
#define __UTIL_LOG_HPP
|
||||
|
||||
#include "nocopy.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
@ -69,6 +71,17 @@ namespace util {
|
||||
#else
|
||||
#define LOG_DEBUG(...) do { ; } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
class scoped_logger : public nocopy {
|
||||
public:
|
||||
scoped_logger (const level_t, const std::string&);
|
||||
~scoped_logger ();
|
||||
|
||||
protected:
|
||||
const level_t m_level;
|
||||
const std::string &m_message;
|
||||
};
|
||||
}
|
||||
|
||||
#include "log.ipp"
|
||||
|
Loading…
Reference in New Issue
Block a user