You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by wa...@apache.org on 2015/06/27 09:14:14 UTC
[2/2] incubator-singa git commit: SINGA-25 - Setup glog output path
SINGA-25 - Setup glog output path
Make the log_dir an optional configuration in cluster.conf.
If this field is not set, then log is output to /tmp/ using glog's default file name.
If this field is set, then log is output to log_dir folder with the file name as <model name>-<log level>-<date time>
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/f234c497
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/f234c497
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/f234c497
Branch: refs/heads/master
Commit: f234c4972e5e027eb43643626d9e48602f460874
Parents: 90c2694
Author: wang wei <wa...@comp.nus.edu.sg>
Authored: Fri Jun 26 23:26:36 2015 +0800
Committer: wang wei <wa...@comp.nus.edu.sg>
Committed: Fri Jun 26 23:26:36 2015 +0800
----------------------------------------------------------------------
src/main.cc | 3 ++-
src/proto/cluster.proto | 2 +-
src/utils/common.cc | 13 ++++++-------
3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/f234c497/src/main.cc
----------------------------------------------------------------------
diff --git a/src/main.cc b/src/main.cc
index 2a52c07..4c2bb03 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -42,7 +42,8 @@ int main(int argc, char **argv) {
singa::ReadProtoFromTextFile(FLAGS_cluster.c_str(), &cluster);
singa::ModelProto model;
singa::ReadProtoFromTextFile(FLAGS_model.c_str(), &model);
- singa::SetupLog(cluster.workspace(), model.name());
+ if(cluster.has_log_dir())
+ singa::SetupLog(cluster.log_dir(), model.name());
LOG(INFO) << "The cluster config is\n" << cluster.DebugString();
LOG(INFO) << "The model config is\n" << model.DebugString();
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/f234c497/src/proto/cluster.proto
----------------------------------------------------------------------
diff --git a/src/proto/cluster.proto b/src/proto/cluster.proto
index 8fbdbbe..1480cc1 100644
--- a/src/proto/cluster.proto
+++ b/src/proto/cluster.proto
@@ -21,7 +21,7 @@ message ClusterProto {
// local workspace, train/val/test shards, checkpoint files
required string workspace = 14;
// relative path to workspace. if not set, use the default dir of glog
- optional string log_dir = 15 [default="/tmp"];
+ optional string log_dir = 15;
// ip/hostname : port [, ip/hostname : port]
optional string zookeeper_host = 16 [default = "localhost:2181"];
// message size limit, default 1MB
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/f234c497/src/utils/common.cc
----------------------------------------------------------------------
diff --git a/src/utils/common.cc b/src/utils/common.cc
index 1f3f1b6..67b4486 100644
--- a/src/utils/common.cc
+++ b/src/utils/common.cc
@@ -146,15 +146,14 @@ const string GetHostIP() {
return ip;
}
-void SetupLog(const std::string& workspace, const std::string& model) {
- std::string folder = workspace+"/log/";
+void SetupLog(const std::string& log_dir, const std::string& model) {
// TODO check if NFS, then create folder using script otherwise may have
// problems due to multiple processes create the same folder.
- CreateFolder(folder);
- std::string warn = folder + model + "-warn-";
- std::string info = folder + model + "-info-";
- std::string error = folder + model + "-error-";
- std::string fatal = folder + model + "-fatal-";
+ CreateFolder(log_dir);
+ std::string warn = log_dir + "/" + model + "-warn-";
+ std::string info = log_dir + "/" + model + "-info-";
+ std::string error = log_dir + "/" + model + "-error-";
+ std::string fatal = log_dir + "/" + model + "-fatal-";
google::SetLogDestination(google::WARNING, warn.c_str());
google::SetLogDestination(google::INFO, info.c_str());
google::SetLogDestination(google::ERROR, error.c_str());