File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,12 +15,8 @@ namespace plog
1515
1616 static util::nstring format (const Record& record)
1717 {
18- tm t;
19- util::localtime_s (&t, &record.getTime ().time );
20-
2118 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 ());
2420 ss << std::setfill (PLOG_NSTR (' ' )) << std::setw (5 ) << std::left << severityToString (record.getSeverity ()) << PLOG_NSTR (" " );
2521 ss << PLOG_NSTR (" [" ) << record.getTid () << PLOG_NSTR (" ] " );
2622 ss << PLOG_NSTR (" [" ) << record.getFunc () << PLOG_NSTR (" @" ) << record.getLine () << PLOG_NSTR (" ] " );
Original file line number Diff line number Diff line change 22#include < cassert>
33#include < cstring>
44#include < cstdio>
5+ #include < iomanip>
56#include < sstream>
67#include < fcntl.h>
78#include < sys/stat.h>
@@ -90,6 +91,17 @@ namespace plog
9091 }
9192#endif
9293
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+
93105 inline unsigned int gettid ()
94106 {
95107#ifdef _WIN32
You can’t perform that action at this time.
0 commit comments