diff --git a/README.cn.md b/README.cn.md index 5da482d5943664a9bc4920e890c9c113f5d12e6f..9236024f6846005884cac0b363383121763cbf57 100644 --- a/README.cn.md +++ b/README.cn.md @@ -95,14 +95,14 @@ for step in range(100): #include "visualdl/sdk.h" namespace vs = visualdl; -namepsace cp = visualdl::components; +namespace cp = visualdl::components; int main() { const std::string dir = "./tmp"; vs::LogWriter logger(dir, 10); logger.SetMode("train"); - auto tablet = logger.NewTablet("scalars/scalar0"); + auto tablet = logger.AddTablet("scalars/scalar0"); cp::Scalar scalar0(tablet); diff --git a/docs/README.md b/docs/README.md index 40429233175c7ed1445557b5c387324dd4d605a6..8825363c41c2002fd309def4b17b453a6b1bd755 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,14 +81,14 @@ The same code for C++ SDK in the above Python SDK is as follows #include "visualdl/sdk.h" namespace vs = visualdl; -namepsace cp = visualdl::components; +namespace cp = visualdl::components; int main() { const std::string dir = "./tmp"; vs::LogWriter logger(dir, 10); logger.SetMode("train"); - auto tablet = logger.NewTablet("scalars/scalar0"); + auto tablet = logger.AddTablet("scalars/scalar0"); cp::Scalar scalar0(tablet); diff --git a/visualdl/logic/sdk.cc b/visualdl/logic/sdk.cc index 7436bc1f9410a77e3216fa7918aa60c99a1a521a..864b4598e11a3135a2be867d4c5896a0194707f6 100644 --- a/visualdl/logic/sdk.cc +++ b/visualdl/logic/sdk.cc @@ -30,6 +30,11 @@ namespace visualdl { std::string g_log_dir; LogWriter LogWriter::AsMode(const std::string& mode) { + for (auto ch : "%/") { + CHECK(mode.find(ch) == std::string::npos) + << "character "<< ch << " is a reserved word, it is not allowed in mode."; + } + LogWriter writer = *this; storage_.AddMode(mode); writer.mode_ = mode; @@ -37,7 +42,9 @@ LogWriter LogWriter::AsMode(const std::string& mode) { } Tablet LogWriter::AddTablet(const std::string& tag) { - // TODO(ChunweiYan) add string check here. + CHECK(tag.find("%") == std::string::npos) + << "character % is a reserved word, it is not allowed in tag."; + auto tmp = mode_ + "/" + tag; string::TagEncode(tmp); auto res = storage_.AddTablet(tmp);