File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,8 @@ namespace plog
15
15
16
16
static util::nstring format (const Record& record)
17
17
{
18
- tm t;
19
- util::localtime_s (&t, &record.getTime ().time );
20
-
21
18
util::nostringstream ss;
22
- 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 (" " );
23
- 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 (" " );
19
+ ss << util::formatTime (&record.getTime ());
24
20
ss << std::setfill (PLOG_NSTR (' ' )) << std::setw (5 ) << std::left << severityToString (record.getSeverity ()) << PLOG_NSTR (" " );
25
21
ss << PLOG_NSTR (" [" ) << record.getTid () << PLOG_NSTR (" ] " );
26
22
ss << PLOG_NSTR (" [" ) << record.getFunc () << PLOG_NSTR (" @" ) << record.getLine () << PLOG_NSTR (" ] " );
Original file line number Diff line number Diff line change 2
2
#include < cassert>
3
3
#include < cstring>
4
4
#include < cstdio>
5
+ #include < iomanip>
5
6
#include < sstream>
6
7
#include < fcntl.h>
7
8
#include < sys/stat.h>
@@ -90,6 +91,18 @@ namespace plog
90
91
}
91
92
#endif
92
93
94
+
95
+ inline util::nstring formatTime (const Time* time)
96
+ {
97
+ struct tm t;
98
+ util::localtime_s (&t, &(time->time ));
99
+
100
+ util::nstringstream ss;
101
+ 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 (" " );
102
+ 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 ) << time->millitm << PLOG_NSTR (" " );
103
+ return ss.str ();
104
+ }
105
+
93
106
inline unsigned int gettid ()
94
107
{
95
108
#ifdef _WIN32
You can’t perform that action at this time.
0 commit comments