mirror of
https://github.com/Zygo/bees.git
synced 2025-06-16 17:46:16 +02:00
Add option for prefixing timestamps
To make bees more friendly to use with syslog/systemd, we add an option to omit timestamps from the log output. Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
@ -17,6 +17,7 @@ namespace crucible {
|
||||
|
||||
static shared_ptr<set<string>> chatter_names;
|
||||
static const char *SPACETAB = " \t";
|
||||
static int chatter_prefix_timestamp = 1;
|
||||
|
||||
static
|
||||
void
|
||||
@ -52,16 +53,21 @@ namespace crucible {
|
||||
{
|
||||
ostringstream header_stream;
|
||||
|
||||
time_t ltime;
|
||||
DIE_IF_MINUS_ONE(time(<ime));
|
||||
struct tm ltm;
|
||||
DIE_IF_ZERO(localtime_r(<ime, <m));
|
||||
if (chatter_prefix_timestamp) {
|
||||
time_t ltime;
|
||||
DIE_IF_MINUS_ONE(time(<ime));
|
||||
struct tm ltm;
|
||||
DIE_IF_ZERO(localtime_r(<ime, <m));
|
||||
|
||||
char buf[1024];
|
||||
DIE_IF_ZERO(strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", <m));
|
||||
char buf[1024];
|
||||
DIE_IF_ZERO(strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", <m));
|
||||
|
||||
header_stream << buf;
|
||||
header_stream << " " << getpid() << "." << gettid();
|
||||
} else {
|
||||
header_stream << "tid " << gettid();
|
||||
}
|
||||
|
||||
header_stream << buf;
|
||||
header_stream << " " << getpid() << "." << gettid();
|
||||
if (!m_name.empty()) {
|
||||
header_stream << " " << m_name;
|
||||
}
|
||||
@ -91,6 +97,11 @@ namespace crucible {
|
||||
c.m_oss.str("");
|
||||
}
|
||||
|
||||
ChatterTimestamp::ChatterTimestamp(int prefix_timestamp)
|
||||
{
|
||||
chatter_prefix_timestamp = prefix_timestamp;
|
||||
}
|
||||
|
||||
set<ChatterBox*> ChatterBox::s_boxes;
|
||||
|
||||
set<ChatterBox*>& ChatterBox::all_boxes()
|
||||
|
Reference in New Issue
Block a user