b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

log4cpp_log4cpp使用_log4cpp下载(6)

电脑杂谈  发布时间:2016-12-26 05:02:14  来源:网络整理

{

std::string message; //vector<char>

va_list args;

va_start(args,format);

message.reserve(_vscprintf(format.c_str(),args) + 1); //_vscprintf只能在windows上使用

vsprintf((char*)message.c_str(),format.c_str(),args);

switch (level)

{

case EMERG:

Emerg(message.c_str());

break;

case FATAL:

Fatal(message.c_str());

break;

case ALERT:

Alert(message.c_str());

break;

case CRIT:

Crit(message.c_str());

break;

case ERROR:

Error(message.c_str());

break;

case WARN: //default

Warn(message.c_str());

break;

case NOTICE:

Notice(message.c_str());

break;

case INFO:

Info(message.c_str());

break;

case DEBUG:

Debug(message.c_str());

break;

case NOTSET:

//break;

default:

Warn(message.c_str());

break;

}

}

void MyLog::SetNDC(const char* ndc)

{

log4cpp::NDC::push(ndc);

}

void MyLog::ClearNDC()

{

log4cpp::NDC::clear();

}

void MyLog::LoadConfigure(const char* filename)

{

if (filename == nullptr)

{

filename = ".\\include\\tests\\log4cpp.property";

}

log4cpp::PropertyConfigurator::configure(filename);

m_pCategory = &log4cpp::Category::getRoot();

}

MyLog& MyLog::operator<<(PriorityLevel level)

{

SetPriority(level);

return *this;

}

MyLog& MyLog::operator<<(const char* msg)

{

Message(m_prioritylevel, msg);

return *this;

}

MyLog& MyLog::operator<<(std::string& msg)

{

Message(m_prioritylevel, msg);

return *this;

}

MyLog& MyLog::operator>>(AppenderStyle appender)

{

SetAppender(appender);

return *this;

}

MyLog& MyLog::operator>>(const char* filename)

{

SetAppender(m_appenderstyle,filename);

return *this;

}

std::string MyLog::bin2str( const unsigned char* buf, int nstrlen )

{

stringstream ss;

ss.setf(ios::hex | ios::uppercase );

ss.width(2);

ss.fill('0');

for (int i = 0;i < nstrlen ; ++i)

{

ss << hex << (short)buf[i];

}

return ss.str();

}


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-23414-6.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...