File tree 2 files changed +13
-5
lines changed
2 files changed +13
-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,17 @@ namespace plog
90
91
}
91
92
#endif
92
93
94
+ inline util::nstring formatTime (const Time* time)
95
+ {
96
+ struct tm t;
97
+ util::localtime_s (&t, &(time ->time ));
98
+
99
+ nostringstream ss;
100
+ 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 (" " );
101
+ 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 (" " );
102
+ return ss.str ();
103
+ }
104
+
93
105
inline unsigned int gettid ()
94
106
{
95
107
#ifdef _WIN32
You can’t perform that action at this time.
0 commit comments