代码拉取完成,页面将自动刷新
#include "cpps_logging_filehandler.h"
#include "cpps_logger_config.h"
namespace cpps {
cpps_integer cpps_io_mkdirs(std::string szdir);
std::string cpps_io_getfilepath(std::string str);
cpps_logging_filehandler::cpps_logging_filehandler()
:cpps_logging_handler( cpps_logging_handler_type_filehandler)
{
file = NULL;
delay = false;
mode = "ab+";
}
cpps_logging_filehandler::~cpps_logging_filehandler()
{
if (file) fclose(file);
file = NULL;
}
void cpps_logging_filehandler::pop(usint8 level, std::string& msg)
{
while (!file) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
openfile();/*尝试重新打开*/
}
fprintf(file,"%s\r\n", msg.c_str());
fflush(file);
}
void cpps_logging_filehandler::setfile(std::string name, std::string filemode)
{
/*创建文件夹*/
std::string path = cpps_io_getfilepath(name);
cpps_io_mkdirs(path);
filename = name;
mode = filemode;
}
void cpps_logging_filehandler::setdelay(bool d)
{
delay = d;
}
void cpps_logging_filehandler::openfile()
{
if (filename.empty() || mode.empty()) return;
file = fopen(filename.c_str(), mode.c_str());
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。