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

[linux] Print log with timestamp and thread id #7299

Merged

Conversation

erjiaqing
Copy link
Contributor

Problem

We don't have timestamp in log, makes it hard to debug with multiple devices, we need to figure out the order of event happened.

Change overview

Add timestamp and thread id in log.

Testing

  • Log update, checked with local build on linux.

@msandstedt
Copy link
Contributor

Most everybody actually integrating this into a system will be sending logs to syslog, which makes these timestamps redundant. Can we make these configurable?

@woody-apple
Copy link
Contributor

src/platform/Linux/Logging.cpp Show resolved Hide resolved
@woody-apple woody-apple merged commit d2a9775 into project-chip:master Jun 2, 2021
@erjiaqing
Copy link
Contributor Author

Most everybody actually integrating this into a system will be sending logs to syslog, which makes these timestamps redundant. Can we make these configurable?

When putting logs to syslog, we may use log redirect

void LogV(uint8_t module, uint8_t category, const char * msg, va_list args)
{
if (!IsCategoryEnabled(category))
{
return;
}
char moduleName[chip::Logging::kMaxModuleNameLen + 1];
GetModuleName(moduleName, sizeof(moduleName), module);
LogRedirectCallback_t redirect = sLogRedirectCallback.load();
if (redirect != nullptr)
{
redirect(moduleName, category, msg, args);
}
else
{
Platform::LogV(moduleName, category, msg, args);
}
}

Thus this function won't be called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants