Module: check_mk
Branch: master
Commit: 5c772b9fb8e61e67031e1c59a5b97174de3175e7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c772b9fb8e61e…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Mar 30 10:22:14 2017 +0200
Use a sensible default for formatting time points.
Change-Id: I5e6fabf8e9c587e491591e334174f7c9178a7525
---
livestatus/src/ChronoUtils.h | 4 ++--
livestatus/src/Logger.cc | 4 ++--
livestatus/src/module.cc | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/livestatus/src/ChronoUtils.h b/livestatus/src/ChronoUtils.h
index 551f62a..f1de078 100644
--- a/livestatus/src/ChronoUtils.h
+++ b/livestatus/src/ChronoUtils.h
@@ -78,9 +78,9 @@ typename Dur::rep time_point_part(std::chrono::system_clock::time_point
&tp) {
class FormattedTimePoint {
public:
FormattedTimePoint(std::chrono::system_clock::time_point tp,
- const std::string &format)
+ const std::string &format = "%F %T")
: _tp(tp), _format(format) {}
- FormattedTimePoint(time_t t, const std::string &format)
+ FormattedTimePoint(time_t t, const std::string &format = "%F %T")
: _tp(std::chrono::system_clock::from_time_t(t)), _format(format) {}
friend std::ostream &operator<<(std::ostream &os,
diff --git a/livestatus/src/Logger.cc b/livestatus/src/Logger.cc
index 574cfa5..42c511a 100644
--- a/livestatus/src/Logger.cc
+++ b/livestatus/src/Logger.cc
@@ -48,8 +48,8 @@ ostream &operator<<(ostream &os, const LogLevel &c) {
// -----------------------------------------------------------------------------
void SimpleFormatter::format(ostream &os, const LogRecord &record) {
- os << FormattedTimePoint(record.getTimePoint(), "%F %T ") //
- << "[" << record.getLevel() << "] " <<
record.getMessage();
+ os << FormattedTimePoint(record.getTimePoint()) << //
+ " [" << record.getLevel() << "] " <<
record.getMessage();
}
SharedStreamHandler::SharedStreamHandler(mutex &mutex, ostream &os)
diff --git a/livestatus/src/module.cc b/livestatus/src/module.cc
index 26292b5..46a8003 100644
--- a/livestatus/src/module.cc
+++ b/livestatus/src/module.cc
@@ -286,7 +286,7 @@ public:
private:
class LivestatusFormatter : public Formatter {
void format(ostream &os, const LogRecord &record) override {
- os << FormattedTimePoint(record.getTimePoint(), "%F %T [")
+ os << FormattedTimePoint(record.getTimePoint()) << "
["
<< tl_info->name << "] " <<
record.getMessage();
}
} _formatter;