From ed5d85c6f6f65c0bfccfbe088a8bd9b18e9f3bea Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Fri, 19 May 2023 11:51:02 -0400 Subject: [PATCH] Make chip::Logging::GetModuleName public (#26664) * Make chip::Logging::GetModuleName public Problem: - Platform LogV receives the module name string - To make any choices based on module, the module names must be visible - Somehow the module names getter was not public This PR: - Make the function public (no functional change) Testing done: - Still builds, unit tests pass * Restyled by clang-format --------- Co-authored-by: tennessee.carmelveilleux@gmail.com Co-authored-by: Restyled.io --- src/lib/support/logging/CHIPLogging.cpp | 6 +++--- src/lib/support/logging/CHIPLogging.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/support/logging/CHIPLogging.cpp b/src/lib/support/logging/CHIPLogging.cpp index a1eac1324e6b3b..fd8d782efb2d08 100644 --- a/src/lib/support/logging/CHIPLogging.cpp +++ b/src/lib/support/logging/CHIPLogging.cpp @@ -154,13 +154,13 @@ static const char ModuleNames[kLogModule_Max][kMaxModuleNameLen + 1] = { "CSM", // CASESessionManager }; -static char const * GetModuleName(LogModule module) +} // namespace + +const char * GetModuleName(LogModule module) { return ModuleNames[(module < kLogModule_Max) ? module : kLogModule_NotSpecified]; } -} // namespace - void SetLogRedirectCallback(LogRedirectCallback_t callback) { sLogRedirectCallback.store(callback); diff --git a/src/lib/support/logging/CHIPLogging.h b/src/lib/support/logging/CHIPLogging.h index 3d0dd96d2f5f60..ba13ac96f181ce 100644 --- a/src/lib/support/logging/CHIPLogging.h +++ b/src/lib/support/logging/CHIPLogging.h @@ -83,6 +83,9 @@ using ByteSpan = Span; 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);