本文整理汇总了C++中LogFile::SetLoglevel方法的典型用法代码示例。如果您正苦于以下问题:C++ LogFile::SetLoglevel方法的具体用法?C++ LogFile::SetLoglevel怎么用?C++ LogFile::SetLoglevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogFile
的用法示例。
在下文中一共展示了LogFile::SetLoglevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// * ================================================================================ *
// @ main
// * ================================================================================ *
int main(int argc, char ** argv)
{
//open the log file
pLogFile = &CCLogFile;
CCLogFile.startlog(1);
CCLogFile.SetLogSize(2*1000*1000);
CCLogFile.SetLoglevel(1);
CCLogFile.logopen();
if ( myconfig.readfile(CONFIG_FILE_PATH) == 0 )
{
printf("appserver: read config file '%s' error\n", CONFIG_FILE_PATH);
LOG(LOG1, "appserver: read config file '%s' error\n", CONFIG_FILE_PATH);
sleep(2);
exit(0);
}
CCLogFile.SetLoglevel(ToInt(myconfig["LogLevel"][1]));
//TANG 2010-9-4 11:02
//处理命令行参数
if ( argc == 3 && strcmp(argv[1], "reload") == 0 && strcmp(argv[2], "config") == 0 )
{
send_msg_reload_config("127.0.0.1", (( ToInt(myconfig["AppServerListenPort"][1]) > 0 ) ? ToInt(myconfig["AppServerListenPort"][1]) : 4016));
exit(0);
}
LOG(LOG1, "appserver: start\n");
child_process_init(SN3_SERVICE_NUMBER);
//application_envinit();
//LOG(LOG1, "appserver: application_envinit() done\n");
_appserver_initial();
LOG(LOG1, "appserver: _appserver_initial() done\n");
nthread_create(thread_sockserver, NULL, 64*1024);
nthread_create(thread_procdata_sendsmsg, NULL, 64*1024);
tcp_server1.SetpLog(&CCLogFile);
tcp_server1.SetCallBackFunc(deal_client_msg);
if ( ToInt(myconfig["AppServerListenPort"][1]) > 0 )
{
tcp_server1.Listen(ToInt(myconfig["AppServerListenPort"][1]), 180);
}
else
{
tcp_server1.Listen(4016, 180);
}
//NPOSITION pos;
//rundata_realtest* p_runtest;
string s_terminal, s_msg_type;
time_t t_check_hb_timeout = time(NULL);
time_t t_check_test_timeout = time(NULL);
while(g_appserver.m_runing)
{
child_process_hb(SN3_SERVICE_NUMBER);
/*
pos = NULL;
while(NULL != (p_runtest = realtest_next(pos)))
{
if ( time(NULL) >= p_runtest->tm_end )
{
CClientMsg::ansy_getitem(p_runtest->s_testdata.c_str(), "terminal", s_terminal);
CClientMsg::ansy_getitem(p_runtest->s_testdata.c_str(), "msg", s_msg_type);
//PESQ的实时测试,ftp扫描单元可能直接修改数据库的测试结果为X
CNString sql;
sql.Format("select * from BUSSOP where BUSSOP_ID = '%s' and (STATUS != 'X' and STATUS != 'Y');", p_runtest->s_bussopid.c_str());
DATASET dbresult;
if ( DB1.db_select(sql.c_str(), dbresult, LOG6) > 0 )
{
LOG(LOG1, "测试超时 [%s] '%c', s_bussopid='%s', timeout=%ds\n\n",
s_terminal.c_str(),
p_runtest->u_buss,
p_runtest->s_bussopid.c_str(),
p_runtest->tm_end - p_runtest->tm_start
);
int i_rescode = 1;
if ( dbresult[0]["STATUS"] == "W" ) i_rescode = 5001;
appserver_dbupdate_bussop_error(p_runtest->s_bussopid.c_str(), i_rescode);
}
t_uchar u_buss = p_runtest->u_buss;
p_runtest = realtest_next(pos);
//.........这里部分代码省略.........
示例2: deal_client_msg
void deal_client_msg(int state, int sockfd, const string & sockname, const string & ip, int port, void * msg, int msglen)
{
char * buf = (char *) msg;
int buflen = msglen;
if ( state == TCP_CLOSED )
{
LOG(LOG6, "server: 对方关闭连接, sockfd=%d, sockname='%s', ip='%s', port=%d\n\n", sockfd, sockname.c_str(), ip.c_str(), port);
return;
}
if ( state == TCP_MSG_TIMEOUT )
{
LOG(LOG6, "server: 接收消息超时, sockfd=%d, sockname='%s', ip='%s', port=%d\n\n", sockfd, sockname.c_str(), ip.c_str(), port);
return;
}
if ( state == TCP_MSG_ERROR )
{
LOG(LOG6, "server: 接收消息格式错误, sockfd=%d, sockname='%s', ip='%s', port=%d\n\n", sockfd, sockname.c_str(), ip.c_str(), port);
return;
}
if ( state == TCP_CONNECTED )
{
LOG(LOG6, "server: 建立连接, sockfd=%d, sockname='%s', ip='%s', port=%d\n\n", sockfd, sockname.c_str(), ip.c_str(), port);
return;
}
if ( state == TCP_COMPLETE )
{
LOG(LOG6, "server: 自己主动关闭连接, sockfd=%d, sockname='%s', ip='%s', port=%d\n\n", sockfd, sockname.c_str(), ip.c_str(), port);
return;
}
if ( state == TCP_SERVER_CLOSED )
{
LOG(LOG6, "server: 服务器停止运行, sockfd=%d, sockname='%s', ip='%s', port=%d\n\n", sockfd, sockname.c_str(), ip.c_str(), port);
return;
}
if ( state != TCP_RECV_MSG )
{
LOG(LOG1, "server: unknown call back\n\n");
return;
}
if ( buflen <= 0 )
{
LOG(LOG1, "server: msglen=%d, error\n", buflen);
return;
}
if ( strncmp(buf, "<policy-file-request/>", strlen("<policy-file-request/>")) == 0 )
{
LOG(LOG6, "service:send msg=[<policy-file-request/>] response\n");
string policy = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>";
tcp_server1.Send(sockfd, policy.c_str(), policy.length()+1, 6);
return;
}
ConfigLine xml;
xml.read_xml_msg(buf); //解析消息
if ( xml["msg"] == "hb" )
{
tcp_server1.Send(sockfd, buf, strlen(buf), 100);
return;
}
//<head>00059</head><msg>terminal_wifi_hb</msg><terminal>13701916487</terminal>
if ( xml["msg"] == "terminal_wifi_hb" )
{
tcp_server1.Send(sockfd, buf, strlen(buf), 100);
return;
}
LOG(LOG6, "server: recv msg, sockfd=%d, sockname='%s', ip='%s', port=%d, msg='%s'\n", sockfd, sockname.c_str(), ip.c_str(), port, buf);
if ( xml["msg"] == "login" )
{
//答复
string outmsg;
xml_put_para(outmsg, "head", "00000");
xml_put_para(outmsg, "msg", xml["msg"]);
xml_put_para(outmsg, "result", 0);
tcp_server1.Send(sockfd, outmsg.c_str(), outmsg.size(), 6);
}
else if ( xml["msg"] == "reload_config" )
{
if ( myconfig.readfile(CONFIG_FILE_PATH) == 0 )
{
LOG(LOG1, "server: read config file '%s' error\n", CONFIG_FILE_PATH);
}
CCLogFile.SetLoglevel(ToInt(myconfig["LogLevel"][1]));
//答复
string outmsg;
//.........这里部分代码省略.........