提交 9322cac9 编写于 作者: F felixhjh

add C++ serving change log environment variable

上级 2828a6f1
......@@ -15,6 +15,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstdlib>
#ifdef BCLOUD
#include <bthread_unstable.h> // bthread_set_worker_startfn
......@@ -135,16 +136,22 @@ int main(int argc, char** argv) {
// google::ParseCommandLineFlags(&argc, &argv, true);
g_change_server_port();
std::string base_log_path = "";
if (const char* serving_log_path = std::getenv("SERVING_LOG_PATH")) {
base_log_path = serving_log_path + '/';
}
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string log_dir = base_log_path + "./log/";
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file =
strdup((std::string("./log/") + filename + ".log").c_str());
strdup((std::string(log_dir) + filename + ".log").c_str());
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
......@@ -154,7 +161,7 @@ int main(int argc, char** argv) {
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
if (FLAGS_log_dir == "") {
FLAGS_log_dir = "./log";
FLAGS_log_dir = base_log_path + "./log";
}
struct stat st_buf;
......
......@@ -34,7 +34,7 @@ log_files = ["PipelineServingLogs", "log", "stderr.log", "stdout.log"]
def set_serving_log_path():
if 'SERVING_LOG_PATH' not in os.environ:
serving_log_path = os.path.expanduser(os.getcwd())
serving_log_path = os.path.expanduser(os.getcwd()) + '/'
os.environ['SERVING_LOG_PATH']=serving_log_path
def mv_log_to_new_dir(dir_path):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册