GeNN  4.0.0
GPU enhanced Neuronal Networks (GeNN)
TxtFormatter.h
Go to the documentation of this file.
1 #pragma once
2 #include <plog/Record.h>
3 #include <plog/Util.h>
4 #include <iomanip>
5 
6 namespace plog
7 {
8  template<bool useUtcTime>
10  {
11  public:
13  {
14  return util::nstring();
15  }
16 
17  static util::nstring format(const Record& record)
18  {
19  tm t;
20  (useUtcTime ? util::gmtime_s : util::localtime_s)(&t, &record.getTime().time);
21 
23  ss << t.tm_year + 1900 << "-" << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_mon + 1 << PLOG_NSTR("-") << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_mday << PLOG_NSTR(" ");
24  ss << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_hour << PLOG_NSTR(":") << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_min << PLOG_NSTR(":") << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_sec << PLOG_NSTR(".") << std::setfill(PLOG_NSTR('0')) << std::setw(3) << record.getTime().millitm << PLOG_NSTR(" ");
25  ss << std::setfill(PLOG_NSTR(' ')) << std::setw(5) << std::left << severityToString(record.getSeverity()) << PLOG_NSTR(" ");
26  ss << PLOG_NSTR("[") << record.getTid() << PLOG_NSTR("] ");
27  ss << PLOG_NSTR("[") << record.getFunc() << PLOG_NSTR("@") << record.getLine() << PLOG_NSTR("] ");
28  ss << record.getMessage() << PLOG_NSTR("\n");
29 
30  return ss.str();
31  }
32  };
33 
34  class TxtFormatter : public TxtFormatterImpl<false> {};
35  class TxtFormatterUtcTime : public TxtFormatterImpl<true> {};
36 }
Definition: AndroidAppender.h:5
unsigned short millitm
Definition: Util.h:99
#define PLOG_NSTR(x)
Definition: Util.h:43
time_t time
Definition: Util.h:98
void localtime_s(struct tm *t, const time_t *time)
Definition: Util.h:62
static util::nstring format(const Record &record)
Definition: TxtFormatter.h:17
static util::nstring header()
Definition: TxtFormatter.h:12
virtual const char * getFunc() const
Definition: Record.h:211
void gmtime_s(struct tm *t, const time_t *time)
Definition: Util.h:75
Definition: TxtFormatter.h:34
virtual const util::Time & getTime() const
Definition: Record.h:180
std::ostringstream nostringstream
Definition: Util.h:57
virtual size_t getLine() const
Definition: Record.h:200
virtual Severity getSeverity() const
Definition: Record.h:185
std::string nstring
Definition: Util.h:56
const char * severityToString(Severity severity)
Definition: Severity.h:16
Definition: Record.h:102
Definition: TxtFormatter.h:35
Definition: TxtFormatter.h:9
virtual unsigned int getTid() const
Definition: Record.h:190
virtual const util::nchar * getMessage() const
Definition: Record.h:205