git-svn-id: svn://elaine/murooma/trunk@272 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-17 21:58:38 +00:00
parent 16ef1ae634
commit feabfee936
50 changed files with 1996 additions and 1984 deletions

View file

@ -2,47 +2,47 @@
Log::Log(std::string ident, int facility)
{
facility_ = facility;
priority_ = LOG_DEBUG;
strncpy(ident_, ident.c_str(), sizeof(ident_));
ident_[sizeof(ident_)-1] = '\0';
facility_ = facility;
priority_ = LOG_DEBUG;
strncpy(ident_, ident.c_str(), sizeof(ident_));
ident_[sizeof(ident_)-1] = '\0';
openlog(ident_, LOG_PID, 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());
buffer_.erase();
priority_ = LOG_DEBUG; // default to debug for each message
}
return 0;
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)
{
buffer_ += static_cast<char>(c);
}
else
{
sync();
}
return c;
if (c != EOF)
{
buffer_ += static_cast<char>(c);
}
else
{
sync();
}
return c;
}
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();
return os;
static_cast<Log *>(os.rdbuf())->priority_ = (int)log_priority;
if (log_priority == dbg)
os.flush();
return os;
}