diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5412d2956536dc..902c7afc618545 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -85,18 +85,22 @@ jobs: # - name: Upload Code Coverage # if: ${{ contains('main', env.BUILD_TYPE) }} # run: bash <(curl -s https://codecov.io/bash) - - name: Setup Build Without Detail Logging + - name: Set up Build Without Detail Logging run: scripts/build/gn_gen.sh --args="chip_detail_logging=false" - name: Run Build Without Detail Logging run: scripts/run_in_build_env.sh "ninja -C ./out" - - name: Setup Build Without Progress Logging + - name: Set up Build Without Progress Logging run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false" - name: Run Build Without Progress Logging run: scripts/run_in_build_env.sh "ninja -C ./out" - - name: Setup Build Without Error Logging + - name: Set up Build Without Error Logging run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false chip_error_logging=false" - name: Run Build Without Error Logging run: scripts/run_in_build_env.sh "ninja -C ./out" + - name: Set up Build Without Logging + run: scripts/build/gn_gen.sh --args="chip_logging=false" + - name: Run Build Without Logging + run: scripts/run_in_build_env.sh "ninja -C ./out" - name: Uploading core files uses: actions/upload-artifact@v3 if: ${{ failure() && !env.ACT }} diff --git a/examples/chip-tool/commands/clusters/JsonParser.h b/examples/chip-tool/commands/clusters/JsonParser.h index adb1375bd880d1..9f13c3be8914a7 100644 --- a/examples/chip-tool/commands/clusters/JsonParser.h +++ b/examples/chip-tool/commands/clusters/JsonParser.h @@ -130,6 +130,7 @@ class JsonParser private: static void LogErrorLocation(chip::Optional & errorColumn, const char * json) { +#if CHIP_ERROR_LOGGING if (!errorColumn.HasValue()) { return; @@ -160,5 +161,6 @@ class JsonParser errorMarker += "^"; ChipLogError(chipTool, "%s", errorMarker.c_str()); errorColumn.ClearValue(); +#endif // CHIP_ERROR_LOGGING } }; diff --git a/src/lib/support/logging/TextOnlyLogging.cpp b/src/lib/support/logging/TextOnlyLogging.cpp index 738f4c81bac152..1e573942f85e17 100644 --- a/src/lib/support/logging/TextOnlyLogging.cpp +++ b/src/lib/support/logging/TextOnlyLogging.cpp @@ -221,20 +221,6 @@ void SetLogFilter(uint8_t category) gLogFilter = category; } -#else // CHIP_LOG_FILTERING - -uint8_t GetLogFilter() -{ - return kLogCategory_Max; -} - -void SetLogFilter(uint8_t category) -{ - IgnoreUnusedVariable(category); -} -#endif // CHIP_LOG_FILTERING - -#if CHIP_LOG_FILTERING bool IsCategoryEnabled(uint8_t category) { return (category <= gLogFilter); diff --git a/src/lib/support/logging/TextOnlyLogging.h b/src/lib/support/logging/TextOnlyLogging.h index a59946c2aab4c8..d6b22f7c6c5a6b 100644 --- a/src/lib/support/logging/TextOnlyLogging.h +++ b/src/lib/support/logging/TextOnlyLogging.h @@ -79,16 +79,8 @@ namespace chip { namespace Logging { -// Get the module name associated with a LogModule, or "-" on invalid value. -const char * GetModuleName(LogModule module); - // Log redirection using LogRedirectCallback_t = void (*)(const char * module, uint8_t category, const char * msg, va_list args); -DLL_EXPORT void SetLogRedirectCallback(LogRedirectCallback_t callback); - -// Log filtering (no-op unless CHIP_LOG_FILTERING is enabled) -DLL_EXPORT uint8_t GetLogFilter(); -DLL_EXPORT void SetLogFilter(uint8_t category); #if CHIP_ERROR_LOGGING /** @@ -323,18 +315,34 @@ DLL_EXPORT void SetLogFilter(uint8_t category); #define _CHIP_USE_LOGGING 0 #endif // CHIP_ERROR_LOGGING || CHIP_PROGRESS_LOGGING || CHIP_DETAIL_LOGGING || CHIP_AUTOMATION_LOGGING -#if _CHIP_USE_LOGGING +// Log filtering (no-op unless CHIP_LOG_FILTERING is enabled) +#if _CHIP_USE_LOGGING && CHIP_LOG_FILTERING +DLL_EXPORT uint8_t GetLogFilter(); +DLL_EXPORT void SetLogFilter(uint8_t category); +bool IsCategoryEnabled(uint8_t category); +#else // _CHIP_USE_LOGGING && CHIP_LOG_FILTERING +inline uint8_t GetLogFilter() +{ + return kLogCategory_Max; +} -static constexpr uint16_t kMaxModuleNameLen = 3; +inline void SetLogFilter(uint8_t category) {} -#if CHIP_LOG_FILTERING -bool IsCategoryEnabled(uint8_t category); -#else // CHIP_LOG_FILTERING inline bool IsCategoryEnabled(uint8_t category) { return true; } -#endif // CHIP_LOG_FILTERING +#endif // _CHIP_USE_LOGGING && CHIP_LOG_FILTERING + +#if _CHIP_USE_LOGGING + +// Get the module name associated with a LogModule, or "-" on invalid value. +const char * GetModuleName(LogModule module); + +// Log redirection +DLL_EXPORT void SetLogRedirectCallback(LogRedirectCallback_t callback); + +static constexpr uint16_t kMaxModuleNameLen = 3; /* Internal macros mapping upper case definitions to camel case category constants*/ #define CHIP_LOG_CATEGORY_DETAIL chip::Logging::kLogCategory_Detail @@ -427,6 +435,10 @@ void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ } while (0) #endif // CHIP_PW_TOKENIZER_LOGGING +#else // _CHIP_USE_LOGGING + +inline void SetLogRedirectCallback(LogRedirectCallback_t callback) {} + #endif // _CHIP_USE_LOGGING } // namespace Logging