Skip to content

Commit

Permalink
Fix chip_logging=false builds. (#29878)
Browse files Browse the repository at this point in the history
Fixes #29877
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Dec 13, 2023
1 parent 7cc5766 commit 2530114
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/clusters/JsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class JsonParser
private:
static void LogErrorLocation(chip::Optional<unsigned> & errorColumn, const char * json)
{
#if CHIP_ERROR_LOGGING
if (!errorColumn.HasValue())
{
return;
Expand Down Expand Up @@ -160,5 +161,6 @@ class JsonParser
errorMarker += "^";
ChipLogError(chipTool, "%s", errorMarker.c_str());
errorColumn.ClearValue();
#endif // CHIP_ERROR_LOGGING
}
};
14 changes: 0 additions & 14 deletions src/lib/support/logging/TextOnlyLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
40 changes: 26 additions & 14 deletions src/lib/support/logging/TextOnlyLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2530114

Please sign in to comment.