Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syslog and logging tweaks #34941

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/platform/Linux/CHIPLinuxStorageIni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
10 changes: 9 additions & 1 deletion src/platform/logging/impl/Syslog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
#include <mutex>
#include <syslog.h>

#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 {
Expand Down Expand Up @@ -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;
}

Expand Down
Loading