From ca952928ee103fe6285569073242e7840af551dd Mon Sep 17 00:00:00 2001 From: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:20:47 +1200 Subject: [PATCH] Syslog and logging tweaks (#34941) * Make syslog ident and facility overridable and tweak options * Linux: Be a little less verbose when writing settings --- src/platform/Linux/CHIPLinuxStorageIni.cpp | 6 +----- src/platform/logging/impl/Syslog.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/platform/Linux/CHIPLinuxStorageIni.cpp b/src/platform/Linux/CHIPLinuxStorageIni.cpp index 1a968876282e1a..7186fe3d477fbf 100644 --- a/src/platform/Linux/CHIPLinuxStorageIni.cpp +++ b/src/platform/Linux/CHIPLinuxStorageIni.cpp @@ -98,17 +98,13 @@ CHIP_ERROR ChipLinuxStorageIni::CommitConfig(const std::string & configFile) if (fd != -1) { std::ofstream ofs; - - ChipLogProgress(DeviceLayer, "writing settings to file (%s)", tmpPath.c_str()); - ofs.open(tmpPath, std::ofstream::out | std::ofstream::trunc); mConfigStore.generate(ofs); - close(fd); if (rename(tmpPath.c_str(), configFile.c_str()) == 0) { - ChipLogProgress(DeviceLayer, "renamed tmp file to file (%s)", configFile.c_str()); + ChipLogDetail(DeviceLayer, "wrote settings to %s", configFile.c_str()); } else { diff --git a/src/platform/logging/impl/Syslog.cpp b/src/platform/logging/impl/Syslog.cpp index 163e6d7398aefe..638cffeb94215e 100644 --- a/src/platform/logging/impl/Syslog.cpp +++ b/src/platform/logging/impl/Syslog.cpp @@ -23,6 +23,14 @@ #include #include +#ifndef CHIP_SYSLOG_IDENT +#define CHIP_SYSLOG_IDENT nullptr +#endif + +#ifndef CHIP_SYSLOG_FACILITY +#define CHIP_SYSLOG_FACILITY LOG_DAEMON +#endif + namespace chip { namespace Logging { namespace Platform { @@ -51,7 +59,7 @@ void LogV(const char * module, uint8_t category, const char * msg, va_list v) if (!sInitialized) { - openlog(nullptr, 0, LOG_DAEMON); + openlog(CHIP_SYSLOG_IDENT, LOG_CONS | LOG_PID, CHIP_SYSLOG_FACILITY); sInitialized = true; }