shill: add object id to scoped log messages
Add object identifier (DBus::Path) string to scoped logging messages. If
the logging message is called from a static method, SLOG will be called
with nullptr and the log will use (anon) for the object id. Objects
without identifying information will use the (class_name) as their logged
identifier.
BUG=chromium:403996
TEST=ran unit tests and manually inspected net.log
Change-Id: Idf23911a303f5edc4b82917bf1e2cea3f8e44e60
Reviewed-on: https://chromium-review.googlesource.com/224812
Tested-by: Rebecca Silberstein <silberst@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Rebecca Silberstein <silberst@chromium.org>
diff --git a/connection_tester.cc b/connection_tester.cc
index 69ee454..fd988fd 100644
--- a/connection_tester.cc
+++ b/connection_tester.cc
@@ -22,6 +22,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kPortal;
+static string ObjectID(Connection *c) { return c->interface_name(); }
+}
+
const int ConnectionTester::kTrialTimeoutSeconds = 5;
ConnectionTester::ConnectionTester(
@@ -45,14 +50,14 @@
}
void ConnectionTester::Start() {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!connectivity_trial_->Start(ConnectivityTrial::kDefaultURL, 0))
LOG(ERROR) << StringPrintf("ConnectivityTrial failed to parse default "
"URL %s", ConnectivityTrial::kDefaultURL);
}
void ConnectionTester::Stop() {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
connectivity_trial_->Stop();
}