huajsj commented on a change in pull request #9012:
URL: https://github.com/apache/tvm/pull/9012#discussion_r712412589



##########
File path: src/runtime/logging.cc
##########
@@ -166,10 +167,118 @@ namespace tvm {
 namespace runtime {
 namespace detail {
 
+namespace {
+constexpr const char* kSrcPrefix = "/src/";
+constexpr const size_t kSrcPrefixLength = 5;
+constexpr const char* kDefaultKeyword = "DEFAULT";
+}  // namespace
+
+// Parse \p opt_spec as a VLOG specification as per comment in
+// DebugLoggingEnabled and VerboseLoggingEnabled.
+std::unordered_map<std::string, int> ParseTvmLogDebugSpec(const char* 
opt_spec) {
+  std::unordered_map<std::string, int> map;
+  if (opt_spec == nullptr) {
+    // DLOG and VLOG disabled.
+    return map;
+  }
+  std::string spec(opt_spec);
+  if (spec.empty() || spec == "0") {
+    // DLOG and VLOG disabled.
+    return map;
+  }
+  if (spec == "1") {
+    // Legacy specification for enabling just DLOG.
+    // A wildcard entry in the map will signal DLOG is on, but all VLOG levels 
are disabled.
+    LOG(INFO) << "TVM_LOG_DEBUG enables DLOG statements only";
+    map.emplace(kDefaultKeyword, -1);

Review comment:
       TVM_LOG_DEBUG gate only can help for TVM_LOG_DEBUG not define or be 0 
case, when #define TVM_LOG_DEBUG 1, and TVM_LOG_DEBUG="1",  
VerboseLoggingEnabled should directly return false instead of still doing 
filename parse and map search, I think that a normal check instead of special 
trick and doing correct check should also apply for debug build. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to