log
This commit is contained in:
43
log.hpp
Normal file
43
log.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* log.hpp
|
||||
*
|
||||
* Created on: 27.03.2013
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef LOG_HPP_
|
||||
#define LOG_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <syslog.h>
|
||||
|
||||
enum LogPriority {
|
||||
kLogEmerg = LOG_EMERG, // system is unusable
|
||||
kLogAlert = LOG_ALERT, // action must be taken immediately
|
||||
kLogCrit = LOG_CRIT, // critical conditions
|
||||
kLogErr = LOG_ERR, // error conditions
|
||||
kLogWarning = LOG_WARNING, // warning conditions
|
||||
kLogNotice = LOG_NOTICE, // normal, but significant, condition
|
||||
kLogInfo = LOG_INFO, // informational message
|
||||
kLogDebug = LOG_DEBUG // debug-level message
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority);
|
||||
|
||||
class Log : public std::basic_streambuf<char, std::char_traits<char> > {
|
||||
public:
|
||||
explicit Log(std::string ident, int facility);
|
||||
|
||||
protected:
|
||||
int sync();
|
||||
int overflow(int c);
|
||||
|
||||
private:
|
||||
friend std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority);
|
||||
std::string buffer_;
|
||||
int facility_;
|
||||
int priority_;
|
||||
char ident_[50];
|
||||
};
|
||||
|
||||
#endif /* LOG_HPP_ */
|
Reference in New Issue
Block a user