diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-24 17:56:10 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-24 17:56:10 +0000 |
commit | 63e5fb76ecfed3434252868d8cf07d676f979f2f (patch) | |
tree | 349d6bd303f53aa57b988dee284c7f264404a8fc /lldb/source/Host/linux/HostInfoLinux.cpp | |
parent | 2bf871be4c35d70db080dde789cf9bb334c04057 (diff) | |
download | bcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.tar.gz bcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.zip |
[Logging] Replace Log::Printf with LLDB_LOG macro (NFC)
This patch replaces explicit calls to log::Printf with the new LLDB_LOGF
macro. The macro is similar to LLDB_LOG but supports printf-style format
strings, instead of formatv-style format strings.
So instead of writing:
if (log)
log->Printf("%s\n", str);
You'd write:
LLDB_LOG(log, "%s\n", str);
This change was done mechanically with the command below. I replaced the
spurious if-checks with vim, since I know how to do multi-line
replacements with it.
find . -type f -name '*.cpp' -exec \
sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" +
Differential revision: https://reviews.llvm.org/D65128
llvm-svn: 366936
Diffstat (limited to 'lldb/source/Host/linux/HostInfoLinux.cpp')
-rw-r--r-- | lldb/source/Host/linux/HostInfoLinux.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index 78dd77b61fa..a008a74ec95 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -88,8 +88,7 @@ llvm::StringRef HostInfoLinux::GetDistributionId() { llvm::call_once(g_once_flag, []() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST)); - if (log) - log->Printf("attempting to determine Linux distribution..."); + LLDB_LOGF(log, "attempting to determine Linux distribution..."); // check if the lsb_release command exists at one of the following paths const char *const exe_paths[] = {"/bin/lsb_release", @@ -100,9 +99,8 @@ llvm::StringRef HostInfoLinux::GetDistributionId() { const char *const get_distribution_info_exe = exe_paths[exe_index]; if (access(get_distribution_info_exe, F_OK)) { // this exe doesn't exist, move on to next exe - if (log) - log->Printf("executable doesn't exist: %s", - get_distribution_info_exe); + LLDB_LOGF(log, "executable doesn't exist: %s", + get_distribution_info_exe); continue; } @@ -112,10 +110,10 @@ llvm::StringRef HostInfoLinux::GetDistributionId() { FILE *file = popen(get_distribution_id_command.c_str(), "r"); if (!file) { - if (log) - log->Printf("failed to run command: \"%s\", cannot retrieve " - "platform information", - get_distribution_id_command.c_str()); + LLDB_LOGF(log, + "failed to run command: \"%s\", cannot retrieve " + "platform information", + get_distribution_id_command.c_str()); break; } @@ -123,9 +121,8 @@ llvm::StringRef HostInfoLinux::GetDistributionId() { char distribution_id[256] = {'\0'}; if (fgets(distribution_id, sizeof(distribution_id) - 1, file) != nullptr) { - if (log) - log->Printf("distribution id command returned \"%s\"", - distribution_id); + LLDB_LOGF(log, "distribution id command returned \"%s\"", + distribution_id); const char *const distributor_id_key = "Distributor ID:\t"; if (strstr(distribution_id, distributor_id_key)) { @@ -140,19 +137,17 @@ llvm::StringRef HostInfoLinux::GetDistributionId() { [](char ch) { return tolower(isspace(ch) ? '_' : ch); }); g_fields->m_distribution_id = id_string; - if (log) - log->Printf("distribution id set to \"%s\"", - g_fields->m_distribution_id.c_str()); + LLDB_LOGF(log, "distribution id set to \"%s\"", + g_fields->m_distribution_id.c_str()); } else { - if (log) - log->Printf("failed to find \"%s\" field in \"%s\"", - distributor_id_key, distribution_id); + LLDB_LOGF(log, "failed to find \"%s\" field in \"%s\"", + distributor_id_key, distribution_id); } } else { - if (log) - log->Printf("failed to retrieve distribution id, \"%s\" returned no" - " lines", - get_distribution_id_command.c_str()); + LLDB_LOGF(log, + "failed to retrieve distribution id, \"%s\" returned no" + " lines", + get_distribution_id_command.c_str()); } // clean up the file |