File tree 3 files changed +17
-8
lines changed
3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ namespace plog
19
19
util::localtime_s (&t, &record.getTime ().time );
20
20
21
21
util::nostringstream ss;
22
- ss << t.tm_year + 1900 << PLOG_NSTR (" /" ) << 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 (" ;" );
22
+ util::nstring date, timeofday;
23
+ util::formatTime (&record.getTime (), &date, &timeofday);
24
+ ss << date << PLOG_NSTR (" ;" ) << timeofday << PLOG_NSTR (" ;" );
24
25
ss << severityToString (record.getSeverity ()) << PLOG_NSTR (" ;" );
25
26
ss << record.getTid () << PLOG_NSTR (" ;" );
26
27
ss << record.getObject () << PLOG_NSTR (" ;" );
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ namespace plog
16
16
static util::nstring format (const Record& record)
17
17
{
18
18
util::nostringstream ss;
19
- ss << util::formatTime (&record.getTime ());
19
+ util::nstring date, timeofday;
20
+ util::formatTime (&record.getTime (), &date, &timeofday);
21
+ ss << date << PLOG_NSTR (" " ) << timeofday << PLOG_NSTR (" " );
20
22
ss << std::setfill (PLOG_NSTR (' ' )) << std::setw (5 ) << std::left << severityToString (record.getSeverity ()) << PLOG_NSTR (" " );
21
23
ss << PLOG_NSTR (" [" ) << record.getTid () << PLOG_NSTR (" ] " );
22
24
ss << PLOG_NSTR (" [" ) << record.getFunc () << PLOG_NSTR (" @" ) << record.getLine () << PLOG_NSTR (" ] " );
Original file line number Diff line number Diff line change @@ -91,15 +91,21 @@ namespace plog
91
91
}
92
92
#endif
93
93
94
- inline util::nstring formatTime (const Time* time)
94
+ inline void formatTime (const Time* time, nstring* date, nstring* timeofday )
95
95
{
96
96
struct tm t;
97
97
util::localtime_s (&t, &(time ->time ));
98
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 ();
99
+ if (date != NULL ) {
100
+ nostringstream 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 ;
102
+ *date = ss.str ();
103
+ }
104
+ if (timeofday != NULL ) {
105
+ nostringstream ss;
106
+ 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 ;
107
+ *timeofday = ss.str ();
108
+ }
103
109
}
104
110
105
111
inline unsigned int gettid ()
You can’t perform that action at this time.
0 commit comments