尝试彩色输出
This commit is contained in:
parent
0e8abc5bee
commit
1bdc7979ce
@ -4,6 +4,24 @@
|
||||
|
||||
#include "net_server.h"
|
||||
|
||||
#define COLOR_WARN "\033[33m" // 黄色
|
||||
#define COLOR_RESET "\033[0m" // 重置颜色
|
||||
#define RESET "\033[0m"
|
||||
#define RED "\033[31m"
|
||||
#define GREEN "\033[32m"
|
||||
#define YELLOW "\033[33m"
|
||||
#define BLUE "\033[34m"
|
||||
#define MAGENTA "\033[35m"
|
||||
#define CYAN "\033[36m"
|
||||
#define WHITE "\033[37m"
|
||||
|
||||
#define LOG_WARN(logger, format, ...) \
|
||||
{ \
|
||||
std::ostringstream oss; \
|
||||
oss << COLOR_WARN << format << COLOR_RESET; \
|
||||
LOG4CPLUS_WARN_FMT(logger, oss.str().c_str(), ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
class CDemoLogger
|
||||
{
|
||||
public:
|
||||
@ -43,12 +61,13 @@ public:
|
||||
|
||||
log4cplus::Logger logger = log4cplus::Logger::getRoot();
|
||||
|
||||
//log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("logConsole"));
|
||||
// log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("logConsole"));
|
||||
LOG4CPLUS_INFO_FMT(logger, LOG4CPLUS_TEXT("Hello world"));
|
||||
std::string data("中文测试2");
|
||||
std::string data3(u8"中文测试3");
|
||||
std::cout << data << std::endl;
|
||||
std::cout << data3 << std::endl;
|
||||
LOG_WARN(logger, u8"Hello world 中文测试5 %d", 3434);
|
||||
LOG4CPLUS_WARN_FMT(logger, u8"Hello world 中文测试5 %d", 3434);
|
||||
LOG4CPLUS_WARN_FMT(logger, "Hello world 中文测试6 %d", 3434);
|
||||
LOG4CPLUS_WARN_FMT(logger, data.c_str());
|
||||
@ -64,12 +83,12 @@ int main()
|
||||
// server.run();
|
||||
// std::cout << "Done" << std::endl;
|
||||
|
||||
// #ifdef _WIN32
|
||||
// system("chcp 65001");
|
||||
// #endif
|
||||
#ifdef _WIN32
|
||||
system("chcp 65001");
|
||||
#endif
|
||||
|
||||
CDemoLogger log;
|
||||
//log.inita();
|
||||
// log.inita();
|
||||
log.initb();
|
||||
|
||||
std::cin.get();
|
||||
|
Reference in New Issue
Block a user