| 1 |
< |
#pragma once |
| 2 |
< |
#include <plog/Appenders/IAppender.h> |
| 3 |
< |
#include <plog/Util.h> |
| 4 |
< |
#include <iostream> |
| 5 |
< |
|
| 6 |
< |
namespace plog |
| 7 |
< |
{ |
| 8 |
< |
template<class Formatter> |
| 9 |
< |
class ConsoleAppender : public IAppender |
| 10 |
< |
{ |
| 11 |
< |
public: |
| 12 |
< |
ConsoleAppender() |
| 13 |
< |
{ |
| 14 |
< |
#ifdef _WIN32 |
| 15 |
< |
::setlocale(LC_ALL, ""); |
| 16 |
< |
#endif |
| 17 |
< |
} |
| 18 |
< |
|
| 19 |
< |
virtual void write(const Record& record) |
| 20 |
< |
{ |
| 21 |
< |
util::nstring str = Formatter::format(record); |
| 22 |
< |
util::MutexLock lock(m_mutex); |
| 23 |
< |
|
| 24 |
< |
writestr(str); |
| 25 |
< |
} |
| 26 |
< |
|
| 27 |
< |
protected: |
| 28 |
< |
void writestr(const util::nstring& str) |
| 29 |
< |
{ |
| 30 |
< |
#ifdef _WIN32 |
| 31 |
< |
std::wcout << str << std::flush; |
| 32 |
< |
#else |
| 33 |
< |
std::cout << str << std::flush; |
| 34 |
< |
#endif |
| 35 |
< |
} |
| 36 |
< |
|
| 37 |
< |
protected: |
| 38 |
< |
util::Mutex m_mutex; |
| 39 |
< |
}; |
| 40 |
< |
} |
| 1 |
> |
#pragma once |
| 2 |
> |
#include <plog/Appenders/IAppender.h> |
| 3 |
> |
#include <plog/Util.h> |
| 4 |
> |
#include <iostream> |
| 5 |
> |
|
| 6 |
> |
namespace plog |
| 7 |
> |
{ |
| 8 |
> |
template<class Formatter> |
| 9 |
> |
class ConsoleAppender : public IAppender |
| 10 |
> |
{ |
| 11 |
> |
public: |
| 12 |
> |
ConsoleAppender() |
| 13 |
> |
{ |
| 14 |
> |
#ifdef _WIN32 |
| 15 |
> |
::setlocale(LC_ALL, ""); |
| 16 |
> |
#endif |
| 17 |
> |
} |
| 18 |
> |
|
| 19 |
> |
virtual void write(const Record& record) |
| 20 |
> |
{ |
| 21 |
> |
util::nstring str = Formatter::format(record); |
| 22 |
> |
util::MutexLock lock(m_mutex); |
| 23 |
> |
|
| 24 |
> |
writestr(str); |
| 25 |
> |
} |
| 26 |
> |
|
| 27 |
> |
protected: |
| 28 |
> |
void writestr(const util::nstring& str) |
| 29 |
> |
{ |
| 30 |
> |
#ifdef _WIN32 |
| 31 |
> |
std::wcout << str << std::flush; |
| 32 |
> |
#else |
| 33 |
> |
std::cout << str << std::flush; |
| 34 |
> |
#endif |
| 35 |
> |
} |
| 36 |
> |
|
| 37 |
> |
protected: |
| 38 |
> |
util::Mutex m_mutex; |
| 39 |
> |
}; |
| 40 |
> |
} |