changed things to include plog
This commit is contained in:
parent
b018a44f10
commit
68a1618743
34 changed files with 2702 additions and 27 deletions
57
include/plog/Formatters/CsvFormatter.h
Normal file
57
include/plog/Formatters/CsvFormatter.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
#include <plog/Record.h>
|
||||
#include <plog/Util.h>
|
||||
#include <iomanip>
|
||||
|
||||
namespace plog
|
||||
{
|
||||
template<bool useUtcTime>
|
||||
class CsvFormatterImpl
|
||||
{
|
||||
public:
|
||||
static util::nstring header()
|
||||
{
|
||||
return PLOG_NSTR("Date;Time;Severity;TID;This;Function;Message\n");
|
||||
}
|
||||
|
||||
static util::nstring format(const Record& record)
|
||||
{
|
||||
tm t;
|
||||
useUtcTime ? util::gmtime_s(&t, &record.getTime().time) : util::localtime_s(&t, &record.getTime().time);
|
||||
|
||||
util::nostringstream ss;
|
||||
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(";");
|
||||
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) << static_cast<int> (record.getTime().millitm) << PLOG_NSTR(";");
|
||||
ss << severityToString(record.getSeverity()) << PLOG_NSTR(";");
|
||||
ss << record.getTid() << PLOG_NSTR(";");
|
||||
ss << record.getObject() << PLOG_NSTR(";");
|
||||
ss << record.getFunc() << PLOG_NSTR("@") << record.getLine() << PLOG_NSTR(";");
|
||||
|
||||
util::nstring message = record.getMessage();
|
||||
|
||||
if (message.size() > kMaxMessageSize)
|
||||
{
|
||||
message.resize(kMaxMessageSize);
|
||||
message.append(PLOG_NSTR("..."));
|
||||
}
|
||||
|
||||
util::nistringstream split(message);
|
||||
util::nstring token;
|
||||
|
||||
while (!split.eof())
|
||||
{
|
||||
std::getline(split, token, PLOG_NSTR('"'));
|
||||
ss << PLOG_NSTR("\"") << token << PLOG_NSTR("\"");
|
||||
}
|
||||
|
||||
ss << PLOG_NSTR("\n");
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static const size_t kMaxMessageSize = 32000;
|
||||
};
|
||||
|
||||
class CsvFormatter : public CsvFormatterImpl<false> {};
|
||||
class CsvFormatterUtcTime : public CsvFormatterImpl<true> {};
|
||||
}
|
23
include/plog/Formatters/FuncMessageFormatter.h
Normal file
23
include/plog/Formatters/FuncMessageFormatter.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include <plog/Record.h>
|
||||
#include <plog/Util.h>
|
||||
|
||||
namespace plog
|
||||
{
|
||||
class FuncMessageFormatter
|
||||
{
|
||||
public:
|
||||
static util::nstring header()
|
||||
{
|
||||
return util::nstring();
|
||||
}
|
||||
|
||||
static util::nstring format(const Record& record)
|
||||
{
|
||||
util::nostringstream ss;
|
||||
ss << record.getFunc() << PLOG_NSTR("@") << record.getLine() << PLOG_NSTR(": ") << record.getMessage() << PLOG_NSTR("\n");
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
}
|
23
include/plog/Formatters/MessageOnlyFormatter.h
Normal file
23
include/plog/Formatters/MessageOnlyFormatter.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include <plog/Record.h>
|
||||
#include <plog/Util.h>
|
||||
|
||||
namespace plog
|
||||
{
|
||||
class MessageOnlyFormatter
|
||||
{
|
||||
public:
|
||||
static util::nstring header()
|
||||
{
|
||||
return util::nstring();
|
||||
}
|
||||
|
||||
static util::nstring format(const Record& record)
|
||||
{
|
||||
util::nostringstream ss;
|
||||
ss << record.getMessage() << PLOG_NSTR("\n");
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
}
|
36
include/plog/Formatters/TxtFormatter.h
Normal file
36
include/plog/Formatters/TxtFormatter.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include <plog/Record.h>
|
||||
#include <plog/Util.h>
|
||||
#include <iomanip>
|
||||
|
||||
namespace plog
|
||||
{
|
||||
template<bool useUtcTime>
|
||||
class TxtFormatterImpl
|
||||
{
|
||||
public:
|
||||
static util::nstring header()
|
||||
{
|
||||
return util::nstring();
|
||||
}
|
||||
|
||||
static util::nstring format(const Record& record)
|
||||
{
|
||||
tm t;
|
||||
useUtcTime ? util::gmtime_s(&t, &record.getTime().time) : util::localtime_s(&t, &record.getTime().time);
|
||||
|
||||
util::nostringstream ss;
|
||||
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(" ");
|
||||
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) << static_cast<int> (record.getTime().millitm) << PLOG_NSTR(" ");
|
||||
ss << std::setfill(PLOG_NSTR(' ')) << std::setw(5) << std::left << severityToString(record.getSeverity()) << PLOG_NSTR(" ");
|
||||
ss << PLOG_NSTR("[") << record.getTid() << PLOG_NSTR("] ");
|
||||
ss << PLOG_NSTR("[") << record.getFunc() << PLOG_NSTR("@") << record.getLine() << PLOG_NSTR("] ");
|
||||
ss << record.getMessage() << PLOG_NSTR("\n");
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
class TxtFormatter : public TxtFormatterImpl<false> {};
|
||||
class TxtFormatterUtcTime : public TxtFormatterImpl<true> {};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue