From a011a040996dd4cdb0152aae2206aebc7f4f7034 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期三, 26 五月 2021 10:49:08 +0800
Subject: [PATCH] refactor, log dir.
---
box/center_main.cc | 2 +-
src/bh_api.cc | 5 +----
src/defs.h | 2 ++
src/defs.cpp | 4 +++-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/box/center_main.cc b/box/center_main.cc
index 58287e6..e7715f8 100644
--- a/box/center_main.cc
+++ b/box/center_main.cc
@@ -92,7 +92,7 @@
return 0;
}
- ns_log::AddLog("/opt/vasystem/valog/bhshmq_center.log");
+ ns_log::AddLog(BHLogDir() + "bhshmq_center.log");
auto lvl = args.Get("log", "info");
if (strcasecmp(lvl.c_str(), "trace") == 0) { ns_log::ResetLogLevel(ns_log::LogLevel::trace); }
if (strcasecmp(lvl.c_str(), "debug") == 0) { ns_log::ResetLogLevel(ns_log::LogLevel::debug); }
diff --git a/src/bh_api.cc b/src/bh_api.cc
index ca69b6e..8690d5f 100644
--- a/src/bh_api.cc
+++ b/src/bh_api.cc
@@ -36,10 +36,7 @@
static std::unique_ptr<TopicNode> ptr;
if (!ptr && GlobalInit(BHomeShm())) {
auto InitLog = []() {
- auto id = GetProcExe();
- char path[200] = {0};
- sprintf(path, "/opt/vasystem/valog/bhshmq_node_%s.log", id.c_str());
- ns_log::AddLog(path);
+ ns_log::AddLog(BHLogDir() + "bhshmq_node_" + GetProcExe() + ".log");
return true;
};
static bool init_log = InitLog();
diff --git a/src/defs.cpp b/src/defs.cpp
index a2f05cc..db0ae61 100644
--- a/src/defs.cpp
+++ b/src/defs.cpp
@@ -207,4 +207,6 @@
msg = LastErrorStore().msg_;
}
-int NodeTimeoutSec() { return 60; }
\ No newline at end of file
+int NodeTimeoutSec() { return 60; }
+
+std::string BHLogDir() { return "/opt/vasystem/valog/"; }
diff --git a/src/defs.h b/src/defs.h
index b117579..5f6fc16 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -74,4 +74,6 @@
// node mq is avail with in timeout; after that may get killed.
int NodeTimeoutSec();
+std::string BHLogDir();
+
#endif // end of include guard: DEFS_KP8LKGD0
--
Gitblit v1.8.0