This commit is contained in:
aozhiwei 2019-01-15 13:48:28 +08:00
parent ad4aafc4fc
commit 74d3cfa5b3

View File

@ -398,18 +398,20 @@ void App::ProcessIMMsg()
void App::InitLog() void App::InitLog()
{ {
std::string filename_fmt = PROJ_LOG_FILENAME_FMT; std::string filename_fmt = PROJ_LOG_FILENAME_FMT;
if (getenv("is_dev_env")) { a8::ReplaceString(filename_fmt, "$pid", a8::XValue(getpid()));
a8::ReplaceString(filename_fmt, "$pid", a8::XValue(0));
} else {
a8::ReplaceString(filename_fmt, "$pid", a8::XValue(getpid()));
}
a8::MkDir(a8::Format(PROJ_ROOT_FMT, {a8::Format(PROJ_NAME_FMT, {GAME_ID})})); std::string proj_root_dir = a8::Format(PROJ_ROOT_FMT, {a8::Format(PROJ_NAME_FMT,{GAME_ID})});
a8::MkDir(a8::Format(PROJ_LOG_ROOT_FMT, {a8::Format(PROJ_NAME_FMT, {GAME_ID})})); std::string proj_log_root_dir = a8::Format(PROJ_LOG_ROOT_FMT, {a8::Format(PROJ_NAME_FMT, {GAME_ID})});
a8::UdpLog::Instance()->SetLogFileName(a8::Format(PROJ_LOG_ROOT_FMT, std::string log_file_name = a8::Format(PROJ_LOG_ROOT_FMT,
{a8::Format(PROJ_NAME_FMT, {GAME_ID})}) + "/" + filename_fmt {a8::Format(PROJ_NAME_FMT, {GAME_ID})}) + "/" + filename_fmt;
);
a8::MkDir(proj_root_dir);
a8::MkDir(proj_log_root_dir);
a8::UdpLog::Instance()->SetLogFileName(log_file_name);
a8::UdpLog::Instance()->Init(); a8::UdpLog::Instance()->Init();
a8::UdpLog::Instance()->Info("proj_root_dir:%s", {proj_root_dir});
a8::UdpLog::Instance()->Info("proj_log_root_dir:%s", {proj_log_root_dir});
a8::UdpLog::Instance()->Info("log_file_name:%s", {log_file_name});
} }
void App::UnInitLog() void App::UnInitLog()