From a7cadd00368dab46c894bc86ba11b4b13566df7e Mon Sep 17 00:00:00 2001 From: hashirama Date: Thu, 30 May 2024 13:24:46 -0400 Subject: [PATCH] only show log if in debug mode --- src/hakurei.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hakurei.cpp b/src/hakurei.cpp index b854df9..ebe13e8 100644 --- a/src/hakurei.cpp +++ b/src/hakurei.cpp @@ -20,6 +20,7 @@ #include +bool debug_mode = false; struct Entry { const std::string_view decoded_view; @@ -125,6 +126,7 @@ inline void print_debug_info(const std::vector& substrings, const s void log_execution(const int argc, char* argv[], const std::string& search_string, const std::string& dict_file, bool debug_mode, bool goldendict_mode) { + if (!debug_mode) return; std::ofstream log_file; log_file.open("/tmp/hakurei.log", std::ios_base::app); if (!log_file) { @@ -149,6 +151,12 @@ void log_execution(const int argc, char* argv[], const std::string& search_strin void log_internal(const std::string& message) { + extern bool debug_mode; // Declare the external debug_mode variable + + if (!debug_mode) { + return; + } + std::ofstream log_file; log_file.open("/tmp/hakurei.log", std::ios_base::app); if (!log_file) { @@ -160,7 +168,6 @@ void log_internal(const std::string& message) { log_file.close(); } - inline void wrap_html_output( const std::vector& substrings, const std::map>& alternatives_map, @@ -234,7 +241,7 @@ int main(const int argc, char* argv[]) { log_internal("Trie loaded from dictionary file"); - bool debug_mode = false; + bool goldendict_mode = false; std::string word, sentence;