code blocks

git-svn-id: svn://elaine/murooma/trunk@271 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-17 06:05:07 +00:00
parent 2cf7855261
commit 16ef1ae634
53 changed files with 2074 additions and 1759 deletions

View file

@ -1,6 +1,7 @@
#include "log.h"
Log::Log(std::string ident, int facility) {
Log::Log(std::string ident, int facility)
{
facility_ = facility;
priority_ = LOG_DEBUG;
strncpy(ident_, ident.c_str(), sizeof(ident_));
@ -9,31 +10,38 @@ Log::Log(std::string ident, int facility) {
openlog(ident_, LOG_PID, facility_);
}
int Log::sync() {
if (buffer_.length()) {
if (priority_ == dbg)
std::cout << buffer_.c_str();
else
syslog(priority_, "%s", buffer_.c_str());
int Log::sync()
{
if (buffer_.length())
{
if (priority_ == dbg)
std::cout << buffer_.c_str();
else
syslog(priority_, "%s", buffer_.c_str());
buffer_.erase();
priority_ = LOG_DEBUG; // default to debug for each message
}
return 0;
}
int Log::overflow(int c) {
if (c != EOF) {
int Log::overflow(int c)
{
if (c != EOF)
{
buffer_ += static_cast<char>(c);
} else {
}
else
{
sync();
}
return c;
}
std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority) {
std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority)
{
static_cast<Log *>(os.rdbuf())->priority_ = (int)log_priority;
if (log_priority == dbg)
os.flush();
if (log_priority == dbg)
os.flush();
return os;
}