Skip to content

Commit 83136a7

Browse files
committed
Added SyslogFormatter.
Similar to the FuncMessageFormatter, but include the TID and don't add a newline at the end.
1 parent 07c679e commit 83136a7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
#include <plog/Record.h>
3+
#include <plog/Util.h>
4+
#include <utility>
5+
6+
namespace plog
7+
{
8+
class SyslogFormatter
9+
{
10+
public:
11+
static util::nstring header()
12+
{
13+
return util::nstring();
14+
}
15+
16+
static util::nstring format(const Record& record)
17+
{
18+
util::nostringstream ss;
19+
ss << PLOG_NSTR("[") << record.getTid() << PLOG_NSTR("] ")
20+
<< record.getFunc() << PLOG_NSTR("@") << record.getLine()
21+
<< PLOG_NSTR(" ") << record.getMessage() /* no line feed */;
22+
23+
#if __cplusplus > 201703L
24+
return std::move(ss).str();
25+
#else
26+
return ss.str();
27+
#endif
28+
}
29+
};
30+
}

0 commit comments

Comments
 (0)