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/active_passive_out_of_credits_detector.cc b/active_passive_out_of_credits_detector.cc
index 6386615..a07d4a0 100644
--- a/active_passive_out_of_credits_detector.cc
+++ b/active_passive_out_of_credits_detector.cc
@@ -4,6 +4,8 @@
#include "shill/active_passive_out_of_credits_detector.h"
+#include <string>
+
#include "shill/cellular_service.h"
#include "shill/connection.h"
#include "shill/connection_health_checker.h"
@@ -11,8 +13,17 @@
#include "shill/manager.h"
#include "shill/traffic_monitor.h"
+using std::string;
+
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(ActivePassiveOutOfCreditsDetector *a) {
+ return a->GetServiceRpcIdentifier();
+}
+}
+
// static
const int64_t
ActivePassiveOutOfCreditsDetector::kOutOfCreditsConnectionDropSeconds = 15;
@@ -29,7 +40,8 @@
: OutOfCreditsDetector(dispatcher, manager, metrics, service),
weak_ptr_factory_(this),
traffic_monitor_(
- new TrafficMonitor(service->cellular(), dispatcher)) {
+ new TrafficMonitor(service->cellular(), dispatcher)),
+ service_rpc_identifier_(service->GetRpcIdentifier()) {
ResetDetector();
traffic_monitor_->set_network_problem_detected_callback(
Bind(&ActivePassiveOutOfCreditsDetector::OnNoNetworkRouting,
@@ -41,7 +53,7 @@
}
void ActivePassiveOutOfCreditsDetector::ResetDetector() {
- SLOG(Cellular, 2) << "Reset out-of-credits detection";
+ SLOG(this, 2) << "Reset out-of-credits detection";
out_of_credits_detection_in_progress_ = false;
num_connect_attempts_ = 0;
}
@@ -52,7 +64,7 @@
void ActivePassiveOutOfCreditsDetector::NotifyServiceStateChanged(
Service::ConnectState old_state, Service::ConnectState new_state) {
- SLOG(Cellular, 2) << __func__ << ": " << old_state << " -> " << new_state;
+ SLOG(this, 2) << __func__ << ": " << old_state << " -> " << new_state;
switch (new_state) {
case Service::kStateUnknown:
case Service::kStateIdle:
@@ -66,9 +78,9 @@
if (old_state != Service::kStateAssociating) {
connect_start_time_ = base::Time::Now();
num_connect_attempts_++;
- SLOG(Cellular, 2) << __func__
- << ": num_connect_attempts="
- << num_connect_attempts_;
+ SLOG(this, 2) << __func__
+ << ": num_connect_attempts="
+ << num_connect_attempts_;
}
break;
case Service::kStateConnected:
@@ -76,8 +88,8 @@
SetupConnectionHealthChecker();
break;
case Service::kStatePortal:
- SLOG(Cellular, 2) << "Portal detection failed. Launching active probe "
- << "for out-of-credit detection.";
+ SLOG(this, 2) << "Portal detection failed. Launching active probe "
+ << "for out-of-credit detection.";
RequestConnectionHealthCheck();
break;
case Service::kStateConfiguring:
@@ -88,24 +100,24 @@
}
bool ActivePassiveOutOfCreditsDetector::StartTrafficMonitor() {
- SLOG(Cellular, 2) << __func__;
- SLOG(Cellular, 2) << "Service " << service()->friendly_name()
- << ": Traffic Monitor starting.";
+ SLOG(this, 2) << __func__;
+ SLOG(this, 2) << "Service " << service()->friendly_name()
+ << ": Traffic Monitor starting.";
traffic_monitor_->Start();
return true;
}
void ActivePassiveOutOfCreditsDetector::StopTrafficMonitor() {
- SLOG(Cellular, 2) << __func__;
- SLOG(Cellular, 2) << "Service " << service()->friendly_name()
- << ": Traffic Monitor stopping.";
+ SLOG(this, 2) << __func__;
+ SLOG(this, 2) << "Service " << service()->friendly_name()
+ << ": Traffic Monitor stopping.";
traffic_monitor_->Stop();
}
void ActivePassiveOutOfCreditsDetector::OnNoNetworkRouting(int reason) {
- SLOG(Cellular, 2) << "Service " << service()->friendly_name()
- << ": Traffic Monitor detected network congestion.";
- SLOG(Cellular, 2) << "Requesting active probe for out-of-credit detection.";
+ SLOG(this, 2) << "Service " << service()->friendly_name()
+ << ": Traffic Monitor detected network congestion.";
+ SLOG(this, 2) << "Requesting active probe for out-of-credit detection.";
RequestConnectionHealthCheck();
}
@@ -132,12 +144,12 @@
void ActivePassiveOutOfCreditsDetector::RequestConnectionHealthCheck() {
if (!health_checker_.get()) {
- SLOG(Cellular, 2) << "No health checker exists, cannot request "
- << "health check.";
+ SLOG(this, 2) << "No health checker exists, cannot request "
+ << "health check.";
return;
}
if (health_checker_->health_check_in_progress()) {
- SLOG(Cellular, 2) << "Health check already in progress.";
+ SLOG(this, 2) << "Health check already in progress.";
return;
}
health_checker_->Start();
@@ -145,8 +157,8 @@
void ActivePassiveOutOfCreditsDetector::OnConnectionHealthCheckerResult(
ConnectionHealthChecker::Result result) {
- SLOG(Cellular, 2) << __func__ << "(Result = "
- << ConnectionHealthChecker::ResultToString(result) << ")";
+ SLOG(this, 2) << __func__ << "(Result = "
+ << ConnectionHealthChecker::ResultToString(result) << ")";
if (result == ConnectionHealthChecker::kResultCongestedTxQueue) {
LOG(WARNING) << "Active probe determined possible out-of-credits "
@@ -159,7 +171,7 @@
metrics()->NotifyCellularOutOfCredits(reason);
ReportOutOfCredits(true);
- SLOG(Cellular, 2) << "Disconnecting due to out-of-credit scenario.";
+ SLOG(this, 2) << "Disconnecting due to out-of-credit scenario.";
Error error;
service()->Disconnect(&error, "out-of-credits");
}
@@ -180,8 +192,8 @@
//
// TODO(thieule): Remove this workaround (crosbug.com/p/18169).
if (out_of_credits()) {
- SLOG(Cellular, 2) << __func__
- << ": Already out-of-credits, skipping check";
+ SLOG(this, 2) << __func__
+ << ": Already out-of-credits, skipping check";
return;
}
base::TimeDelta
@@ -204,7 +216,7 @@
// out-of-credits warning.
// 7. Udev fires device removed event.
// 8. Udev fires new device event.
- SLOG(Cellular, 2) <<
+ SLOG(this, 2) <<
"Skipping out-of-credits detection, too soon since resume.";
ResetDetector();
return;
@@ -232,8 +244,8 @@
return;
if (time_since_connect.InSeconds() <= kOutOfCreditsConnectionDropSeconds) {
if (num_connect_attempts_ < kOutOfCreditsMaxConnectAttempts) {
- SLOG(Cellular, 2) << "Out-Of-Credits detection: Reconnecting "
- << "(retry #" << num_connect_attempts_ << ")";
+ SLOG(this, 2) << "Out-Of-Credits detection: Reconnecting "
+ << "(retry #" << num_connect_attempts_ << ")";
// Prevent autoconnect logic from kicking in while we perform the
// out-of-credits detection.
out_of_credits_detection_in_progress_ = true;
diff --git a/active_passive_out_of_credits_detector.h b/active_passive_out_of_credits_detector.h
index 9b8a29f..4a16a9c 100644
--- a/active_passive_out_of_credits_detector.h
+++ b/active_passive_out_of_credits_detector.h
@@ -6,6 +6,7 @@
#define SHILL_ACTIVE_PASSIVE_OUT_OF_CREDITS_DETECTOR_H_
#include <memory>
+#include <string>
#include <base/time/time.h>
@@ -37,6 +38,10 @@
return traffic_monitor_.get();
}
+ const std::string &GetServiceRpcIdentifier() const {
+ return service_rpc_identifier_;
+ }
+
private:
friend class ActivePassiveOutOfCreditsDetectorTest;
FRIEND_TEST(ActivePassiveOutOfCreditsDetectorTest,
@@ -101,6 +106,9 @@
// Flag indicating whether out-of-credits detection is in progress.
bool out_of_credits_detection_in_progress_;
+ // String to hold service identifier for scoped logging.
+ std::string service_rpc_identifier_;
+
DISALLOW_COPY_AND_ASSIGN(ActivePassiveOutOfCreditsDetector);
};
diff --git a/callback80211_metrics.cc b/callback80211_metrics.cc
index 6eb9a7e..79e650c 100644
--- a/callback80211_metrics.cc
+++ b/callback80211_metrics.cc
@@ -4,14 +4,25 @@
#include "shill/callback80211_metrics.h"
+#include <string>
+
#include "shill/logging.h"
#include "shill/metrics.h"
#include "shill/net/ieee80211.h"
#include "shill/net/netlink_manager.h"
#include "shill/net/nl80211_message.h"
+using std::string;
+
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static string ObjectID(const Callback80211Metrics *c) {
+ return "(callback80211metrics)";
+}
+}
+
Callback80211Metrics::Callback80211Metrics(Metrics *metrics)
: metrics_(metrics) {}
@@ -25,7 +36,7 @@
(reason >= IEEE_80211::kReasonCodeReservedBegin40 &&
reason <= IEEE_80211::kReasonCodeReservedEnd44) ||
reason >= IEEE_80211::kReasonCodeMax) {
- SLOG(WiFi, 1) << "Invalid reason code in disconnect message";
+ SLOG(this, 1) << "Invalid reason code in disconnect message";
reason_enum = IEEE_80211::kReasonCodeInvalid;
} else {
reason_enum = static_cast<IEEE_80211::WiFiReasonCode>(reason);
@@ -51,26 +62,26 @@
// disconnect message.
uint16_t reason = IEEE_80211::kReasonCodeUnspecified;
if (message.command() == DeauthenticateMessage::kCommand) {
- SLOG(WiFi, 3) << "Handling Deauthenticate Message";
+ SLOG(this, 3) << "Handling Deauthenticate Message";
message.Print(3, 3);
// If there's no frame, this is probably an AP-caused disconnect and
// there'll be a disconnect message to tell us about that.
ByteString rawdata;
if (!message.const_attributes()->GetRawAttributeValue(NL80211_ATTR_FRAME,
&rawdata)) {
- SLOG(WiFi, 5) << "No frame in deauthenticate message, ignoring";
+ SLOG(this, 5) << "No frame in deauthenticate message, ignoring";
return;
}
Nl80211Frame frame(rawdata);
reason = frame.reason();
} else if (message.command() == DisconnectMessage::kCommand) {
- SLOG(WiFi, 3) << "Handling Disconnect Message";
+ SLOG(this, 3) << "Handling Disconnect Message";
message.Print(3, 3);
// If there's no reason code, this is probably a STA-caused disconnect and
// there was be a disconnect message to tell us about that.
if (!message.const_attributes()->GetU16AttributeValue(
NL80211_ATTR_REASON_CODE, &reason)) {
- SLOG(WiFi, 5) << "No reason code in disconnect message, ignoring";
+ SLOG(this, 5) << "No reason code in disconnect message, ignoring";
return;
}
} else {
@@ -83,7 +94,7 @@
message.const_attributes()->IsFlagAttributeTrue(
NL80211_ATTR_DISCONNECTED_BY_AP) ? Metrics::kDisconnectedByAp :
Metrics::kDisconnectedNotByAp;
- SLOG(WiFi, 1) << "Notify80211Disconnect by " << (by_whom ? "station" : "AP")
+ SLOG(this, 1) << "Notify80211Disconnect by " << (by_whom ? "station" : "AP")
<< " because:" << reason_enum;
metrics_->Notify80211Disconnect(by_whom, reason_enum);
}
diff --git a/cellular.cc b/cellular.cc
index f05ce53..815ac13 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -53,6 +53,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(Cellular *c) { return c->GetRpcIdentifier(); }
+}
+
// static
const char Cellular::kAllowRoaming[] = "AllowRoaming";
const int64_t Cellular::kDefaultScanningTimeoutMilliseconds = 60000;
@@ -114,8 +119,8 @@
home_provider_info()->AddObserver(mobile_operator_info_observer_.get());
serving_operator_info()->AddObserver(mobile_operator_info_observer_.get());
- SLOG(Cellular, 2) << "Cellular device " << this->link_name()
- << " initialized.";
+ SLOG(this, 2) << "Cellular device " << this->link_name()
+ << " initialized.";
}
Cellular::~Cellular() {
@@ -211,8 +216,8 @@
}
void Cellular::SetState(State state) {
- SLOG(Cellular, 2) << GetStateString(state_) << " -> "
- << GetStateString(state);
+ SLOG(this, 2) << GetStateString(state_) << " -> "
+ << GetStateString(state);
state_ = state;
}
@@ -237,7 +242,7 @@
void Cellular::Start(Error *error,
const EnabledStateChangedCallback &callback) {
DCHECK(error);
- SLOG(Cellular, 2) << __func__ << ": " << GetStateString(state_);
+ SLOG(this, 2) << __func__ << ": " << GetStateString(state_);
// We can only short circuit the start operation if both the cellular state
// is not disabled AND the proxies have been initialized. We have seen
// crashes due to NULL proxies and the state being not disabled.
@@ -253,7 +258,7 @@
void Cellular::Stop(Error *error,
const EnabledStateChangedCallback &callback) {
- SLOG(Cellular, 2) << __func__ << ": " << GetStateString(state_);
+ SLOG(this, 2) << __func__ << ": " << GetStateString(state_);
explicit_disconnect_ = true;
ResultCallback cb = Bind(&Cellular::StopModemCallback,
weak_ptr_factory_.GetWeakPtr(),
@@ -295,7 +300,7 @@
void Cellular::StartModemCallback(const EnabledStateChangedCallback &callback,
const Error &error) {
- SLOG(Cellular, 2) << __func__ << ": " << GetStateString(state_);
+ SLOG(this, 2) << __func__ << ": " << GetStateString(state_);
if (error.IsSuccess() && (state_ == kStateDisabled)) {
SetState(kStateEnabled);
// Registration state updates may have been ignored while the
@@ -307,7 +312,7 @@
void Cellular::StopModemCallback(const EnabledStateChangedCallback &callback,
const Error &error) {
- SLOG(Cellular, 2) << __func__ << ": " << GetStateString(state_);
+ SLOG(this, 2) << __func__ << ": " << GetStateString(state_);
explicit_disconnect_ = false;
// Destroy the cellular service regardless of any errors that occur during
// the stop process since we do not know the state of the modem at this
@@ -325,7 +330,7 @@
void Cellular::InitCapability(Type type) {
// TODO(petkov): Consider moving capability construction into a factory that's
// external to the Cellular class.
- SLOG(Cellular, 2) << __func__ << "(" << type << ")";
+ SLOG(this, 2) << __func__ << "(" << type << ")";
switch (type) {
case kTypeGSM:
capability_.reset(new CellularCapabilityGSM(this,
@@ -371,37 +376,37 @@
void Cellular::RequirePIN(const string &pin, bool require,
Error *error, const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__ << "(" << require << ")";
+ SLOG(this, 2) << __func__ << "(" << require << ")";
capability_->RequirePIN(pin, require, error, callback);
}
void Cellular::EnterPIN(const string &pin,
Error *error, const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
capability_->EnterPIN(pin, error, callback);
}
void Cellular::UnblockPIN(const string &unblock_code,
const string &pin,
Error *error, const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
capability_->UnblockPIN(unblock_code, pin, error, callback);
}
void Cellular::ChangePIN(const string &old_pin, const string &new_pin,
Error *error, const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
capability_->ChangePIN(old_pin, new_pin, error, callback);
}
void Cellular::Reset(Error *error, const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
capability_->Reset(error, callback);
}
void Cellular::SetCarrier(const string &carrier,
Error *error, const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__ << "(" << carrier << ")";
+ SLOG(this, 2) << __func__ << "(" << carrier << ")";
capability_->SetCarrier(carrier, error, callback);
}
@@ -482,7 +487,7 @@
}
void Cellular::OnAfterResume() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (enabled_persistent()) {
LOG(INFO) << "Restarting modem after resume.";
@@ -516,7 +521,7 @@
void Cellular::Scan(ScanType /*scan_type*/, Error *error,
const string &/*reason*/) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(error);
if (proposed_scan_in_progress_) {
Error::PopulateAndLog(error, Error::kInProgress, "Already scanning");
@@ -552,8 +557,8 @@
}
void Cellular::HandleNewRegistrationState() {
- SLOG(Cellular, 2) << __func__
- << ": (new state " << GetStateString(state_) << ")";
+ SLOG(this, 2) << __func__
+ << ": (new state " << GetStateString(state_) << ")";
if (!capability_->IsRegistered()) {
if (!explicit_disconnect_ &&
(state_ == kStateLinked || state_ == kStateConnected) &&
@@ -590,14 +595,14 @@
}
void Cellular::HandleNewSignalQuality(uint32_t strength) {
- SLOG(Cellular, 2) << "Signal strength: " << strength;
+ SLOG(this, 2) << "Signal strength: " << strength;
if (service_) {
service_->SetStrength(strength);
}
}
void Cellular::CreateService() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!service_.get());
service_ = new CellularService(modem_info_, this);
capability_->OnServiceCreated();
@@ -650,7 +655,7 @@
}
void Cellular::DestroyService() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
DropConnection();
if (service_) {
LOG(INFO) << "Deregistering cellular service " << service_->unique_name()
@@ -661,7 +666,7 @@
}
void Cellular::Connect(Error *error) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (state_ == kStateConnected || state_ == kStateLinked) {
Error::PopulateAndLog(error, Error::kAlreadyConnected,
"Already connected; connection request ignored.");
@@ -695,7 +700,7 @@
// Note that there's no ResultCallback argument to this,
// since Connect() isn't yet passed one.
void Cellular::OnConnectReply(const Error &error) {
- SLOG(Cellular, 2) << __func__ << "(" << error << ")";
+ SLOG(this, 2) << __func__ << "(" << error << ")";
if (error.IsSuccess()) {
metrics()->NotifyDeviceConnectFinished(interface_index());
OnConnected();
@@ -722,9 +727,9 @@
}
void Cellular::OnConnected() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (state_ == kStateConnected || state_ == kStateLinked) {
- SLOG(Cellular, 2) << "Already connected";
+ SLOG(this, 2) << "Already connected";
return;
}
SetState(kStateConnected);
@@ -746,7 +751,7 @@
}
void Cellular::Disconnect(Error *error, const char *reason) {
- SLOG(Cellular, 2) << __func__ << ": " << reason;
+ SLOG(this, 2) << __func__ << ": " << reason;
if (state_ != kStateConnected && state_ != kStateLinked) {
Error::PopulateAndLog(
error, Error::kNotConnected, "Not connected; request ignored.");
@@ -760,7 +765,7 @@
}
void Cellular::OnDisconnectReply(const Error &error) {
- SLOG(Cellular, 2) << __func__ << "(" << error << ")";
+ SLOG(this, 2) << __func__ << "(" << error << ")";
explicit_disconnect_ = false;
if (error.IsSuccess()) {
OnDisconnected();
@@ -771,7 +776,7 @@
}
void Cellular::OnDisconnected() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!DisconnectCleanup()) {
LOG(WARNING) << "Disconnect occurred while in state "
<< GetStateString(state_);
@@ -779,7 +784,7 @@
}
void Cellular::OnDisconnectFailed() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
// If the modem is in the disconnecting state, then
// the disconnect should eventually succeed, so do
// nothing.
@@ -807,7 +812,7 @@
}
void Cellular::EstablishLink() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK_EQ(kStateConnected, state_);
CellularBearer *bearer = capability_->GetActiveBearer();
@@ -846,7 +851,7 @@
// IPv6 support on cellular devices.
CellularBearer *bearer = capability_->GetActiveBearer();
if (bearer && bearer->ipv4_config_method() == IPConfig::kMethodStatic) {
- SLOG(Cellular, 2) << "Assign static IP configuration from bearer.";
+ SLOG(this, 2) << "Assign static IP configuration from bearer.";
SelectService(service_);
SetServiceState(Service::kStateConfiguring);
AssignIPConfig(*bearer->ipv4_config_properties());
@@ -854,7 +859,7 @@
}
if (AcquireIPConfig()) {
- SLOG(Cellular, 2) << "Start DHCP to acquire IP configuration.";
+ SLOG(this, 2) << "Start DHCP to acquire IP configuration.";
SelectService(service_);
SetServiceState(Service::kStateConfiguring);
return;
@@ -881,7 +886,7 @@
}
string Cellular::CreateDefaultFriendlyServiceName() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
return base::StringPrintf("%s_%u",
kGenericServiceNamePrefix,
friendly_service_name_id_++);
@@ -893,10 +898,10 @@
void Cellular::OnModemStateChanged(ModemState new_state) {
ModemState old_state = modem_state_;
- SLOG(Cellular, 2) << __func__ << ": " << GetModemStateString(old_state)
- << " -> " << GetModemStateString(new_state);
+ SLOG(this, 2) << __func__ << ": " << GetModemStateString(old_state)
+ << " -> " << GetModemStateString(new_state);
if (old_state == new_state) {
- SLOG(Cellular, 2) << "The new state matches the old state. Nothing to do.";
+ SLOG(this, 2) << "The new state matches the old state. Nothing to do.";
return;
}
set_modem_state(new_state);
@@ -936,8 +941,8 @@
}
bool Cellular::SetAllowRoaming(const bool &value, Error */*error*/) {
- SLOG(Cellular, 2) << __func__
- << "(" << allow_roaming_ << "->" << value << ")";
+ SLOG(this, 2) << __func__
+ << "(" << allow_roaming_ << "->" << value << ")";
if (allow_roaming_ == value) {
return false;
}
@@ -957,7 +962,7 @@
}
void Cellular::StartTermination() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
OnBeforeSuspend(Bind(&Cellular::OnTerminationCompleted,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -990,7 +995,7 @@
}
void Cellular::StartPPP(const string &serial_device) {
- SLOG(PPP, 2) << __func__ << " on " << serial_device;
+ SLOG(PPP, this, 2) << __func__ << " on " << serial_device;
// Detach any SelectedService from this device. It will be grafted onto
// the PPPDevice after PPP is up (in Cellular::Notify).
//
@@ -1037,7 +1042,7 @@
}
void Cellular::StopPPP() {
- SLOG(PPP, 2) << __func__;
+ SLOG(PPP, this, 2) << __func__;
if (!ppp_task_) {
return;
}
@@ -1048,7 +1053,7 @@
// called by |ppp_task_|
void Cellular::GetLogin(string *user, string *password) {
- SLOG(PPP, 2) << __func__;
+ SLOG(PPP, this, 2) << __func__;
if (!service()) {
LOG(ERROR) << __func__ << " with no service ";
return;
@@ -1062,7 +1067,7 @@
// Called by |ppp_task_|.
void Cellular::Notify(const string &reason,
const map<string, string> &dict) {
- SLOG(PPP, 2) << __func__ << " " << reason << " on " << link_name();
+ SLOG(PPP, this, 2) << __func__ << " " << reason << " on " << link_name();
if (reason == kPPPReasonAuthenticating) {
OnPPPAuthenticating();
@@ -1078,17 +1083,17 @@
}
void Cellular::OnPPPAuthenticated() {
- SLOG(PPP, 2) << __func__;
+ SLOG(PPP, this, 2) << __func__;
is_ppp_authenticating_ = false;
}
void Cellular::OnPPPAuthenticating() {
- SLOG(PPP, 2) << __func__;
+ SLOG(PPP, this, 2) << __func__;
is_ppp_authenticating_ = true;
}
void Cellular::OnPPPConnected(const map<string, string> ¶ms) {
- SLOG(PPP, 2) << __func__;
+ SLOG(PPP, this, 2) << __func__;
string interface_name = PPPDevice::GetInterfaceName(params);
DeviceInfo *device_info = modem_info_->manager()->device_info();
int interface_index = device_info->GetIndex(interface_name);
@@ -1123,7 +1128,7 @@
}
void Cellular::OnPPPDisconnected() {
- SLOG(PPP, 2) << __func__;
+ SLOG(PPP, this, 2) << __func__;
// DestroyLater, rather than while on stack.
ppp_task_.release()->DestroyLater(modem_info_->dispatcher());
if (is_ppp_authenticating_) {
@@ -1237,9 +1242,9 @@
adaptor()->EmitBoolChanged(kSupportNetworkScanProperty,
scanning_supported_);
else
- SLOG(Cellular, 2) << "Could not emit signal for property |"
- << kSupportNetworkScanProperty
- << "| change. DBus adaptor is NULL!";
+ SLOG(this, 2) << "Could not emit signal for property |"
+ << kSupportNetworkScanProperty
+ << "| change. DBus adaptor is NULL!";
}
void Cellular::set_esn(const string &esn) {
@@ -1339,13 +1344,13 @@
// Every time it is set to |true|, it will remain |true| up to a maximum of
// |kScanningTimeout| time, after which it will be reset to |false|.
if (!scanning_ && !scanning_timeout_callback_.IsCancelled()) {
- SLOG(Cellular, 2) << "Scanning set to false. "
- << "Cancelling outstanding timeout.";
+ SLOG(this, 2) << "Scanning set to false. "
+ << "Cancelling outstanding timeout.";
scanning_timeout_callback_.Cancel();
} else {
CHECK(scanning_timeout_callback_.IsCancelled());
- SLOG(Cellular, 2) << "Scanning set to true. "
- << "Starting timeout to reset to false.";
+ SLOG(this, 2) << "Scanning set to true. "
+ << "Starting timeout to reset to false.";
scanning_timeout_callback_.Reset(Bind(&Cellular::set_scanning,
weak_ptr_factory_.GetWeakPtr(),
false));
@@ -1404,9 +1409,9 @@
if (adaptor())
adaptor()->EmitStringmapsChanged(kCellularApnListProperty, apn_list_);
else
- SLOG(Cellular, 2) << "Could not emit signal for property |"
- << kCellularApnListProperty
- << "| change. DBus adaptor is NULL!";
+ SLOG(this, 2) << "Could not emit signal for property |"
+ << kCellularApnListProperty
+ << "| change. DBus adaptor is NULL!";
}
void Cellular::set_sim_identifier(const string &sim_identifier) {
@@ -1443,7 +1448,7 @@
}
void Cellular::UpdateHomeProvider(const MobileOperatorInfo *operator_info) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
Stringmap home_provider;
if (!operator_info->sid().empty()) {
@@ -1499,7 +1504,7 @@
void Cellular::UpdateServingOperator(
const MobileOperatorInfo *operator_info,
const MobileOperatorInfo *home_provider_info) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (!service()) {
return;
}
@@ -1558,7 +1563,7 @@
Cellular::MobileOperatorInfoObserver::~MobileOperatorInfoObserver() {}
void Cellular::MobileOperatorInfoObserver::OnOperatorChanged() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(cellular_, 3) << __func__;
// Give the capabilities a chance to hook in and update their state.
// Some tests set |capability_| to nullptr avoid having to expect the full
@@ -1580,7 +1585,7 @@
if (home_provider_known) {
cellular_->UpdateHomeProvider(home_provider_info);
} else if (serving_operator_known) {
- SLOG(Cellular, 2) << "Serving provider proxying in for home provider.";
+ SLOG(cellular_, 2) << "Serving provider proxying in for home provider.";
cellular_->UpdateHomeProvider(serving_operator_info);
}
diff --git a/cellular_bearer.cc b/cellular_bearer.cc
index 62960fe..84ffaac 100644
--- a/cellular_bearer.cc
+++ b/cellular_bearer.cc
@@ -18,6 +18,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(const CellularBearer *c) { return "(cellular_bearer)"; }
+}
+
namespace {
const char kPropertyAddress[] = "address";
@@ -58,8 +63,8 @@
CellularBearer::~CellularBearer() {}
bool CellularBearer::Init() {
- SLOG(Cellular, 3) << __func__ << ": path='" << dbus_path_
- << "', service='" << dbus_service_ << "'";
+ SLOG(this, 3) << __func__ << ": path='" << dbus_path_
+ << "', service='" << dbus_service_ << "'";
dbus_properties_proxy_.reset(
proxy_factory_->CreateDBusPropertiesProxy(dbus_path_, dbus_service_));
@@ -87,8 +92,8 @@
uint32_t method;
if (!DBusProperties::GetUint32(properties, kPropertyMethod, &method)) {
- SLOG(Cellular, 2) << "Bearer '" << dbus_path_
- << "' does not specify an IP configuration method.";
+ SLOG(this, 2) << "Bearer '" << dbus_path_
+ << "' does not specify an IP configuration method.";
method = MM_BEARER_IP_METHOD_UNKNOWN;
}
*ipconfig_method = ConvertMMBearerIPConfigMethod(method);
@@ -100,8 +105,8 @@
string address, gateway;
if (!DBusProperties::GetString(properties, kPropertyAddress, &address) ||
!DBusProperties::GetString(properties, kPropertyGateway, &gateway)) {
- SLOG(Cellular, 2) << "Bearer '" << dbus_path_
- << "' static IP configuration does not specify valid "
+ SLOG(this, 2) << "Bearer '" << dbus_path_
+ << "' static IP configuration does not specify valid "
"address/gateway information.";
*ipconfig_method = IPConfig::kMethodUnknown;
return;
@@ -161,8 +166,8 @@
const string &interface,
const DBusPropertiesMap &changed_properties,
const vector<string> &/*invalidated_properties*/) {
- SLOG(Cellular, 3) << __func__ << ": path=" << dbus_path_
- << ", interface=" << interface;
+ SLOG(this, 3) << __func__ << ": path=" << dbus_path_
+ << ", interface=" << interface;
if (interface != MM_DBUS_INTERFACE_BEARER)
return;
diff --git a/cellular_capability.cc b/cellular_capability.cc
index 034af65..e64f2fa 100644
--- a/cellular_capability.cc
+++ b/cellular_capability.cc
@@ -17,6 +17,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularCapability *c) {
+ return c->cellular()->GetRpcIdentifier();
+}
+}
+
const char CellularCapability::kModemPropertyIMSI[] = "imsi";
const char CellularCapability::kModemPropertyState[] = "State";
// All timeout values are in milliseconds
@@ -124,14 +131,14 @@
}
void CellularCapability::OnOperatorChanged() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (cellular()->service()) {
UpdateServiceOLP();
}
}
void CellularCapability::UpdateServiceOLP() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
}
} // namespace shill
diff --git a/cellular_capability_cdma.cc b/cellular_capability_cdma.cc
index a7f01e5..bbcb8d3 100644
--- a/cellular_capability_cdma.cc
+++ b/cellular_capability_cdma.cc
@@ -23,6 +23,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularCapabilityCDMA *c) {
+ return c->cellular()->GetRpcIdentifier();
+}
+}
+
// static
const char CellularCapabilityCDMA::kPhoneNumber[] = "#777";
@@ -35,7 +42,7 @@
activation_state_(MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED),
registration_state_evdo_(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN),
registration_state_1x_(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) {
- SLOG(Cellular, 2) << "Cellular capability constructed: CDMA";
+ SLOG(this, 2) << "Cellular capability constructed: CDMA";
}
CellularCapabilityCDMA::~CellularCapabilityCDMA() {}
@@ -61,7 +68,7 @@
void CellularCapabilityCDMA::StartModem(Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
InitProxies();
CellularTaskList *tasks = new CellularTaskList();
@@ -98,7 +105,7 @@
void CellularCapabilityCDMA::OnServiceCreated() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
cellular()->service()->SetUsageURL(usage_url_);
cellular()->service()->SetActivationType(
CellularService::kActivationTypeOTASP);
@@ -119,7 +126,7 @@
}
void CellularCapabilityCDMA::UpdateServiceOLP() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// All OLP changes are routed up to the Home Provider.
if (!cellular()->home_provider_info()->IsMobileNetworkOperatorKnown()) {
return;
@@ -132,7 +139,7 @@
}
if (olp_list.size() > 1) {
- SLOG(Cellular, 1) << "Found multiple online portals. Choosing the first.";
+ SLOG(this, 1) << "Found multiple online portals. Choosing the first.";
}
cellular()->service()->SetOLP(olp_list[0].url,
olp_list[0].method,
@@ -148,7 +155,7 @@
void CellularCapabilityCDMA::Activate(const string &carrier,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__ << "(" << carrier << ")";
+ SLOG(this, 2) << __func__ << "(" << carrier << ")";
// We're going to trigger something which leads to an activation.
activation_starting_ = true;
if (cellular()->state() == Cellular::kStateEnabled ||
@@ -172,7 +179,7 @@
}
void CellularCapabilityCDMA::HandleNewActivationState(uint32_t error) {
- SLOG(Cellular, 2) << __func__ << "(" << error << ")";
+ SLOG(this, 2) << __func__ << "(" << error << ")";
if (!cellular()->service().get()) {
LOG(ERROR) << "In " << __func__ << "(): service is null.";
return;
@@ -243,17 +250,17 @@
}
void CellularCapabilityCDMA::GetMEID(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (cellular()->meid().empty()) {
// TODO(petkov): Switch to asynchronous calls (crbug.com/200687).
cellular()->set_meid(proxy_->MEID());
- SLOG(Cellular, 2) << "MEID: " << cellular()->meid();
+ SLOG(this, 2) << "MEID: " << cellular()->meid();
}
callback.Run(Error());
}
void CellularCapabilityCDMA::GetProperties(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
// No properties.
callback.Run(Error());
}
@@ -303,7 +310,7 @@
}
void CellularCapabilityCDMA::GetSignalQuality() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
SignalQualityCallback callback =
Bind(&CellularCapabilityCDMA::OnGetSignalQualityReply,
weak_ptr_factory_.GetWeakPtr());
@@ -311,7 +318,7 @@
}
void CellularCapabilityCDMA::GetRegistrationState() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
RegistrationStateCallback callback =
Bind(&CellularCapabilityCDMA::OnGetRegistrationStateReply,
weak_ptr_factory_.GetWeakPtr());
@@ -337,7 +344,7 @@
void CellularCapabilityCDMA::OnGetRegistrationStateReply(
uint32_t state_1x, uint32_t state_evdo, const Error &error) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (error.IsSuccess())
OnRegistrationStateChangedSignal(state_1x, state_evdo);
}
@@ -352,7 +359,7 @@
uint32_t activation_state,
uint32_t activation_error,
const DBusPropertiesMap &status_changes) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
string prop_value;
if (DBusProperties::GetString(status_changes, "mdn", &prop_value))
@@ -367,7 +374,7 @@
void CellularCapabilityCDMA::OnRegistrationStateChangedSignal(
uint32_t state_1x, uint32_t state_evdo) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
registration_state_1x_ = state_1x;
registration_state_evdo_ = state_evdo;
cellular()->HandleNewRegistrationState();
diff --git a/cellular_capability_classic.cc b/cellular_capability_classic.cc
index 61372e0..300beee 100644
--- a/cellular_capability_classic.cc
+++ b/cellular_capability_classic.cc
@@ -21,6 +21,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularCapabilityClassic *c) {
+ return c->cellular()->GetRpcIdentifier();
+}
+}
+
const char CellularCapabilityClassic::kConnectPropertyApn[] = "apn";
const char CellularCapabilityClassic::kConnectPropertyApnUsername[] =
"username";
@@ -75,7 +82,7 @@
CellularCapabilityClassic::~CellularCapabilityClassic() {}
void CellularCapabilityClassic::InitProxies() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
proxy_.reset(proxy_factory()->CreateModemProxy(
cellular()->dbus_path(), cellular()->dbus_owner()));
simple_proxy_.reset(proxy_factory()->CreateModemSimpleProxy(
@@ -86,7 +93,7 @@
}
void CellularCapabilityClassic::ReleaseProxies() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
proxy_.reset();
simple_proxy_.reset();
gobi_proxy_.reset();
@@ -121,7 +128,7 @@
void CellularCapabilityClassic::RunNextStep(CellularTaskList *tasks) {
CHECK(!tasks->empty());
- SLOG(Cellular, 2) << __func__ << ": " << tasks->size() << " remaining tasks";
+ SLOG(this, 2) << __func__ << ": " << tasks->size() << " remaining tasks";
Closure task = (*tasks)[0];
tasks->erase(tasks->begin());
cellular()->dispatcher()->PostTask(task);
@@ -143,7 +150,7 @@
// always called from an async context
void CellularCapabilityClassic::EnableModem(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
Error error;
modem_info()->metrics()->NotifyDeviceEnableStarted(
@@ -155,7 +162,7 @@
// always called from an async context
void CellularCapabilityClassic::DisableModem(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
Error error;
modem_info()->metrics()->NotifyDeviceDisableStarted(
@@ -167,7 +174,7 @@
// always called from an async context
void CellularCapabilityClassic::GetModemStatus(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
DBusPropertyMapCallback cb = Bind(
&CellularCapabilityClassic::OnGetModemStatusReply,
@@ -180,7 +187,7 @@
// always called from an async context
void CellularCapabilityClassic::GetModemInfo(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
ModemInfoCallback cb = Bind(&CellularCapabilityClassic::OnGetModemInfoReply,
weak_ptr_factory_.GetWeakPtr(), callback);
@@ -192,7 +199,7 @@
void CellularCapabilityClassic::StopModem(Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CellularTaskList *tasks = new CellularTaskList();
ResultCallback cb =
@@ -219,13 +226,13 @@
void CellularCapabilityClassic::Connect(const DBusPropertiesMap &properties,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
simple_proxy_->Connect(properties, error, callback, kTimeoutConnect);
}
void CellularCapabilityClassic::Disconnect(Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (proxy_.get())
proxy_->Disconnect(error, callback, kTimeoutDisconnect);
else
@@ -249,7 +256,7 @@
const std::string &interface,
const DBusPropertiesMap &changed_properties,
const std::vector<std::string> &invalidated_properties) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
bool enabled;
// This solves a bootstrapping problem: If the modem is not yet
// enabled, there are no proxy objects associated with the capability
@@ -265,7 +272,7 @@
// All other state changes are handled from OnModemStateChangedSignal.
if (DBusProperties::GetBool(changed_properties,
kModemPropertyEnabled, &enabled)) {
- SLOG(Cellular, 2) << "Property \"Enabled\" changed: " << enabled;
+ SLOG(this, 2) << "Property \"Enabled\" changed: " << enabled;
Cellular::ModemState prev_modem_state = cellular()->modem_state();
if (!Cellular::IsEnabledModemState(prev_modem_state)) {
cellular()->OnModemStateChanged(
@@ -280,8 +287,8 @@
const DBusPropertiesMap &props,
const Error &error) {
string prop_value;
- SLOG(Cellular, 2) << __func__ << " " << props.size() << " props. error "
- << error;
+ SLOG(this, 2) << __func__ << " " << props.size() << " props. error "
+ << error;
if (error.IsSuccess()) {
if (DBusProperties::GetString(props, "carrier", &prop_value)) {
cellular()->set_carrier(prop_value);
@@ -319,28 +326,28 @@
void CellularCapabilityClassic::UpdateStatus(
const DBusPropertiesMap &properties) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
}
void CellularCapabilityClassic::OnGetModemInfoReply(
const ResultCallback &callback,
const ModemHardwareInfo &info,
const Error &error) {
- SLOG(Cellular, 2) << __func__ << "(" << error << ")";
+ SLOG(this, 2) << __func__ << "(" << error << ")";
if (error.IsSuccess()) {
cellular()->set_manufacturer(info._1);
cellular()->set_model_id(info._2);
cellular()->set_hardware_revision(info._3);
- SLOG(Cellular, 2) << __func__ << ": " << info._1 << ", " << info._2 << ", "
- << info._3;
+ SLOG(this, 2) << __func__ << ": " << info._1 << ", " << info._2 << ", "
+ << info._3;
}
callback.Run(error);
}
void CellularCapabilityClassic::OnModemStateChangedSignal(
uint32_t old_state, uint32_t new_state, uint32_t reason) {
- SLOG(Cellular, 2) << __func__ << "(" << old_state << ", " << new_state << ", "
- << reason << ")";
+ SLOG(this, 2) << __func__ << "(" << old_state << ", " << new_state << ", "
+ << reason << ")";
cellular()->OnModemStateChanged(ConvertClassicToModemState(new_state));
}
diff --git a/cellular_capability_gsm.cc b/cellular_capability_gsm.cc
index bb18ff0..cbee8f4 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -27,6 +27,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularCapabilityGSM *c) {
+ return c->cellular()->GetRpcIdentifier();
+}
+}
+
// static
const char CellularCapabilityGSM::kNetworkPropertyAccessTechnology[] =
"access-tech";
@@ -59,7 +66,7 @@
home_provider_info_(nullptr),
get_imsi_retries_(0),
get_imsi_retry_delay_milliseconds_(kGetIMSIRetryDelayMilliseconds) {
- SLOG(Cellular, 2) << "Cellular capability constructed: GSM";
+ SLOG(this, 2) << "Cellular capability constructed: GSM";
mobile_operator_info_->Init();
HelpRegisterConstDerivedKeyValueStore(
kSIMLockStatusProperty, &CellularCapabilityGSM::SimLockStatusToProperty);
@@ -204,7 +211,7 @@
}
void CellularCapabilityGSM::ReleaseProxies() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CellularCapabilityClassic::ReleaseProxies();
card_proxy_.reset();
network_proxy_.reset();
@@ -261,7 +268,7 @@
// Leave the APN at the front of the list, so that it can be recorded
// if the connect attempt succeeds.
Stringmap apn_info = apn_try_list_.front();
- SLOG(Cellular, 2) << __func__ << ": Using APN " << apn_info[kApnProperty];
+ SLOG(this, 2) << __func__ << ": Using APN " << apn_info[kApnProperty];
(*properties)[kConnectPropertyApn].writer().append_string(
apn_info[kApnProperty].c_str());
if (ContainsKey(apn_info, kApnUsernameProperty))
@@ -276,7 +283,7 @@
void CellularCapabilityGSM::Connect(const DBusPropertiesMap &properties,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
ResultCallback cb = Bind(&CellularCapabilityGSM::OnConnectReply,
weak_ptr_factory_.GetWeakPtr(),
callback);
@@ -298,8 +305,8 @@
// with some modems in some cases.
if (error.type() == Error::kInvalidApn && !apn_try_list_.empty()) {
apn_try_list_.pop_front();
- SLOG(Cellular, 2) << "Connect failed with invalid APN, "
- << apn_try_list_.size() << " remaining APNs to try";
+ SLOG(this, 2) << "Connect failed with invalid APN, "
+ << apn_try_list_.size() << " remaining APNs to try";
DBusPropertiesMap props;
FillConnectPropertyMap(&props);
Error error;
@@ -320,7 +327,7 @@
// always called from an async context
void CellularCapabilityGSM::GetIMEI(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
Error error;
if (cellular()->imei().empty()) {
@@ -330,14 +337,14 @@
if (error.IsFailure())
callback.Run(error);
} else {
- SLOG(Cellular, 2) << "Already have IMEI " << cellular()->imei();
+ SLOG(this, 2) << "Already have IMEI " << cellular()->imei();
callback.Run(error);
}
}
// always called from an async context
void CellularCapabilityGSM::GetIMSI(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
Error error;
if (cellular()->imsi().empty()) {
@@ -350,14 +357,14 @@
callback.Run(error);
}
} else {
- SLOG(Cellular, 2) << "Already have IMSI " << cellular()->imsi();
+ SLOG(this, 2) << "Already have IMSI " << cellular()->imsi();
callback.Run(error);
}
}
// always called from an async context
void CellularCapabilityGSM::GetSPN(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
Error error;
if (spn_.empty()) {
@@ -368,14 +375,14 @@
if (error.IsFailure())
callback.Run(error);
} else {
- SLOG(Cellular, 2) << "Already have SPN " << spn_;
+ SLOG(this, 2) << "Already have SPN " << spn_;
callback.Run(error);
}
}
// always called from an async context
void CellularCapabilityGSM::GetMSISDN(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!callback.is_null());
Error error;
string mdn = cellular()->mdn();
@@ -387,13 +394,13 @@
if (error.IsFailure())
callback.Run(error);
} else {
- SLOG(Cellular, 2) << "Already have MSISDN " << mdn;
+ SLOG(this, 2) << "Already have MSISDN " << mdn;
callback.Run(error);
}
}
void CellularCapabilityGSM::GetSignalQuality() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
SignalQualityCallback callback =
Bind(&CellularCapabilityGSM::OnGetSignalQualityReply,
weak_ptr_factory_.GetWeakPtr());
@@ -401,7 +408,7 @@
}
void CellularCapabilityGSM::GetRegistrationState() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
RegistrationInfoCallback callback =
Bind(&CellularCapabilityGSM::OnGetRegistrationInfoReply,
weak_ptr_factory_.GetWeakPtr());
@@ -409,25 +416,25 @@
}
void CellularCapabilityGSM::GetProperties(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
// TODO(petkov): Switch to asynchronous calls (crbug.com/200687).
uint32_t tech = network_proxy_->AccessTechnology();
SetAccessTechnology(tech);
- SLOG(Cellular, 2) << "GSM AccessTechnology: " << tech;
+ SLOG(this, 2) << "GSM AccessTechnology: " << tech;
// TODO(petkov): Switch to asynchronous calls (crbug.com/200687).
uint32_t locks = card_proxy_->EnabledFacilityLocks();
sim_lock_status_.enabled = locks & MM_MODEM_GSM_FACILITY_SIM;
- SLOG(Cellular, 2) << "GSM EnabledFacilityLocks: " << locks;
+ SLOG(this, 2) << "GSM EnabledFacilityLocks: " << locks;
callback.Run(Error());
}
// always called from an async context
void CellularCapabilityGSM::Register(const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__ << " \"" << cellular()->selected_network()
- << "\"";
+ SLOG(this, 2) << __func__ << " \"" << cellular()->selected_network()
+ << "\"";
CHECK(!callback.is_null());
Error error;
ResultCallback cb = Bind(&CellularCapabilityGSM::OnRegisterReply,
@@ -442,7 +449,7 @@
const string &network_id,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 2) << __func__ << "(" << network_id << ")";
+ SLOG(this, 2) << __func__ << "(" << network_id << ")";
CHECK(error);
desired_network_ = network_id;
ResultCallback cb = Bind(&CellularCapabilityGSM::OnRegisterReply,
@@ -452,7 +459,7 @@
void CellularCapabilityGSM::OnRegisterReply(const ResultCallback &callback,
const Error &error) {
- SLOG(Cellular, 2) << __func__ << "(" << error << ")";
+ SLOG(this, 2) << __func__ << "(" << error << ")";
if (error.IsSuccess()) {
cellular()->set_selected_network(desired_network_);
@@ -554,8 +561,8 @@
"HSUPA",
kNetworkTechnologyHspa,
};
- SLOG(Cellular, 2) << "Network property: " << it->first << " = "
- << it->second;
+ SLOG(this, 2) << "Network property: " << it->first << " = "
+ << it->second;
if (it->first == kNetworkPropertyStatus) {
int status = 0;
if (base::StringToInt(it->second, &status) &&
@@ -691,9 +698,9 @@
void CellularCapabilityGSM::OnRegistrationInfoSignal(
uint32_t status, const string &operator_code, const string &operator_name) {
- SLOG(Cellular, 2) << __func__ << ": regstate=" << status
- << ", opercode=" << operator_code
- << ", opername=" << operator_name;
+ SLOG(this, 2) << __func__ << ": regstate=" << status
+ << ", opercode=" << operator_code
+ << ", opername=" << operator_name;
registration_state_ = status;
cellular()->serving_operator_info()->UpdateMCCMNC(operator_code);
cellular()->serving_operator_info()->UpdateOperatorName(operator_name);
@@ -721,10 +728,10 @@
const string &imei,
const Error &error) {
if (error.IsSuccess()) {
- SLOG(Cellular, 2) << "IMEI: " << imei;
+ SLOG(this, 2) << "IMEI: " << imei;
cellular()->set_imei(imei);
} else {
- SLOG(Cellular, 2) << "GetIMEI failed - " << error;
+ SLOG(this, 2) << "GetIMEI failed - " << error;
}
callback.Run(error);
}
@@ -733,7 +740,7 @@
const string &imsi,
const Error &error) {
if (error.IsSuccess()) {
- SLOG(Cellular, 2) << "IMSI: " << imsi;
+ SLOG(this, 2) << "IMSI: " << imsi;
cellular()->set_imsi(imsi);
cellular()->set_sim_present(true);
cellular()->home_provider_info()->UpdateIMSI(imsi);
@@ -742,13 +749,13 @@
cellular()->serving_operator_info()->UpdateIMSI(imsi);
callback.Run(error);
} else if (!sim_lock_status_.lock_type.empty()) {
- SLOG(Cellular, 2) << "GetIMSI failed - SIM lock in place.";
+ SLOG(this, 2) << "GetIMSI failed - SIM lock in place.";
cellular()->set_sim_present(true);
callback.Run(error);
} else {
cellular()->set_sim_present(false);
if (get_imsi_retries_++ < kGetIMSIRetryLimit) {
- SLOG(Cellular, 2) << "GetIMSI failed - " << error << ". Retrying";
+ SLOG(this, 2) << "GetIMSI failed - " << error << ". Retrying";
base::Callback<void(void)> retry_get_imsi_cb =
Bind(&CellularCapabilityGSM::GetIMSI,
weak_ptr_factory_.GetWeakPtr(), callback);
@@ -767,11 +774,11 @@
const string &spn,
const Error &error) {
if (error.IsSuccess()) {
- SLOG(Cellular, 2) << "SPN: " << spn;
+ SLOG(this, 2) << "SPN: " << spn;
spn_ = spn;
cellular()->home_provider_info()->UpdateOperatorName(spn);
} else {
- SLOG(Cellular, 2) << "GetSPN failed - " << error;
+ SLOG(this, 2) << "GetSPN failed - " << error;
}
callback.Run(error);
}
@@ -780,10 +787,10 @@
const string &msisdn,
const Error &error) {
if (error.IsSuccess()) {
- SLOG(Cellular, 2) << "MSISDN: " << msisdn;
+ SLOG(this, 2) << "MSISDN: " << msisdn;
cellular()->set_mdn(msisdn);
} else {
- SLOG(Cellular, 2) << "GetMSISDN failed - " << error;
+ SLOG(this, 2) << "GetMSISDN failed - " << error;
}
callback.Run(error);
}
diff --git a/cellular_capability_universal.cc b/cellular_capability_universal.cc
index d5b861c..cda10d9 100644
--- a/cellular_capability_universal.cc
+++ b/cellular_capability_universal.cc
@@ -36,6 +36,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularCapabilityUniversal *c) {
+ return c->cellular()->GetRpcIdentifier();
+}
+}
+
// static
const char CellularCapabilityUniversal::kConnectPin[] = "pin";
const char CellularCapabilityUniversal::kConnectOperatorId[] = "operator-id";
@@ -139,7 +146,7 @@
reset_done_(false),
registration_dropped_update_timeout_milliseconds_(
kRegistrationDroppedUpdateTimeoutMilliseconds) {
- SLOG(Cellular, 2) << "Cellular capability constructed: Universal";
+ SLOG(this, 2) << "Cellular capability constructed: Universal";
mobile_operator_info_->Init();
HelpRegisterConstDerivedKeyValueStore(
kSIMLockStatusProperty,
@@ -200,7 +207,7 @@
void CellularCapabilityUniversal::StartModem(Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
InitProxies();
deferred_enable_modem_callback_.Reset();
EnableModem(true, error, callback);
@@ -209,7 +216,7 @@
void CellularCapabilityUniversal::EnableModem(bool deferrable,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__ << "(deferrable=" << deferrable << ")";
+ SLOG(this, 3) << __func__ << "(deferrable=" << deferrable << ")";
CHECK(!callback.is_null());
Error local_error(Error::kOperationInitiated);
modem_info()->metrics()->NotifyDeviceEnableStarted(
@@ -221,7 +228,7 @@
weak_ptr_factory_.GetWeakPtr(), deferrable, callback),
kTimeoutEnable);
if (local_error.IsFailure()) {
- SLOG(Cellular, 2) << __func__ << "Call to modem_proxy_->Enable() failed";
+ SLOG(this, 2) << __func__ << "Call to modem_proxy_->Enable() failed";
}
if (error) {
error->CopyFrom(local_error);
@@ -230,8 +237,8 @@
void CellularCapabilityUniversal::EnableModemCompleted(
bool deferrable, const ResultCallback &callback, const Error &error) {
- SLOG(Cellular, 3) << __func__ << "(deferrable=" << deferrable
- << ", error=" << error << ")";
+ SLOG(this, 3) << __func__ << "(deferrable=" << deferrable
+ << ", error=" << error << ")";
// If the enable operation failed with Error::kWrongState, the modem is not
// in the expected state (i.e. disabled). If |deferrable| indicates that the
@@ -251,7 +258,7 @@
}
if (deferred_enable_modem_callback_.is_null()) {
- SLOG(Cellular, 2) << "Defer enable operation.";
+ SLOG(this, 2) << "Defer enable operation.";
// The Enable operation to be deferred should not be further deferrable.
deferred_enable_modem_callback_ =
Bind(&CellularCapabilityUniversal::EnableModem,
@@ -283,7 +290,7 @@
// the service will be destroyed anyway.
if (!registration_dropped_update_callback_.IsCancelled()) {
registration_dropped_update_callback_.Cancel();
- SLOG(Cellular, 2) << __func__ << " Cancelled delayed deregister.";
+ SLOG(this, 2) << __func__ << " Cancelled delayed deregister.";
}
// Some modems will implicitly disconnect the bearer when transitioning to
@@ -306,7 +313,7 @@
void CellularCapabilityUniversal::Stop_DeleteActiveBearer(
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (!active_bearer_) {
Stop_Disable(callback);
@@ -325,14 +332,14 @@
void CellularCapabilityUniversal::Stop_DeleteActiveBearerCompleted(
const ResultCallback &callback, const Error &error) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// Disregard the error from the bearer deletion since the disable will clean
// up any remaining bearers.
Stop_Disable(callback);
}
void CellularCapabilityUniversal::Stop_Disable(const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
Error error;
modem_info()->metrics()->NotifyDeviceDisableStarted(
cellular()->interface_index());
@@ -347,7 +354,7 @@
void CellularCapabilityUniversal::Stop_DisableCompleted(
const ResultCallback &callback, const Error &error) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (error.IsSuccess()) {
// The modem has been successfully disabled, but we still need to power it
@@ -361,7 +368,7 @@
void CellularCapabilityUniversal::Stop_PowerDown(
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
Error error;
modem_proxy_->SetPowerState(
MM_MODEM_POWER_STATE_LOW,
@@ -385,10 +392,10 @@
void CellularCapabilityUniversal::Stop_PowerDownCompleted(
const ResultCallback &callback,
const Error &error) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (error.IsFailure())
- SLOG(Cellular, 2) << "Ignoring error returned by SetPowerState: " << error;
+ SLOG(this, 2) << "Ignoring error returned by SetPowerState: " << error;
// Since the disable succeeded, if power down fails, we currently fail
// silently, i.e. we need to report the disable operation as having
@@ -402,7 +409,7 @@
void CellularCapabilityUniversal::Connect(const DBusPropertiesMap &properties,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
DBusPathCallback cb = Bind(&CellularCapabilityUniversal::OnConnectReply,
weak_ptr_factory_.GetWeakPtr(),
callback);
@@ -411,9 +418,9 @@
void CellularCapabilityUniversal::Disconnect(Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (modem_simple_proxy_.get()) {
- SLOG(Cellular, 2) << "Disconnect all bearers.";
+ SLOG(this, 2) << "Disconnect all bearers.";
// If "/" is passed as the bearer path, ModemManager will disconnect all
// bearers.
modem_simple_proxy_->Disconnect(DBus::Path(kRootPath),
@@ -424,7 +431,7 @@
}
void CellularCapabilityUniversal::CompleteActivation(Error *error) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// Persist the ICCID as "Pending Activation".
// We're assuming that when this function gets called,
@@ -432,7 +439,7 @@
// is non-empty, though something is wrong if it is empty.
const string &sim_identifier = cellular()->sim_identifier();
if (sim_identifier.empty()) {
- SLOG(Cellular, 2) << "SIM identifier not available. Nothing to do.";
+ SLOG(this, 2) << "SIM identifier not available. Nothing to do.";
return;
}
@@ -442,12 +449,12 @@
PendingActivationStore::kStatePending);
UpdatePendingActivationState();
- SLOG(Cellular, 2) << "Resetting modem for activation.";
+ SLOG(this, 2) << "Resetting modem for activation.";
ResetAfterActivation();
}
void CellularCapabilityUniversal::ResetAfterActivation() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// Here the initial call to Reset might fail in rare cases. Simply ignore.
Error error;
@@ -456,14 +463,14 @@
weak_ptr_factory_.GetWeakPtr());
Reset(&error, callback);
if (error.IsFailure())
- SLOG(Cellular, 2) << "Failed to reset after activation.";
+ SLOG(this, 2) << "Failed to reset after activation.";
}
void CellularCapabilityUniversal::OnResetAfterActivationReply(
const Error &error) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (error.IsFailure()) {
- SLOG(Cellular, 2) << "Failed to reset after activation. Try again later.";
+ SLOG(this, 2) << "Failed to reset after activation. Try again later.";
// TODO(armansito): Maybe post a delayed reset task?
return;
}
@@ -472,7 +479,7 @@
}
void CellularCapabilityUniversal::UpdatePendingActivationState() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
const string &sim_identifier = cellular()->sim_identifier();
bool registered =
@@ -516,7 +523,7 @@
// been unavailable earlier.
service->SetActivationState(kActivationStateActivating);
if (reset_done_) {
- SLOG(Cellular, 2) << "Post-payment activation reset complete.";
+ SLOG(this, 2) << "Post-payment activation reset complete.";
modem_info()->pending_activation_store()->SetActivationState(
PendingActivationStore::kIdentifierICCID,
sim_identifier,
@@ -526,8 +533,8 @@
case PendingActivationStore::kStateActivated:
if (registered) {
// Trigger auto connect here.
- SLOG(Cellular, 2) << "Modem has been reset at least once, try to "
- << "autoconnect to force MDN to update.";
+ SLOG(this, 2) << "Modem has been reset at least once, try to "
+ << "autoconnect to force MDN to update.";
service->AutoConnect();
}
break;
@@ -563,7 +570,7 @@
}
void CellularCapabilityUniversal::ReleaseProxies() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
modem_3gpp_proxy_.reset();
modem_proxy_.reset();
modem_simple_proxy_.reset();
@@ -668,7 +675,7 @@
// Leave the APN at the front of the list, so that it can be recorded
// if the connect attempt succeeds.
Stringmap apn_info = apn_try_list_.front();
- SLOG(Cellular, 2) << __func__ << ": Using APN " << apn_info[kApnProperty];
+ SLOG(this, 2) << __func__ << ": Using APN " << apn_info[kApnProperty];
(*properties)[kConnectApn].writer().append_string(
apn_info[kApnProperty].c_str());
if (ContainsKey(apn_info, kApnUsernameProperty))
@@ -683,7 +690,7 @@
void CellularCapabilityUniversal::OnConnectReply(const ResultCallback &callback,
const DBus::Path &path,
const Error &error) {
- SLOG(Cellular, 3) << __func__ << "(" << error << ")";
+ SLOG(this, 3) << __func__ << "(" << error << ")";
CellularServiceRefPtr service = cellular()->service();
if (!service) {
@@ -698,8 +705,8 @@
// with some modems in some cases.
if (RetriableConnectError(error) && !apn_try_list_.empty()) {
apn_try_list_.pop_front();
- SLOG(Cellular, 2) << "Connect failed with invalid APN, "
- << apn_try_list_.size() << " remaining APNs to try";
+ SLOG(this, 2) << "Connect failed with invalid APN, "
+ << apn_try_list_.size() << " remaining APNs to try";
DBusPropertiesMap props;
FillConnectPropertyMap(&props);
Error error;
@@ -711,7 +718,7 @@
service->SetLastGoodApn(apn_try_list_.front());
apn_try_list_.clear();
}
- SLOG(Cellular, 2) << "Connected bearer " << path;
+ SLOG(this, 2) << "Connected bearer " << path;
}
if (!callback.is_null())
@@ -725,7 +732,7 @@
}
void CellularCapabilityUniversal::GetProperties() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
std::unique_ptr<DBusPropertiesProxyInterface> properties_proxy(
proxy_factory()->CreateDBusPropertiesProxy(cellular()->dbus_path(),
@@ -739,7 +746,7 @@
}
void CellularCapabilityUniversal::UpdateServiceOLP() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// OLP is based off of the Home Provider.
if (!cellular()->home_provider_info()->IsMobileNetworkOperatorKnown()) {
@@ -753,7 +760,7 @@
}
if (olp_list.size() > 1) {
- SLOG(Cellular, 1) << "Found multiple online portals. Choosing the first.";
+ SLOG(this, 1) << "Found multiple online portals. Choosing the first.";
}
string post_data = olp_list[0].post_data;
ReplaceSubstringsAfterOffset(&post_data, 0, "${iccid}",
@@ -767,7 +774,7 @@
}
void CellularCapabilityUniversal::UpdateActiveBearer() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// Look for the first active bearer and use its path as the connected
// one. Right now, we don't allow more than one active bearer.
@@ -783,13 +790,13 @@
if (!bearer->connected())
continue;
- SLOG(Cellular, 2) << "Found active bearer \"" << path << "\".";
+ SLOG(this, 2) << "Found active bearer \"" << path << "\".";
CHECK(!active_bearer_) << "Found more than one active bearer.";
active_bearer_ = std::move(bearer);
}
if (!active_bearer_)
- SLOG(Cellular, 2) << "No active bearer found.";
+ SLOG(this, 2) << "No active bearer found.";
}
bool CellularCapabilityUniversal::IsServiceActivationRequired() const {
@@ -836,8 +843,8 @@
// always called from an async context
void CellularCapabilityUniversal::Register(const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__ << " \"" << cellular()->selected_network()
- << "\"";
+ SLOG(this, 3) << __func__ << " \"" << cellular()->selected_network()
+ << "\"";
CHECK(!callback.is_null());
Error error;
ResultCallback cb = Bind(&CellularCapabilityUniversal::OnRegisterReply,
@@ -852,7 +859,7 @@
const string &network_id,
Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__ << "(" << network_id << ")";
+ SLOG(this, 3) << __func__ << "(" << network_id << ")";
CHECK(error);
desired_network_ = network_id;
ResultCallback cb = Bind(&CellularCapabilityUniversal::OnRegisterReply,
@@ -863,7 +870,7 @@
void CellularCapabilityUniversal::OnRegisterReply(
const ResultCallback &callback,
const Error &error) {
- SLOG(Cellular, 3) << __func__ << "(" << error << ")";
+ SLOG(this, 3) << __func__ << "(" << error << ")";
if (error.IsSuccess()) {
cellular()->set_selected_network(desired_network_);
@@ -914,7 +921,7 @@
Error *error,
const ResultCallback &callback) {
CHECK(error);
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
sim_proxy_->SendPin(pin, error, callback, kEnterPinTimeoutMilliseconds);
}
@@ -935,7 +942,7 @@
void CellularCapabilityUniversal::Reset(Error *error,
const ResultCallback &callback) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
CHECK(error);
if (resetting_) {
Error::PopulateAndLog(error, Error::kInProgress, "Already resetting");
@@ -951,7 +958,7 @@
void CellularCapabilityUniversal::OnResetReply(const ResultCallback &callback,
const Error &error) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
resetting_ = false;
if (!callback.is_null())
callback.Run(error);
@@ -1231,7 +1238,7 @@
const string &interface,
const DBusPropertiesMap &changed_properties,
const vector<string> &invalidated_properties) {
- SLOG(Cellular, 3) << __func__ << "(" << interface << ")";
+ SLOG(this, 3) << __func__ << "(" << interface << ")";
if (interface == MM_DBUS_INTERFACE_MODEM) {
OnModemPropertiesChanged(changed_properties, invalidated_properties);
}
@@ -1338,12 +1345,12 @@
void CellularCapabilityUniversal::OnModemStateChanged(
Cellular::ModemState state) {
- SLOG(Cellular, 3) << __func__ << ": " << Cellular::GetModemStateString(state);
+ SLOG(this, 3) << __func__ << ": " << Cellular::GetModemStateString(state);
if (state == Cellular::kModemStateConnected) {
// This assumes that ModemManager updates the Bearers list and the Bearer
// properties before changing Modem state to Connected.
- SLOG(Cellular, 2) << "Update active bearer.";
+ SLOG(this, 2) << "Update active bearer.";
UpdateActiveBearer();
}
@@ -1352,7 +1359,7 @@
// (See crbug.com/279499).
if (!deferred_enable_modem_callback_.is_null() &&
state == Cellular::kModemStateDisabled) {
- SLOG(Cellular, 2) << "Enabling modem after deferring.";
+ SLOG(this, 2) << "Enabling modem after deferring.";
deferred_enable_modem_callback_.Run();
deferred_enable_modem_callback_.Reset();
}
@@ -1393,7 +1400,7 @@
void CellularCapabilityUniversal::OnLockRetriesChanged(
const LockRetryData &lock_retries) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// Look for the retries left for the current lock. Try the obtain the count
// that matches the current count. If no count for the current lock is
@@ -1411,7 +1418,7 @@
void CellularCapabilityUniversal::OnLockTypeChanged(
MMModemLock lock_type) {
- SLOG(Cellular, 3) << __func__ << ": " << lock_type;
+ SLOG(this, 3) << __func__ << ": " << lock_type;
sim_lock_status_.lock_type = lock_type;
// If the SIM is in a locked state |sim_lock_status_.enabled| might be false.
@@ -1425,7 +1432,7 @@
}
void CellularCapabilityUniversal::OnSimLockStatusChanged() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
cellular()->adaptor()->EmitKeyValueStoreChanged(
kSIMLockStatusProperty, SimLockStatusToProperty(nullptr));
@@ -1447,7 +1454,7 @@
void CellularCapabilityUniversal::OnModem3GPPPropertiesChanged(
const DBusPropertiesMap &properties,
const vector<string> &/* invalidated_properties */) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
uint32_t uint_value;
string imei;
if (DBusProperties::GetString(properties,
@@ -1496,8 +1503,8 @@
DBusProperties::GetUint32(properties,
MM_MODEM_MODEM3GPP_PROPERTY_SUBSCRIPTIONSTATE,
&subscription_state)) {
- SLOG(Cellular, 3) << __func__ << ": Subscription state = "
- << subscription_state;
+ SLOG(this, 3) << __func__ << ": Subscription state = "
+ << subscription_state;
service->out_of_credits_detector()->NotifySubscriptionStateChanged(
subscription_state);
}
@@ -1513,9 +1520,9 @@
MMModem3gppRegistrationState state,
const string &operator_code,
const string &operator_name) {
- SLOG(Cellular, 3) << __func__ << ": regstate=" << state
- << ", opercode=" << operator_code
- << ", opername=" << operator_name;
+ SLOG(this, 3) << __func__ << ": regstate=" << state
+ << ", opercode=" << operator_code
+ << ", opername=" << operator_name;
// While the modem is connected, if the state changed from a registered state
// to a non registered state, defer the state change by 15 seconds.
@@ -1530,7 +1537,7 @@
// posted.
modem_info()->metrics()->Notify3GPPRegistrationDelayedDropPosted();
}
- SLOG(Cellular, 2) << "Posted deferred registration state update";
+ SLOG(this, 2) << "Posted deferred registration state update";
registration_dropped_update_callback_.Reset(
Bind(&CellularCapabilityUniversal::Handle3GPPRegistrationChange,
weak_ptr_factory_.GetWeakPtr(),
@@ -1542,7 +1549,7 @@
registration_dropped_update_timeout_milliseconds_);
} else {
if (!registration_dropped_update_callback_.IsCancelled()) {
- SLOG(Cellular, 2) << "Cancelled a deferred registration state update";
+ SLOG(this, 2) << "Cancelled a deferred registration state update";
registration_dropped_update_callback_.Cancel();
// If we cancelled the callback here, it means we had flaky network for a
// small duration.
@@ -1561,9 +1568,9 @@
// So, explicitly cancel the callback here.
registration_dropped_update_callback_.Cancel();
- SLOG(Cellular, 3) << __func__ << ": regstate=" << updated_state
- << ", opercode=" << updated_operator_code
- << ", opername=" << updated_operator_name;
+ SLOG(this, 3) << __func__ << ": regstate=" << updated_state
+ << ", opercode=" << updated_operator_code
+ << ", opername=" << updated_operator_name;
registration_state_ = updated_state;
serving_operator_[kOperatorCodeKey] = updated_operator_code;
@@ -1581,8 +1588,8 @@
void CellularCapabilityUniversal::On3GPPSubscriptionStateChanged(
MMModem3gppSubscriptionState updated_state) {
- SLOG(Cellular, 3) << __func__ << ": Updated subscription state = "
- << updated_state;
+ SLOG(this, 3) << __func__ << ": Updated subscription state = "
+ << updated_state;
// A one-to-one enum mapping.
SubscriptionState new_subscription_state;
@@ -1620,10 +1627,12 @@
static_cast<Cellular::ModemState>(old_state);
Cellular::ModemState new_modem_state =
static_cast<Cellular::ModemState>(new_state);
- SLOG(Cellular, 3) << __func__ << "("
- << Cellular::GetModemStateString(old_modem_state) << ", "
- << Cellular::GetModemStateString(new_modem_state) << ", "
- << reason << ")";
+ SLOG(this, 3) << __func__ << "("
+ << Cellular::GetModemStateString(old_modem_state)
+ << ", "
+ << Cellular::GetModemStateString(new_modem_state)
+ << ", "
+ << reason << ")";
}
void CellularCapabilityUniversal::OnSignalQualityChanged(uint32_t quality) {
@@ -1641,7 +1650,7 @@
void CellularCapabilityUniversal::OnSimPropertiesChanged(
const DBusPropertiesMap &props,
const vector<string> &/* invalidated_properties */) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
string value;
if (DBusProperties::GetString(props, MM_SIM_PROPERTY_SIMIDENTIFIER, &value))
OnSimIdentifierChanged(value);
@@ -1674,7 +1683,7 @@
void CellularCapabilityUniversal::OnOperatorIdChanged(
const string &operator_id) {
- SLOG(Cellular, 2) << "Operator ID = '" << operator_id << "'";
+ SLOG(this, 2) << "Operator ID = '" << operator_id << "'";
cellular()->home_provider_info()->UpdateMCCMNC(operator_id);
}
diff --git a/cellular_capability_universal_cdma.cc b/cellular_capability_universal_cdma.cc
index 7041293..d0d62ef 100644
--- a/cellular_capability_universal_cdma.cc
+++ b/cellular_capability_universal_cdma.cc
@@ -28,6 +28,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularCapabilityUniversalCDMA *c) {
+ return c->cellular()->GetRpcIdentifier();
+}
+}
+
namespace {
const char kPhoneNumber[] = "#777";
@@ -46,7 +53,7 @@
cdma_evdo_registration_state_(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN),
nid_(0),
sid_(0) {
- SLOG(Cellular, 2) << "Cellular capability constructed: Universal CDMA";
+ SLOG(this, 2) << "Cellular capability constructed: Universal CDMA";
// TODO(armansito): Update PRL for activation over cellular.
// See crbug.com/197330.
}
@@ -54,7 +61,7 @@
CellularCapabilityUniversalCDMA::~CellularCapabilityUniversalCDMA() {}
void CellularCapabilityUniversalCDMA::InitProxies() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
modem_cdma_proxy_.reset(
proxy_factory()->CreateMM1ModemModemCdmaProxy(cellular()->dbus_path(),
cellular()->dbus_owner()));
@@ -65,7 +72,7 @@
}
void CellularCapabilityUniversalCDMA::ReleaseProxies() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
modem_cdma_proxy_.reset();
CellularCapabilityUniversal::ReleaseProxies();
}
@@ -81,7 +88,7 @@
}
void CellularCapabilityUniversalCDMA::CompleteActivation(Error *error) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (cellular()->state() < Cellular::kStateEnabled) {
Error::PopulateAndLog(error, Error::kInvalidArguments,
"Unable to activate in state " +
@@ -94,8 +101,8 @@
void CellularCapabilityUniversalCDMA::ActivateAutomatic() {
if (!cellular()->serving_operator_info()->IsMobileNetworkOperatorKnown() ||
cellular()->serving_operator_info()->activation_code().empty()) {
- SLOG(Cellular, 2) << "OTA activation cannot be run in the presence of no "
- << "activation code.";
+ SLOG(this, 2) << "OTA activation cannot be run in the presence of no "
+ << "activation code.";
return;
}
@@ -103,12 +110,12 @@
modem_info()->pending_activation_store()->GetActivationState(
PendingActivationStore::kIdentifierMEID, cellular()->meid());
if (state == PendingActivationStore::kStatePending) {
- SLOG(Cellular, 2) << "There's already a pending activation. Ignoring.";
+ SLOG(this, 2) << "There's already a pending activation. Ignoring.";
return;
}
if (state == PendingActivationStore::kStateActivated) {
- SLOG(Cellular, 2) << "A call to OTA activation has already completed "
- << "successfully. Ignoring.";
+ SLOG(this, 2) << "A call to OTA activation has already completed "
+ << "successfully. Ignoring.";
return;
}
@@ -134,9 +141,9 @@
}
void CellularCapabilityUniversalCDMA::UpdatePendingActivationState() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (IsActivated()) {
- SLOG(Cellular, 3) << "CDMA service activated. Clear store.";
+ SLOG(this, 3) << "CDMA service activated. Clear store.";
modem_info()->pending_activation_store()->RemoveEntry(
PendingActivationStore::kIdentifierMEID, cellular()->meid());
return;
@@ -145,19 +152,19 @@
modem_info()->pending_activation_store()->GetActivationState(
PendingActivationStore::kIdentifierMEID, cellular()->meid());
if (IsActivating() && state != PendingActivationStore::kStateFailureRetry) {
- SLOG(Cellular, 3) << "OTA activation in progress. Nothing to do.";
+ SLOG(this, 3) << "OTA activation in progress. Nothing to do.";
return;
}
switch (state) {
case PendingActivationStore::kStateFailureRetry:
- SLOG(Cellular, 3) << "OTA activation failed. Scheduling a retry.";
+ SLOG(this, 3) << "OTA activation failed. Scheduling a retry.";
cellular()->dispatcher()->PostTask(
Bind(&CellularCapabilityUniversalCDMA::ActivateAutomatic,
weak_cdma_ptr_factory_.GetWeakPtr()));
break;
case PendingActivationStore::kStateActivated:
- SLOG(Cellular, 3) << "OTA Activation has completed successfully. "
- << "Waiting for activation state update to finalize.";
+ SLOG(this, 3) << "OTA Activation has completed successfully. "
+ << "Waiting for activation state update to finalize.";
break;
default:
break;
@@ -183,7 +190,7 @@
}
void CellularCapabilityUniversalCDMA::OnServiceCreated() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
cellular()->service()->SetActivationType(
CellularService::kActivationTypeOTASP);
UpdateServiceActivationStateProperty();
@@ -203,7 +210,7 @@
}
void CellularCapabilityUniversalCDMA::UpdateServiceOLP() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
// In this case, the Home Provider is trivial. All information comes from the
// Serving Operator.
@@ -218,7 +225,7 @@
}
if (olp_list.size() > 1) {
- SLOG(Cellular, 1) << "Found multiple online portals. Choosing the first.";
+ SLOG(this, 1) << "Found multiple online portals. Choosing the first.";
}
string post_data = olp_list[0].post_data;
ReplaceSubstringsAfterOffset(&post_data, 0, "${esn}", cellular()->esn());
@@ -231,7 +238,7 @@
}
void CellularCapabilityUniversalCDMA::GetProperties() {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
CellularCapabilityUniversal::GetProperties();
std::unique_ptr<DBusPropertiesProxyInterface> properties_proxy(
@@ -246,7 +253,7 @@
uint32_t activation_state,
uint32_t activation_error,
const DBusPropertiesMap &status_changes) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
activation_state_ =
static_cast<MMModemCdmaActivationState>(activation_state);
@@ -257,8 +264,8 @@
if (DBusProperties::GetString(status_changes, "min", &value))
cellular()->set_min(value);
- SLOG(Cellular, 2) << "Activation state: "
- << GetActivationStateString(activation_state_);
+ SLOG(this, 2) << "Activation state: "
+ << GetActivationStateString(activation_state_);
HandleNewActivationStatus(activation_error);
UpdatePendingActivationState();
@@ -267,7 +274,7 @@
void CellularCapabilityUniversalCDMA::OnActivateReply(
const ResultCallback &callback,
const Error &error) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (error.IsSuccess()) {
LOG(INFO) << "Activation completed successfully.";
modem_info()->pending_activation_store()->SetActivationState(
@@ -292,12 +299,12 @@
void CellularCapabilityUniversalCDMA::HandleNewActivationStatus(
uint32_t error) {
- SLOG(Cellular, 2) << __func__ << "(" << error << ")";
+ SLOG(this, 2) << __func__ << "(" << error << ")";
if (!cellular()->service().get()) {
LOG(ERROR) << "In " << __func__ << "(): service is null.";
return;
}
- SLOG(Cellular, 2) << "Activation State: " << activation_state_;
+ SLOG(this, 2) << "Activation State: " << activation_state_;
cellular()->service()->SetActivationState(
GetActivationStateString(activation_state_));
cellular()->service()->set_error(GetActivationErrorString(error));
@@ -441,7 +448,7 @@
const string &interface,
const DBusPropertiesMap &changed_properties,
const vector<string> &invalidated_properties) {
- SLOG(Cellular, 2) << __func__ << "(" << interface << ")";
+ SLOG(this, 2) << __func__ << "(" << interface << ")";
if (interface == MM_DBUS_INTERFACE_MODEM_MODEMCDMA) {
OnModemCDMAPropertiesChanged(changed_properties, invalidated_properties);
} else {
@@ -453,7 +460,7 @@
void CellularCapabilityUniversalCDMA::OnModemCDMAPropertiesChanged(
const DBusPropertiesMap &properties,
const std::vector<std::string> &/*invalidated_properties*/) {
- SLOG(Cellular, 2) << __func__;
+ SLOG(this, 2) << __func__;
string str_value;
if (DBusProperties::GetString(properties,
MM_MODEM_MODEMCDMA_PROPERTY_MEID,
@@ -513,9 +520,8 @@
MMModemCdmaRegistrationState state_1x,
MMModemCdmaRegistrationState state_evdo,
uint32_t sid, uint32_t nid) {
- SLOG(Cellular, 2) << __func__
- << ": state_1x=" << state_1x
- << ", state_evdo=" << state_evdo;
+ SLOG(this, 2) << __func__ << ": state_1x=" << state_1x
+ << ", state_evdo=" << state_evdo;
cdma_1x_registration_state_ = state_1x;
cdma_evdo_registration_state_ = state_evdo;
sid_ = sid;
diff --git a/cellular_service.cc b/cellular_service.cc
index 223010c..24a8f6b 100644
--- a/cellular_service.cc
+++ b/cellular_service.cc
@@ -18,6 +18,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularService *c) { return c->GetRpcIdentifier(); }
+}
+
// statics
const char CellularService::kAutoConnActivating[] = "activating";
const char CellularService::kAutoConnBadPPPCredentials[] =
@@ -349,7 +354,7 @@
}
void CellularService::SetStorageIdentifier(const string &identifier) {
- SLOG(Cellular, 3) << __func__ << ": " << identifier;
+ SLOG(this, 3) << __func__ << ": " << identifier;
storage_identifier_ = identifier;
std::replace_if(storage_identifier_.begin(),
storage_identifier_.end(),
diff --git a/certificate_file.cc b/certificate_file.cc
index b147482..d779dd4 100644
--- a/certificate_file.cc
+++ b/certificate_file.cc
@@ -24,6 +24,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCrypto;
+static string ObjectID(CertificateFile *c) { return "(certificate_file)"; }
+}
+
const char CertificateFile::kDefaultRootDirectory[] =
RUNDIR "/certificate_export";
const char CertificateFile::kPEMHeader[] = "-----BEGIN CERTIFICATE-----";
@@ -31,11 +36,11 @@
CertificateFile::CertificateFile()
: root_directory_(FilePath(kDefaultRootDirectory)) {
- SLOG(Crypto, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
CertificateFile::~CertificateFile() {
- SLOG(Crypto, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!output_file_.empty()) {
base::DeleteFile(output_file_, false);
}
diff --git a/connection.cc b/connection.cc
index 940ceb2..d2a30ff 100644
--- a/connection.cc
+++ b/connection.cc
@@ -25,6 +25,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kConnection;
+static string ObjectID(Connection *c) {
+ return c->interface_name();
+}
+}
+
// static
const uint32_t Connection::kDefaultMetric = 1;
// static
@@ -59,7 +66,7 @@
<< connection_->interface_name();
connection_.reset();
if (!client_disconnect_callback_.is_null()) {
- SLOG(Connection, 2) << "Running client disconnect callback.";
+ SLOG(connection_.get(), 2) << "Running client disconnect callback.";
client_disconnect_callback_.Run();
}
}
@@ -86,13 +93,13 @@
resolver_(Resolver::GetInstance()),
routing_table_(RoutingTable::GetInstance()),
rtnl_handler_(RTNLHandler::GetInstance()) {
- SLOG(Connection, 2) << __func__ << "(" << interface_index << ", "
- << interface_name << ", "
- << Technology::NameFromIdentifier(technology) << ")";
+ SLOG(this, 2) << __func__ << "(" << interface_index << ", "
+ << interface_name << ", "
+ << Technology::NameFromIdentifier(technology) << ")";
}
Connection::~Connection() {
- SLOG(Connection, 2) << __func__ << " " << interface_name_;
+ SLOG(this, 2) << __func__ << " " << interface_name_;
NotifyBindersOnDisconnect();
@@ -103,7 +110,7 @@
}
void Connection::UpdateFromIPConfig(const IPConfigRefPtr &config) {
- SLOG(Connection, 2) << __func__ << " " << interface_name_;
+ SLOG(this, 2) << __func__ << " " << interface_name_;
const IPConfig::Properties &properties = config->properties();
IPAddress gateway(properties.address_family);
@@ -209,9 +216,9 @@
}
void Connection::SetIsDefault(bool is_default) {
- SLOG(Connection, 2) << __func__ << " " << interface_name_
- << " (index " << interface_index_ << ") "
- << is_default_ << " -> " << is_default;
+ SLOG(this, 2) << __func__ << " " << interface_name_
+ << " (index " << interface_index_ << ") "
+ << is_default_ << " -> " << is_default;
if (is_default == is_default_) {
return;
}
@@ -242,8 +249,8 @@
vector<string> domain_search = dns_domain_search_;
if (domain_search.empty() && !dns_domain_name_.empty()) {
- SLOG(Connection, 2) << "Setting domain search to domain name "
- << dns_domain_name_;
+ SLOG(this, 2) << "Setting domain search to domain name "
+ << dns_domain_name_;
domain_search.push_back(dns_domain_name_ + ".");
}
resolver_->SetDNSFromLists(dns_servers_, domain_search);
@@ -422,7 +429,7 @@
bool Connection::PinHostRoute(const IPAddress &trusted_ip,
const IPAddress &gateway) {
- SLOG(Connection, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!trusted_ip.IsValid()) {
LOG(ERROR) << "No trusted IP -- unable to pin host route.";
return false;
@@ -441,8 +448,8 @@
void Connection::OnRouteQueryResponse(int interface_index,
const RoutingTableEntry &entry) {
- SLOG(Connection, 2) << __func__ << "(" << interface_index << ", "
- << entry.tag << ")" << " @ " << interface_name_;
+ SLOG(this, 2) << __func__ << "(" << interface_index << ", "
+ << entry.tag << ")" << " @ " << interface_name_;
lower_binder_.Attach(nullptr);
DeviceRefPtr device = device_info_->GetDevice(interface_index);
if (!device) {
@@ -480,7 +487,7 @@
}
void Connection::OnLowerDisconnect() {
- SLOG(Connection, 2) << __func__ << " @ " << interface_name_;
+ SLOG(this, 2) << __func__ << " @ " << interface_name_;
// Ensures that |this| instance doesn't get destroyed in the middle of
// notifying the binders. This method needs to be separate from
// NotifyBindersOnDisconnect because the latter may be invoked by Connection's
@@ -491,7 +498,7 @@
void Connection::NotifyBindersOnDisconnect() {
// Note that this method may be invoked by the destructor.
- SLOG(Connection, 2) << __func__ << " @ " << interface_name_;
+ SLOG(this, 2) << __func__ << " @ " << interface_name_;
// Unbinds the lower connection before notifying the binders. This ensures
// correct behavior in case of circular binding.
@@ -506,14 +513,14 @@
}
void Connection::AttachBinder(Binder *binder) {
- SLOG(Connection, 2) << __func__ << "(" << binder->name() << ")" << " @ "
- << interface_name_;
+ SLOG(this, 2) << __func__ << "(" << binder->name() << ")" << " @ "
+ << interface_name_;
binders_.push_back(binder);
}
void Connection::DetachBinder(Binder *binder) {
- SLOG(Connection, 2) << __func__ << "(" << binder->name() << ")" << " @ "
- << interface_name_;
+ SLOG(this, 2) << __func__ << "(" << binder->name() << ")" << " @ "
+ << interface_name_;
for (auto it = binders_.begin(); it != binders_.end(); ++it) {
if (binder == *it) {
binders_.erase(it);
@@ -523,7 +530,7 @@
}
ConnectionRefPtr Connection::GetCarrierConnection() {
- SLOG(Connection, 2) << __func__ << " @ " << interface_name_;
+ SLOG(this, 2) << __func__ << " @ " << interface_name_;
set<Connection *> visited;
ConnectionRefPtr carrier = this;
while (carrier->GetLowerConnection()) {
@@ -537,8 +544,8 @@
visited.insert(carrier.get());
carrier = carrier->GetLowerConnection();
}
- SLOG(Connection, 2) << "Carrier connection: " << carrier->interface_name()
- << " @ " << interface_name_;
+ SLOG(this, 2) << "Carrier connection: " << carrier->interface_name()
+ << " @ " << interface_name_;
return carrier;
}
diff --git a/connection_health_checker.cc b/connection_health_checker.cc
index 2e3d0f7..0c3b5cc 100644
--- a/connection_health_checker.cc
+++ b/connection_health_checker.cc
@@ -35,6 +35,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kConnection;
+static string ObjectID(Connection *c) {
+ return c->interface_name();
+}
+}
+
// static
const char *ConnectionHealthChecker::kDefaultRemoteIPPool[] = {
"74.125.224.47",
@@ -117,12 +124,13 @@
HTTPURL url;
if (!url.ParseFromString(url_string)) {
- SLOG(Connection, 2) << __func__ << ": Malformed url: " << url_string << ".";
+ SLOG(connection_, 2) << __func__ << ": Malformed url: "
+ << url_string << ".";
return;
}
if (url.port() != kRemotePort) {
- SLOG(Connection, 2) << __func__ << ": Remote connections only supported "
- << " to port 80, requested " << url.port() << ".";
+ SLOG(connection_, 2) << __func__ << ": Remote connections only supported "
+ << " to port 80, requested " << url.port() << ".";
return;
}
for (int i = 0; i < kNumDNSQueries; ++i) {
@@ -136,20 +144,20 @@
dns_client_callback_);
dns_clients_.push_back(dns_client);
if (!dns_clients_[i]->Start(url.host(), &error)) {
- SLOG(Connection, 2) << __func__ << ": Failed to start DNS client "
- << "(query #" << i << "): "
- << error.message();
+ SLOG(connection_, 2) << __func__ << ": Failed to start DNS client "
+ << "(query #" << i << "): "
+ << error.message();
}
}
}
void ConnectionHealthChecker::Start() {
if (health_check_in_progress_) {
- SLOG(Connection, 2) << __func__ << ": Health Check already in progress.";
+ SLOG(connection_, 2) << __func__ << ": Health Check already in progress.";
return;
}
if (!connection_.get()) {
- SLOG(Connection, 2) << __func__ << ": Connection not ready yet.";
+ SLOG(connection_, 2) << __func__ << ": Connection not ready yet.";
result_callback_.Run(kResultUnknown);
return;
}
@@ -162,7 +170,7 @@
if (remote_ips_->Empty()) {
// Nothing to try.
Stop();
- SLOG(Connection, 2) << __func__ << ": Not enough IPs.";
+ SLOG(connection_, 2) << __func__ << ": Not enough IPs.";
result_callback_.Run(kResultUnknown);
return;
}
@@ -184,7 +192,7 @@
}
void ConnectionHealthChecker::SetConnection(ConnectionRefPtr connection) {
- SLOG(Connection, 3) << __func__;
+ SLOG(connection_, 3) << __func__;
connection_ = connection;
tcp_connection_.reset(new AsyncConnection(connection_->interface_name(),
dispatcher_,
@@ -216,8 +224,8 @@
void ConnectionHealthChecker::GetDNSResult(const Error &error,
const IPAddress& ip) {
if (!error.IsSuccess()) {
- SLOG(Connection, 2) << __func__ << "DNSClient returned failure: "
- << error.message();
+ SLOG(connection_, 2) << __func__ << "DNSClient returned failure: "
+ << error.message();
return;
}
remote_ips_->AddUnique(ip);
@@ -260,10 +268,10 @@
// (1) Repeated failed attempts for the same IP at start-up everytime.
// (2) All users attempting to connect to the same IP.
IPAddress ip = remote_ips_->GetRandomIP();
- SLOG(Connection, 3) << __func__ << ": Starting connection at "
- << ip.ToString();
+ SLOG(connection_, 3) << __func__ << ": Starting connection at "
+ << ip.ToString();
if (!tcp_connection_->Start(ip, kRemotePort)) {
- SLOG(Connection, 2) << __func__ << ": Connection attempt failed.";
+ SLOG(connection_, 2) << __func__ << ": Connection attempt failed.";
++num_connection_failures_;
NextHealthCheckSample();
}
@@ -271,10 +279,10 @@
void ConnectionHealthChecker::OnConnectionComplete(bool success, int sock_fd) {
if (!success) {
- SLOG(Connection, 2) << __func__
- << ": AsyncConnection connection attempt failed "
- << "with error: "
- << tcp_connection_->error();
+ SLOG(connection_, 2) << __func__
+ << ": AsyncConnection connection attempt failed "
+ << "with error: "
+ << tcp_connection_->error();
++num_connection_failures_;
NextHealthCheckSample();
return;
@@ -286,8 +294,8 @@
if (!GetSocketInfo(sock_fd_, &sock_info) ||
sock_info.connection_state() !=
SocketInfo::kConnectionStateEstablished) {
- SLOG(Connection, 2) << __func__
- << ": Connection originally not in established state..";
+ SLOG(connection_, 2) << __func__
+ << ": Connection originally not in established state.";
// Count this as a failed connection attempt.
++num_connection_failures_;
ClearSocketDescriptor();
@@ -302,7 +310,7 @@
// transfer.
char buf;
if (socket_->Send(sock_fd_, &buf, sizeof(buf), 0) == -1) {
- SLOG(Connection, 2) << __func__ << ": " << socket_->ErrorString();
+ SLOG(connection_, 2) << __func__ << ": " << socket_->ErrorString();
// Count this as a failed connection attempt.
++num_connection_failures_;
ClearSocketDescriptor();
@@ -328,18 +336,18 @@
SocketInfo::kConnectionStateEstablished &&
sock_info.connection_state() !=
SocketInfo::kConnectionStateCloseWait)) {
- SLOG(Connection, 2) << __func__
- << ": Connection not in acceptable state after send.";
+ SLOG(connection_, 2) << __func__
+ << ": Connection not in acceptable state after send.";
if (sock_info_found)
- SLOG(Connection, 3) << "Found socket info but in state: "
- << sock_info.connection_state();
+ SLOG(connection_, 3) << "Found socket info but in state: "
+ << sock_info.connection_state();
++num_connection_failures_;
} else if (sock_info.transmit_queue_value() > old_transmit_queue_value_ &&
sock_info.timer_state() ==
SocketInfo::kTimerStateRetransmitTimerPending) {
if (num_tx_queue_polling_attempts_ < kMaxSentDataPollingAttempts) {
- SLOG(Connection, 2) << __func__
- << ": Polling again.";
+ SLOG(connection_, 2) << __func__
+ << ": Polling again.";
++num_tx_queue_polling_attempts_;
verify_sent_data_callback_.Reset(
Bind(&ConnectionHealthChecker::VerifySentData, Unretained(this)));
@@ -347,10 +355,10 @@
tcp_state_update_wait_milliseconds_);
return;
}
- SLOG(Connection, 2) << __func__ << ": Sampled congested Tx-Queue";
+ SLOG(connection_, 2) << __func__ << ": Sampled congested Tx-Queue";
++num_congested_queue_detected_;
} else {
- SLOG(Connection, 2) << __func__ << ": Sampled successful send.";
+ SLOG(connection_, 2) << __func__ << ": Sampled successful send.";
++num_successful_sends_;
}
ClearSocketDescriptor();
@@ -366,12 +374,12 @@
if (socket_->GetSockName(sock_fd,
reinterpret_cast<struct sockaddr *>(&addr),
&addrlen) != 0) {
- SLOG(Connection, 2) << __func__
- << ": Failed to get address of created socket.";
+ SLOG(connection_, 2) << __func__
+ << ": Failed to get address of created socket.";
return false;
}
if (addr.ss_family != AF_INET) {
- SLOG(Connection, 2) << __func__ << ": IPv6 socket address found.";
+ SLOG(connection_, 2) << __func__ << ": IPv6 socket address found.";
return false;
}
@@ -382,19 +390,19 @@
const char *res = inet_ntop(AF_INET, &addr_in->sin_addr,
ipstr, sizeof(ipstr));
if (res == nullptr) {
- SLOG(Connection, 2) << __func__
- << ": Could not convert IP address to string.";
+ SLOG(connection_, 2) << __func__
+ << ": Could not convert IP address to string.";
return false;
}
IPAddress local_ip_address(IPAddress::kFamilyIPv4);
CHECK(local_ip_address.SetAddressFromString(ipstr));
- SLOG(Connection, 3) << "Local IP = " << local_ip_address.ToString()
- << ":" << local_port;
+ SLOG(connection_, 3) << "Local IP = " << local_ip_address.ToString()
+ << ":" << local_port;
vector<SocketInfo> info_list;
if (!socket_info_reader_->LoadTcpSocketInfo(&info_list)) {
- SLOG(Connection, 2) << __func__ << ": Failed to load TCP socket info.";
+ SLOG(connection_, 2) << __func__ << ": Failed to load TCP socket info.";
return false;
}
@@ -403,7 +411,7 @@
++info_list_it) {
const SocketInfo &cur_sock_info = *info_list_it;
- SLOG(Connection, 4)
+ SLOG(connection_, 4)
<< "Testing against IP = "
<< cur_sock_info.local_ip_address().ToString()
<< ":" << cur_sock_info.local_port()
@@ -414,26 +422,26 @@
if (cur_sock_info.local_ip_address().Equals(local_ip_address) &&
cur_sock_info.local_port() == local_port) {
- SLOG(Connection, 3) << __func__ << ": Found matching TCP socket info.";
+ SLOG(connection_, 3) << __func__ << ": Found matching TCP socket info.";
*sock_info = cur_sock_info;
return true;
}
}
- SLOG(Connection, 2) << __func__ << ": No matching TCP socket info.";
+ SLOG(connection_, 2) << __func__ << ": No matching TCP socket info.";
return false;
}
void ConnectionHealthChecker::ReportResult() {
- SLOG(Connection, 2) << __func__ << ": Result: "
- << ResultToString(health_check_result_);
+ SLOG(connection_, 2) << __func__ << ": Result: "
+ << ResultToString(health_check_result_);
Stop();
result_callback_.Run(health_check_result_);
}
void ConnectionHealthChecker::SetSocketDescriptor(int sock_fd) {
if (sock_fd_ != kInvalidSocket) {
- SLOG(Connection, 4) << "Closing socket";
+ SLOG(connection_, 4) << "Closing socket";
socket_->Close(sock_fd_);
}
sock_fd_ = sock_fd;
diff --git a/connection_info_reader.cc b/connection_info_reader.cc
index e79b704..d34044a 100644
--- a/connection_info_reader.cc
+++ b/connection_info_reader.cc
@@ -21,6 +21,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kLink;
+static string ObjectID(ConnectionInfoReader *c) {
+ return "(connection_info_reader)";
+}
+}
+
namespace {
const char kConnectionInfoFilePath[] = "/proc/net/ip_conntrack";
@@ -47,7 +54,7 @@
FilePath info_file_path = GetConnectionInfoFilePath();
FileReader file_reader;
if (!file_reader.Open(info_file_path)) {
- SLOG(Link, 2) << __func__ << ": Failed to open '"
+ SLOG(this, 2) << __func__ << ": Failed to open '"
<< info_file_path.value() << "'.";
return false;
}
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();
}
diff --git a/connectivity_trial.cc b/connectivity_trial.cc
index 80a42bd..21dc32e 100644
--- a/connectivity_trial.cc
+++ b/connectivity_trial.cc
@@ -29,6 +29,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kPortal;
+static string ObjectID(Connection *c) { return c->interface_name(); }
+}
+
const char ConnectivityTrial::kDefaultURL[] =
"http://www.gstatic.com/generate_204";
const char ConnectivityTrial::kResponseExpected[] = "HTTP/?.? 204";
@@ -56,7 +61,7 @@
}
bool ConnectivityTrial::Retry(int start_delay_milliseconds) {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (request_.get())
CleanupTrial(false);
else
@@ -67,7 +72,7 @@
bool ConnectivityTrial::Start(const string &url_string,
int start_delay_milliseconds) {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!url_.ParseFromString(url_string)) {
LOG(ERROR) << "Failed to parse URL string: " << url_string;
@@ -83,7 +88,7 @@
}
void ConnectivityTrial::Stop() {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!request_.get()) {
return;
@@ -93,8 +98,8 @@
}
void ConnectivityTrial::StartTrialAfterDelay(int start_delay_milliseconds) {
- SLOG(Portal, 4) << "In " << __func__
- << " delay = " << start_delay_milliseconds << "ms.";
+ SLOG(connection_, 4) << "In " << __func__
+ << " delay = " << start_delay_milliseconds << "ms.";
trial_.Reset(Bind(&ConnectivityTrial::StartTrialTask,
weak_ptr_factory_.GetWeakPtr()));
dispatcher_->PostDelayedTask(trial_.callback(), start_delay_milliseconds);
@@ -152,10 +157,10 @@
}
void ConnectivityTrial::CompleteTrial(Result result) {
- SLOG(Portal, 3) << StringPrintf("Connectivity Trial completed "
- "with phase==%s, status==%s",
- PhaseToString(result.phase).c_str(),
- StatusToString(result.status).c_str());
+ SLOG(connection_, 3) << StringPrintf("Connectivity Trial completed "
+ "with phase==%s, status==%s",
+ PhaseToString(result.phase).c_str(),
+ StatusToString(result.status).c_str());
CleanupTrial(false);
trial_callback_.Run(result);
}
diff --git a/dbus_adaptor.cc b/dbus_adaptor.cc
index 3ee7e7d..124beb7 100644
--- a/dbus_adaptor.cc
+++ b/dbus_adaptor.cc
@@ -25,12 +25,21 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(DBusAdaptor *d) {
+ if (d == nullptr)
+ return "(dbus_adaptor)";
+ return d->path();
+}
+}
+
// public static
const char DBusAdaptor::kNullPath[] = "/";
DBusAdaptor::DBusAdaptor(DBus::Connection* conn, const string &object_path)
: DBus::ObjectAdaptor(*conn, object_path) {
- SLOG(DBus, 2) << "DBusAdaptor: " << object_path;
+ SLOG(this, 2) << "DBusAdaptor: " << object_path;
}
DBusAdaptor::~DBusAdaptor() {}
@@ -60,7 +69,7 @@
value.operator map<string, string>(),
&e);
} else if (DBusAdaptor::IsStringmaps(value.signature())) {
- SLOG(DBus, 1) << " can't yet handle setting type " << value.signature();
+ SLOG(nullptr, 1) << " can't yet handle setting type " << value.signature();
ret = false;
e.Populate(Error::kInternalError);
} else if (DBusAdaptor::IsStrings(value.signature())) {
@@ -75,7 +84,7 @@
} else if (DBusAdaptor::IsUint64(value.signature())) {
ret = store->SetUint64Property(name, value.reader().get_uint64(), &e);
} else if (DBusAdaptor::IsKeyValueStore(value.signature())) {
- SLOG(DBus, 1) << " can't yet handle setting type " << value.signature();
+ SLOG(nullptr, 1) << " can't yet handle setting type " << value.signature();
ret = false;
e.Populate(Error::kInternalError);
} else {
@@ -228,19 +237,19 @@
DBus::type<int32_t> int32_type;
if (key_value_pair.second.signature() == bool_type.sig()) {
- SLOG(DBus, 5) << "Got bool property " << key;
+ SLOG(nullptr, 5) << "Got bool property " << key;
out->SetBool(key, key_value_pair.second.reader().get_bool());
} else if (key_value_pair.second.signature() == int32_type.sig()) {
- SLOG(DBus, 5) << "Got int32_t property " << key;
+ SLOG(nullptr, 5) << "Got int32_t property " << key;
out->SetInt(key, key_value_pair.second.reader().get_int32());
} else if (key_value_pair.second.signature() == string_type.sig()) {
- SLOG(DBus, 5) << "Got string property " << key;
+ SLOG(nullptr, 5) << "Got string property " << key;
out->SetString(key, key_value_pair.second.reader().get_string());
} else if (DBusAdaptor::IsStrings(key_value_pair.second.signature())) {
- SLOG(DBus, 5) << "Got strings property " << key;
+ SLOG(nullptr, 5) << "Got strings property " << key;
out->SetStrings(key, key_value_pair.second.operator vector<string>());
} else if (DBusAdaptor::IsStringmap(key_value_pair.second.signature())) {
- SLOG(DBus, 5) << "Got stringmap property " << key;
+ SLOG(nullptr, 5) << "Got stringmap property " << key;
out->SetStringmap(
key, key_value_pair.second.operator map<string, string>());
} else {
@@ -493,7 +502,7 @@
const DBus::Error &error) {
Continuation *cont = find_continuation(tag);
CHECK(cont) << "Failed to find continuation.";
- SLOG(DBus, 1) << "Returning error: (" << error.name() << ": "
+ SLOG(this, 1) << "Returning error: (" << error.name() << ": "
<< error.message() << ")";
return_error(cont, error);
}
diff --git a/dbus_async_call_helper.h b/dbus_async_call_helper.h
index 402a345..b6770a7 100644
--- a/dbus_async_call_helper.h
+++ b/dbus_async_call_helper.h
@@ -8,14 +8,22 @@
#include "shill/logging.h"
#include <memory>
+#include <string>
#include <base/macros.h> // for ignore_result
#include <dbus-c++/error.h>
#include "shill/error.h"
+using std::string;
+
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p;}
+}
+
// The dbus-c++ async call mechanism has a funny way of handling the
// callback parameter. In particular, the caller is responsible for
// cleaning up the callback. (This is unlike the low-level D-Bus
@@ -39,7 +47,7 @@
Error *error,
void(*error_converter)(const DBus::Error &, Error *),
int timeout, ArgTypes... call_args) {
- SLOG(DBus, 2) << trace_msg << " [timeout=" << timeout << "]";
+ SLOG(&proxy.path(), 2) << trace_msg << " [timeout=" << timeout << "]";
std::unique_ptr<CallbackT> cb(new CallbackT(callback));
try {
(proxy.*call)(call_args..., cb.get(), timeout);
diff --git a/dbus_manager.cc b/dbus_manager.cc
index edf6437..c46dbbf 100644
--- a/dbus_manager.cc
+++ b/dbus_manager.cc
@@ -19,6 +19,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(DBusManager *d) { return "(dbus_manager)"; }
+}
+
namespace {
const int kDefaultRPCTimeoutMS = 30000;
@@ -31,7 +36,7 @@
DBusManager::~DBusManager() {}
void DBusManager::Start() {
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (proxy_.get()) {
return;
}
@@ -41,7 +46,7 @@
}
void DBusManager::Stop() {
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
proxy_.reset();
name_watchers_.clear();
}
diff --git a/dbus_objectmanager_proxy.cc b/dbus_objectmanager_proxy.cc
index 8edee60..7acef1a 100644
--- a/dbus_objectmanager_proxy.cc
+++ b/dbus_objectmanager_proxy.cc
@@ -61,7 +61,7 @@
void DBusObjectManagerProxy::Proxy::InterfacesAdded(
const ::DBus::Path &object_path,
const DBusInterfaceToProperties &interface_to_properties) {
- SLOG(DBus, 2) << __func__ << "(" << object_path << ")";
+ SLOG(&path(), 2) << __func__ << "(" << object_path << ")";
interfaces_added_callback_.Run(object_path, interface_to_properties);
}
@@ -69,7 +69,7 @@
void DBusObjectManagerProxy::Proxy::InterfacesRemoved(
const ::DBus::Path &object_path,
const std::vector<std::string> &interfaces) {
- SLOG(DBus, 2) << __func__ << "(" << object_path << ")";
+ SLOG(&path(), 2) << __func__ << "(" << object_path << ")";
interfaces_removed_callback_.Run(object_path, interfaces);
}
@@ -78,7 +78,7 @@
const DBusObjectsWithProperties &objects_with_properties,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
shill::Error error;
CellularError::FromDBusError(dberror, &error);
std::unique_ptr<ManagedObjectsCallback> callback(
diff --git a/dbus_properties.cc b/dbus_properties.cc
index f7406d7..7f8456c 100644
--- a/dbus_properties.cc
+++ b/dbus_properties.cc
@@ -14,6 +14,10 @@
namespace shill {
+namespace Logging {
+static string ObjectID(DBusProperties *d) { return "(dbus_properties)"; }
+}
+
namespace {
template <typename ValueType>
@@ -24,15 +28,16 @@
DBusPropertiesMap::const_iterator it = properties.find(key);
if (it == properties.end()) {
- SLOG(DBus, 2) << "Key '" << key << "' not found.";
+ SLOG(DBus, nullptr, 2) << "Key '" << key << "' not found.";
return false;
}
string actual_type = it->second.signature();
string expected_type = DBus::type<ValueType>::sig();
if (actual_type != expected_type) {
- SLOG(DBus, 2) << "Key '" << key << "' type mismatch (expected '"
- << expected_type << "', actual '" << actual_type << "').";
+ SLOG(DBus, nullptr, 2) << "Key '" << key << "' type mismatch (expected '"
+ << expected_type << "', actual '" << actual_type
+ << "').";
return false;
}
diff --git a/dbus_properties_proxy.cc b/dbus_properties_proxy.cc
index 306ddf3..634d1f9 100644
--- a/dbus_properties_proxy.cc
+++ b/dbus_properties_proxy.cc
@@ -11,6 +11,11 @@
using std::string;
using std::vector;
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p; }
+}
+
DBusPropertiesProxy::DBusPropertiesProxy(DBus::Connection *connection,
const string &path,
const string &service)
@@ -19,7 +24,7 @@
DBusPropertiesProxy::~DBusPropertiesProxy() {}
DBusPropertiesMap DBusPropertiesProxy::GetAll(const string &interface_name) {
- SLOG(DBus, 2) << __func__ << "(" << interface_name << ")";
+ SLOG(&proxy_.path(), 2) << __func__ << "(" << interface_name << ")";
try {
return proxy_.GetAll(interface_name);
} catch (const DBus::Error &e) {
@@ -31,7 +36,7 @@
DBus::Variant DBusPropertiesProxy::Get(const string &interface_name,
const string &property) {
- SLOG(DBus, 2) << __func__ << "(" << interface_name << ", "
+ SLOG(&proxy_.path(), 2) << __func__ << "(" << interface_name << ", "
<< property << ")";
try {
return proxy_.Get(interface_name, property);
@@ -63,7 +68,7 @@
void DBusPropertiesProxy::Proxy::MmPropertiesChanged(
const string &interface,
const DBusPropertiesMap &properties) {
- SLOG(DBus, 2) << __func__ << "(" << interface << ")";
+ SLOG(&path(), 2) << __func__ << "(" << interface << ")";
mm_properties_changed_callback_.Run(interface, properties);
}
@@ -71,7 +76,7 @@
const string &interface,
const DBusPropertiesMap &changed_properties,
const vector<string> &invalidated_properties) {
- SLOG(DBus, 2) << __func__ << "(" << interface << ")";
+ SLOG(&path(), 2) << __func__ << "(" << interface << ")";
properties_changed_callback_.Run(
interface, changed_properties, invalidated_properties);
}
diff --git a/device.cc b/device.cc
index de06b48..776fbb5 100644
--- a/device.cc
+++ b/device.cc
@@ -55,6 +55,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDevice;
+static string ObjectID(Device *d) { return d->GetRpcIdentifier(); }
+}
+
// static
const char Device::kIPFlagTemplate[] = "/proc/sys/net/%s/conf/%s/%s";
// static
@@ -190,15 +195,15 @@
}
void Device::LinkEvent(unsigned flags, unsigned change) {
- SLOG(Device, 2) << "Device " << link_name_
- << std::showbase << std::hex
- << " flags " << flags << " changed " << change
- << std::dec << std::noshowbase;
+ SLOG(this, 2) << "Device " << link_name_
+ << std::showbase << std::hex
+ << " flags " << flags << " changed " << change
+ << std::dec << std::noshowbase;
}
void Device::Scan(ScanType scan_type, Error *error, const string &reason) {
- SLOG(Device, 2) << __func__ << " [Device] on " << link_name() << " from "
- << reason;
+ SLOG(this, 2) << __func__ << " [Device] on " << link_name() << " from "
+ << reason;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support scan.");
}
@@ -212,14 +217,14 @@
void Device::RequirePIN(
const string &/*pin*/, bool /*require*/,
Error *error, const ResultCallback &/*callback*/) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support RequirePIN.");
}
void Device::EnterPIN(const string &/*pin*/,
Error *error, const ResultCallback &/*callback*/) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support EnterPIN.");
}
@@ -227,7 +232,7 @@
void Device::UnblockPIN(const string &/*unblock_code*/,
const string &/*pin*/,
Error *error, const ResultCallback &/*callback*/) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support UnblockPIN.");
}
@@ -235,20 +240,20 @@
void Device::ChangePIN(const string &/*old_pin*/,
const string &/*new_pin*/,
Error *error, const ResultCallback &/*callback*/) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support ChangePIN.");
}
void Device::Reset(Error *error, const ResultCallback &/*callback*/) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support Reset.");
}
void Device::SetCarrier(const string &/*carrier*/,
Error *error, const ResultCallback &/*callback*/) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error::PopulateAndLog(error, Error::kNotSupported,
"Device doesn't support SetCarrier.");
}
@@ -258,12 +263,12 @@
}
void Device::DisableIPv6() {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
SetIPFlag(IPAddress::kFamilyIPv6, kIPFlagDisableIPv6, "1");
}
void Device::EnableIPv6() {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!IsIPv6Allowed()) {
LOG(INFO) << "Skip enabling IPv6 on " << link_name_
<< " as it is not allowed.";
@@ -378,7 +383,7 @@
void Device::OnAfterResume() {
if (ipconfig_) {
- SLOG(Device, 3) << "Renewing IP address on resume.";
+ SLOG(this, 3) << "Renewing IP address on resume.";
ipconfig_->RenewIP();
}
if (ip6config_) {
@@ -389,7 +394,7 @@
UpdateIPConfigsProperty();
}
if (link_monitor_) {
- SLOG(Device, 3) << "Informing Link Monitor of resume.";
+ SLOG(this, 3) << "Informing Link Monitor of resume.";
link_monitor_->OnAfterResume();
}
// Resume from sleep, could be in different location now.
@@ -403,7 +408,7 @@
}
void Device::DropConnection() {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
DestroyIPConfig();
SelectService(nullptr);
}
@@ -446,8 +451,8 @@
} else if (properties.address == ip6config_->properties().address &&
properties.subnet_prefix ==
ip6config_->properties().subnet_prefix) {
- SLOG(Device, 2) << __func__ << " primary address for "
- << link_name_ << " is unchanged.";
+ SLOG(this, 2) << __func__ << " primary address for "
+ << link_name_ << " is unchanged.";
return;
}
@@ -499,8 +504,8 @@
// Done if no change in server addresses.
if (ip6config_->properties().dns_servers == addresses_str) {
- SLOG(Device, 2) << __func__ << " IPv6 DNS server list for "
- << link_name_ << " is unchanged.";
+ SLOG(this, 2) << __func__ << " IPv6 DNS server list for "
+ << link_name_ << " is unchanged.";
return;
}
@@ -643,15 +648,15 @@
}
void Device::ConfigureStaticIPTask() {
- SLOG(Device, 2) << __func__ << " selected_service " << selected_service_.get()
- << " ipconfig " << ipconfig_.get();
+ SLOG(this, 2) << __func__ << " selected_service " << selected_service_.get()
+ << " ipconfig " << ipconfig_.get();
if (!selected_service_ || !ipconfig_) {
return;
}
if (IsUsingStaticIP()) {
- SLOG(Device, 2) << __func__ << " " << " configuring static IP parameters.";
+ SLOG(this, 2) << __func__ << " " << " configuring static IP parameters.";
// If the parameters contain an IP address, apply them now and bring
// the interface up. When DHCP information arrives, it will supplement
// the static information.
@@ -661,7 +666,7 @@
// we're being called by OnIPConfigRefreshed(). In either case a
// DHCP client has been started, and will take care of calling
// OnIPConfigUpdated() when it completes.
- SLOG(Device, 2) << __func__ << " " << " no static IP address.";
+ SLOG(this, 2) << __func__ << " " << " no static IP address.";
}
}
@@ -718,7 +723,7 @@
}
void Device::OnIPConfigUpdated(const IPConfigRefPtr &ipconfig) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (selected_service_) {
ipconfig->ApplyStaticIPParameters(
selected_service_->mutable_static_ip_parameters());
@@ -738,7 +743,7 @@
}
void Device::OnIPConfigFailed(const IPConfigRefPtr &ipconfig) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
// TODO(pstew): This logic gets yet more complex when multiple
// IPConfig types are run in parallel (e.g. DHCP and DHCP6)
if (selected_service_) {
@@ -822,7 +827,7 @@
}
void Device::CreateConnection() {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!connection_.get()) {
connection_ = new Connection(interface_index_,
link_name_,
@@ -832,20 +837,20 @@
}
void Device::DestroyConnection() {
- SLOG(Device, 2) << __func__ << " on " << link_name_;
+ SLOG(this, 2) << __func__ << " on " << link_name_;
StopAllActivities();
if (selected_service_.get()) {
- SLOG(Device, 3) << "Clearing connection of service "
- << selected_service_->unique_name();
+ SLOG(this, 3) << "Clearing connection of service "
+ << selected_service_->unique_name();
selected_service_->SetConnection(nullptr);
}
connection_ = nullptr;
}
void Device::SelectService(const ServiceRefPtr &service) {
- SLOG(Device, 2) << __func__ << ": service "
- << (service ? service->unique_name() : "*reset*")
- << " on " << link_name_;
+ SLOG(this, 2) << __func__ << ": service "
+ << (service ? service->unique_name() : "*reset*")
+ << " on " << link_name_;
if (selected_service_.get() == service.get()) {
// No change to |selected_service_|. Return early to avoid
@@ -900,8 +905,8 @@
}
FilePath flag_file(StringPrintf(kIPFlagTemplate, ip_version.c_str(),
link_name_.c_str(), flag.c_str()));
- SLOG(Device, 2) << "Writing " << value << " to flag file "
- << flag_file.value();
+ SLOG(this, 2) << "Writing " << value << " to flag file "
+ << flag_file.value();
if (base::WriteFile(flag_file, value.c_str(), value.length()) != 1) {
LOG(ERROR) << StringPrintf("IP flag write failed: %s to %s",
value.c_str(), flag_file.value().c_str());
@@ -929,32 +934,34 @@
bool Device::RequestPortalDetection() {
if (!selected_service_) {
- SLOG(Device, 2) << FriendlyName()
- << ": No selected service, so no need for portal check.";
+ SLOG(this, 2) << FriendlyName()
+ << ": No selected service, so no need for portal check.";
return false;
}
if (!connection_.get()) {
- SLOG(Device, 2) << FriendlyName()
- << ": No connection, so no need for portal check.";
+ SLOG(this, 2) << FriendlyName()
+ << ": No connection, so no need for portal check.";
return false;
}
if (selected_service_->state() != Service::kStatePortal) {
- SLOG(Device, 2) << FriendlyName()
- << ": Service is not in portal state. No need to start check.";
+ SLOG(this, 2) << FriendlyName()
+ << ": Service is not in portal state. "
+ << "No need to start check.";
return false;
}
if (!connection_->is_default()) {
- SLOG(Device, 2) << FriendlyName()
- << ": Service is not the default connection. Don't start check.";
+ SLOG(this, 2) << FriendlyName()
+ << ": Service is not the default connection. "
+ << "Don't start check.";
return false;
}
if (portal_detector_.get() && portal_detector_->IsInProgress()) {
- SLOG(Device, 2) << FriendlyName()
- << ": Portal detection is already running.";
+ SLOG(this, 2) << FriendlyName()
+ << ": Portal detection is already running.";
return true;
}
@@ -964,9 +971,9 @@
bool Device::StartPortalDetection() {
DCHECK(selected_service_);
if (selected_service_->IsPortalDetectionDisabled()) {
- SLOG(Device, 2) << "Service " << selected_service_->unique_name()
- << ": Portal detection is disabled; "
- << "marking service online.";
+ SLOG(this, 2) << "Service " << selected_service_->unique_name()
+ << ": Portal detection is disabled; "
+ << "marking service online.";
SetServiceConnectedState(Service::kStateOnline);
return false;
}
@@ -975,9 +982,9 @@
!manager_->IsPortalDetectionEnabled(technology())) {
// If portal detection is disabled for this technology, immediately set
// the service state to "Online".
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Portal detection is disabled; "
- << "marking service online.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Portal detection is disabled; "
+ << "marking service online.";
SetServiceConnectedState(Service::kStateOnline);
return false;
}
@@ -986,8 +993,8 @@
// Services with HTTP proxy configurations should not be checked by the
// connection manager, since we don't have the ability to evaluate
// arbitrary proxy configs and their possible credentials.
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Service has proxy config; marking it online.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Service has proxy config; marking it online.";
SetServiceConnectedState(Service::kStateOnline);
return false;
}
@@ -1003,14 +1010,14 @@
return false;
}
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Portal detection has started.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Portal detection has started.";
return true;
}
void Device::StopPortalDetection() {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Portal detection stopping.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Portal detection stopping.";
portal_detector_.reset();
}
@@ -1025,8 +1032,8 @@
}
void Device::StopConnectivityTest() {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Connectivity test stopping.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Connectivity test stopping.";
connection_tester_.reset();
}
@@ -1036,14 +1043,14 @@
bool Device::StartLinkMonitor() {
if (!manager_->IsTechnologyLinkMonitorEnabled(technology())) {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Link Monitoring is disabled.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Link Monitoring is disabled.";
return false;
}
if (selected_service_ && selected_service_->link_monitor_disabled()) {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Link Monitoring is disabled for the selected service";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Link Monitoring is disabled for the selected service";
return false;
}
@@ -1056,14 +1063,14 @@
weak_ptr_factory_.GetWeakPtr())));
}
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Link Monitor starting.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Link Monitor starting.";
return link_monitor_->Start();
}
void Device::StopLinkMonitor() {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Link Monitor stopping.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Link Monitor stopping.";
link_monitor_.reset();
}
@@ -1073,8 +1080,8 @@
}
void Device::OnLinkMonitorFailure() {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Link Monitor indicates failure.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Link Monitor indicates failure.";
if (!selected_service_) {
return;
}
@@ -1190,8 +1197,8 @@
return;
}
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Traffic Monitor starting.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Traffic Monitor starting.";
if (!traffic_monitor_.get()) {
traffic_monitor_.reset(new TrafficMonitor(this, dispatcher_));
traffic_monitor_->set_network_problem_detected_callback(
@@ -1208,8 +1215,8 @@
}
if (traffic_monitor_.get()) {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Traffic Monitor stopping.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Traffic Monitor stopping.";
traffic_monitor_->Stop();
}
traffic_monitor_.reset();
@@ -1265,11 +1272,11 @@
portal_detector_.reset();
return;
}
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Portal detection retrying.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Portal detection retrying.";
} else {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Portal will not retry.";
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Portal will not retry.";
portal_detector_.reset();
}
@@ -1278,17 +1285,17 @@
void Device::PortalDetectorCallback(const PortalDetector::Result &result) {
if (!result.final) {
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Received non-final status: "
- << ConnectivityTrial::StatusToString(
- result.trial_result.status);
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Received non-final status: "
+ << ConnectivityTrial::StatusToString(
+ result.trial_result.status);
return;
}
- SLOG(Device, 2) << "Device " << FriendlyName()
- << ": Received final status: "
- << ConnectivityTrial::StatusToString(
- result.trial_result.status);
+ SLOG(this, 2) << "Device " << FriendlyName()
+ << ": Received final status: "
+ << ConnectivityTrial::StatusToString(
+ result.trial_result.status);
portal_attempts_to_online_ += result.num_attempts;
@@ -1400,10 +1407,10 @@
// callback
void Device::OnEnabledStateChanged(const ResultCallback &callback,
const Error &error) {
- SLOG(Device, 2) << __func__
- << " (target: " << enabled_pending_ << ","
- << " success: " << error.IsSuccess() << ")"
- << " on " << link_name_;
+ SLOG(this, 2) << __func__
+ << " (target: " << enabled_pending_ << ","
+ << " success: " << error.IsSuccess() << ")"
+ << " on " << link_name_;
if (error.IsSuccess()) {
enabled_ = enabled_pending_;
manager_->UpdateEnabledTechnologies();
@@ -1415,7 +1422,7 @@
}
void Device::SetEnabled(bool enable) {
- SLOG(Device, 2) << __func__ << "(" << enable << ")";
+ SLOG(this, 2) << __func__ << "(" << enable << ")";
Error error;
SetEnabledChecked(enable, false, &error, ResultCallback());
@@ -1448,8 +1455,8 @@
Error *error,
const ResultCallback &callback) {
DCHECK(error);
- SLOG(Device, 2) << "Device " << link_name_ << " "
- << (enable ? "starting" : "stopping");
+ SLOG(this, 2) << "Device " << link_name_ << " "
+ << (enable ? "starting" : "stopping");
if (enable == enabled_) {
if (enable != enabled_pending_ && persist) {
// Return an error, as there is an ongoing operation to achieve the
@@ -1493,14 +1500,14 @@
DestroyIPConfig(); // breaks a reference cycle
SelectService(nullptr); // breaks a reference cycle
rtnl_handler_->SetInterfaceFlags(interface_index(), 0, IFF_UP);
- SLOG(Device, 3) << "Device " << link_name_ << " ipconfig_ "
- << (ipconfig_ ? "is set." : "is not set.");
- SLOG(Device, 3) << "Device " << link_name_ << " ip6config_ "
- << (ip6config_ ? "is set." : "is not set.");
- SLOG(Device, 3) << "Device " << link_name_ << " connection_ "
- << (connection_ ? "is set." : "is not set.");
- SLOG(Device, 3) << "Device " << link_name_ << " selected_service_ "
- << (selected_service_ ? "is set." : "is not set.");
+ SLOG(this, 3) << "Device " << link_name_ << " ipconfig_ "
+ << (ipconfig_ ? "is set." : "is not set.");
+ SLOG(this, 3) << "Device " << link_name_ << " ip6config_ "
+ << (ip6config_ ? "is set." : "is not set.");
+ SLOG(this, 3) << "Device " << link_name_ << " connection_ "
+ << (connection_ ? "is set." : "is not set.");
+ SLOG(this, 3) << "Device " << link_name_ << " selected_service_ "
+ << (selected_service_ ? "is set." : "is not set.");
Stop(error, chained_callback);
}
}
diff --git a/device_dbus_adaptor.cc b/device_dbus_adaptor.cc
index 92fb354..309950a 100644
--- a/device_dbus_adaptor.cc
+++ b/device_dbus_adaptor.cc
@@ -17,6 +17,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(DeviceDBusAdaptor *d) { return d->GetRpcIdentifier(); }
+}
+
// static
const char DeviceDBusAdaptor::kPath[] = "/device/";
@@ -39,61 +44,61 @@
}
void DeviceDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
}
void DeviceDBusAdaptor::EmitUintChanged(const string &name,
uint32_t value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
}
void DeviceDBusAdaptor::EmitUint16Changed(const string &name, uint16_t value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Uint16ToVariant(value));
}
void DeviceDBusAdaptor::EmitIntChanged(const string &name, int value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
}
void DeviceDBusAdaptor::EmitStringChanged(const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::StringToVariant(value));
}
void DeviceDBusAdaptor::EmitStringmapChanged(const string &name,
const Stringmap &value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::StringmapToVariant(value));
}
void DeviceDBusAdaptor::EmitStringmapsChanged(const string &name,
const Stringmaps &value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::StringmapsToVariant(value));
}
void DeviceDBusAdaptor::EmitStringsChanged(const string &name,
const Strings &value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::StringsToVariant(value));
}
void DeviceDBusAdaptor::EmitKeyValueStoreChanged(const string &name,
const KeyValueStore &value) {
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
PropertyChanged(name, DBusAdaptor::KeyValueStoreToVariant(value));
}
@@ -101,7 +106,7 @@
void DeviceDBusAdaptor::EmitRpcIdentifierArrayChanged(
const string &name,
const vector<string> &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
vector<DBus::Path> paths;
for (const auto &element : value) {
paths.push_back(element);
@@ -112,7 +117,7 @@
map<string, DBus::Variant> DeviceDBusAdaptor::GetProperties(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << " " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << " " << device_->UniqueName();
map<string, DBus::Variant> properties;
DBusAdaptor::GetProperties(device_->store(), &properties, &error);
return properties;
@@ -121,20 +126,20 @@
void DeviceDBusAdaptor::SetProperty(const string &name,
const DBus::Variant &value,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
DBusAdaptor::SetProperty(device_->mutable_store(), name, value, &error);
}
void DeviceDBusAdaptor::ClearProperty(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " " << name;
DBusAdaptor::ClearProperty(device_->mutable_store(), name, &error);
}
void DeviceDBusAdaptor::Enable(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->SetEnabledPersistent(true, &e, GetMethodReplyCallback(tag));
@@ -142,7 +147,7 @@
}
void DeviceDBusAdaptor::Disable(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->SetEnabledPersistent(false, &e, GetMethodReplyCallback(tag));
@@ -150,7 +155,7 @@
}
void DeviceDBusAdaptor::ProposeScan(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e;
// User scan requests, which are the likely source of DBus requests, probably
// aren't time-critical so we might as well perform a complete scan. It
@@ -161,7 +166,7 @@
DBus::Path DeviceDBusAdaptor::AddIPConfig(const string &/*method*/,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e(Error::kNotSupported, "This function is deprecated in shill");
e.ToDBusError(&error);
return "/";
@@ -169,7 +174,7 @@
void DeviceDBusAdaptor::Register(const string &network_id,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< " (" << network_id << ")";
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
@@ -179,7 +184,7 @@
void DeviceDBusAdaptor::RequirePin(
const string &pin, const bool &require, DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->RequirePIN(pin, require, &e, GetMethodReplyCallback(tag));
@@ -188,7 +193,7 @@
void DeviceDBusAdaptor::EnterPin(const string &pin,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->EnterPIN(pin, &e, GetMethodReplyCallback(tag));
@@ -198,7 +203,7 @@
void DeviceDBusAdaptor::UnblockPin(const string &unblock_code,
const string &pin,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->UnblockPIN(unblock_code, pin, &e, GetMethodReplyCallback(tag));
@@ -208,7 +213,7 @@
void DeviceDBusAdaptor::ChangePin(const string &old_pin,
const string &new_pin,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->ChangePIN(old_pin, new_pin, &e, GetMethodReplyCallback(tag));
@@ -216,7 +221,7 @@
}
void DeviceDBusAdaptor::Reset(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
device_->Reset(&e, GetMethodReplyCallback(tag));
@@ -226,7 +231,7 @@
string DeviceDBusAdaptor::PerformTDLSOperation(const string &operation,
const string &peer,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName();
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName();
Error e;
string return_value = device_->PerformTDLSOperation(operation, peer, &e);
e.ToDBusError(&error);
@@ -239,7 +244,7 @@
void DeviceDBusAdaptor::SetCarrier(const string &carrier,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Device " << device_->UniqueName()
+ SLOG(this, 2) << __func__ << ": Device " << device_->UniqueName()
<< "(" << carrier << ")";
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
diff --git a/device_info.cc b/device_info.cc
index 2b668fb..dbde3db 100644
--- a/device_info.cc
+++ b/device_info.cc
@@ -62,6 +62,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDevice;
+static string ObjectID(const DeviceInfo *d) { return "(device_info)"; }
+}
+
// static
const char DeviceInfo::kModemPseudoDeviceNamePrefix[] = "pseudomodem";
const char DeviceInfo::kEthernetPseudoDeviceNamePrefix[] = "pseudoethernet";
@@ -161,8 +166,8 @@
}
void DeviceInfo::RegisterDevice(const DeviceRefPtr &device) {
- SLOG(Device, 2) << __func__ << "(" << device->link_name() << ", "
- << device->interface_index() << ")";
+ SLOG(this, 2) << __func__ << "(" << device->link_name() << ", "
+ << device->interface_index() << ")";
delayed_devices_.erase(device->interface_index());
CHECK(!GetDevice(device->interface_index()).get());
infos_[device->interface_index()].device = device;
@@ -180,16 +185,16 @@
void DeviceInfo::DeregisterDevice(const DeviceRefPtr &device) {
int interface_index = device->interface_index();
- SLOG(Device, 2) << __func__ << "(" << device->link_name() << ", "
- << interface_index << ")";
+ SLOG(this, 2) << __func__ << "(" << device->link_name() << ", "
+ << interface_index << ")";
CHECK((device->technology() == Technology::kCellular) ||
(device->technology() == Technology::kWiMax));
// Release reference to the device
map<int, Info>::iterator iter = infos_.find(interface_index);
if (iter != infos_.end()) {
- SLOG(Device, 2) << "Removing device from info for index: "
- << interface_index;
+ SLOG(this, 2) << "Removing device from info for index: "
+ << interface_index;
manager_->DeregisterDevice(device);
// Release the reference to the device, but maintain the mapping
// for the index. That will be cleaned up by an RTNL message.
@@ -237,12 +242,12 @@
// start of the file or after a newline, we can safely assume this
// is a wifi device.
if (contents.find(kInterfaceUeventWifiSignature) != string::npos) {
- SLOG(Device, 2)
+ SLOG(this, 2)
<< StringPrintf("%s: device %s has wifi signature in uevent file",
__func__, iface_name.c_str());
if (arp_type == ARPHRD_IEEE80211_RADIOTAP) {
- SLOG(Device, 2) << StringPrintf("%s: wifi device %s is in monitor mode",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: wifi device %s is in monitor mode",
+ __func__, iface_name.c_str());
return Technology::kWiFiMonitor;
}
return Technology::kWifi;
@@ -250,7 +255,7 @@
// Special case for pseudo modems which are used for testing
if (iface_name.find(kModemPseudoDeviceNamePrefix) == 0) {
- SLOG(Device, 2) << StringPrintf(
+ SLOG(this, 2) << StringPrintf(
"%s: device %s is a pseudo modem for testing",
__func__, iface_name.c_str());
return Technology::kCellular;
@@ -258,7 +263,7 @@
// Special case for pseudo ethernet devices which are used for testing.
if (iface_name.find(kEthernetPseudoDeviceNamePrefix) == 0) {
- SLOG(Device, 2) << StringPrintf(
+ SLOG(this, 2) << StringPrintf(
"%s: device %s is a virtual ethernet device for testing",
__func__, iface_name.c_str());
return Technology::kEthernet;
@@ -266,16 +271,16 @@
FilePath driver_path;
if (!GetDeviceInfoSymbolicLink(iface_name, kInterfaceDriver, &driver_path)) {
- SLOG(Device, 2) << StringPrintf("%s: device %s has no device symlink",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s has no device symlink",
+ __func__, iface_name.c_str());
if (arp_type == ARPHRD_LOOPBACK) {
- SLOG(Device, 2) << StringPrintf("%s: device %s is a loopback device",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s is a loopback device",
+ __func__, iface_name.c_str());
return Technology::kLoopback;
}
if (arp_type == ARPHRD_PPP) {
- SLOG(Device, 2) << StringPrintf("%s: device %s is a ppp device",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s is a ppp device",
+ __func__, iface_name.c_str());
return Technology::kPPP;
}
string tun_flags_str;
@@ -284,16 +289,16 @@
base::TrimString(tun_flags_str, "\n", &tun_flags_str) &&
base::HexStringToInt(tun_flags_str, &tun_flags) &&
(tun_flags & IFF_TUN)) {
- SLOG(Device, 2) << StringPrintf("%s: device %s is tun device",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s is tun device",
+ __func__, iface_name.c_str());
return Technology::kTunnel;
}
// We don't know what sort of device it is. Act the same as if there
// was a driver symlink, but we did not recognize the driver name.
- SLOG(Device, 2) << StringPrintf("%s: device %s, without driver name "
- "is defaulted to type ethernet",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s, without driver name "
+ "is defaulted to type ethernet",
+ __func__, iface_name.c_str());
return Technology::kEthernet;
}
@@ -302,7 +307,7 @@
for (size_t modem_idx = 0; modem_idx < arraysize(kModemDrivers);
++modem_idx) {
if (driver_name == kModemDrivers[modem_idx]) {
- SLOG(Device, 2)
+ SLOG(this, 2)
<< StringPrintf("%s: device %s is matched with modem driver %s",
__func__, iface_name.c_str(), driver_name.c_str());
return Technology::kCellular;
@@ -310,8 +315,8 @@
}
if (driver_name == kDriverGdmWiMax) {
- SLOG(Device, 2) << StringPrintf("%s: device %s is a WiMAX device",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s is a WiMAX device",
+ __func__, iface_name.c_str());
return Technology::kWiMax;
}
@@ -323,23 +328,23 @@
iface_name.c_str(), driver_name.c_str());
return Technology::kCellular;
}
- SLOG(Device, 2) << StringPrintf("%s: device %s is a %s device", __func__,
- iface_name.c_str(), driver_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s is a %s device", __func__,
+ iface_name.c_str(), driver_name.c_str());
return Technology::kCDCEthernet;
}
// Special case for the virtio driver, used when run under KVM. See also
// the comment in VirtioEthernet::Start.
if (driver_name == kDriverVirtioNet) {
- SLOG(Device, 2) << StringPrintf("%s: device %s is virtio ethernet",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s is virtio ethernet",
+ __func__, iface_name.c_str());
return Technology::kVirtioEthernet;
}
- SLOG(Device, 2) << StringPrintf("%s: device %s, with driver %s, "
- "is defaulted to type ethernet",
- __func__, iface_name.c_str(),
- driver_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s, with driver %s, "
+ "is defaulted to type ethernet",
+ __func__, iface_name.c_str(),
+ driver_name.c_str());
return Technology::kEthernet;
}
@@ -373,8 +378,8 @@
FilePath device_file = GetDeviceInfoPath(iface_name, kInterfaceDevice);
FilePath device_path;
if (!base::ReadSymbolicLink(device_file, &device_path)) {
- SLOG(Device, 2) << StringPrintf("%s: device %s has no device symlink",
- __func__, iface_name.c_str());
+ SLOG(this, 2) << StringPrintf("%s: device %s has no device symlink",
+ __func__, iface_name.c_str());
return false;
}
if (!device_path.IsAbsolute()) {
@@ -420,9 +425,9 @@
return nullptr;
#else
// Cellular devices are managed by ModemInfo.
- SLOG(Device, 2) << "Cellular link " << link_name
- << " at index " << interface_index
- << " -- notifying ModemInfo.";
+ SLOG(this, 2) << "Cellular link " << link_name
+ << " at index " << interface_index
+ << " -- notifying ModemInfo.";
// The MAC address provided by RTNL is not reliable for Gobi 2K modems.
// Clear it here, and it will be fetched from the kernel in
@@ -454,9 +459,9 @@
return nullptr;
#else
// WiMax devices are managed by WiMaxProvider.
- SLOG(Device, 2) << "WiMax link " << link_name
- << " at index " << interface_index
- << " -- notifying WiMaxProvider.";
+ SLOG(this, 2) << "WiMax link " << link_name
+ << " at index " << interface_index
+ << " -- notifying WiMaxProvider.";
// The MAC address provided by RTNL may not be the final value as the
// WiMAX device may change the address after initialization. Clear it
// here, and it will be fetched from the kernel when
@@ -473,23 +478,23 @@
// Since CreateDevice is only called once in the lifetime of an
// interface index, this notification will only occur the first
// time the device is seen.
- SLOG(Device, 2) << "Tunnel / PPP link " << link_name
- << " at index " << interface_index
- << " -- notifying VPNProvider.";
+ SLOG(this, 2) << "Tunnel / PPP link " << link_name
+ << " at index " << interface_index
+ << " -- notifying VPNProvider.";
if (!manager_->vpn_provider()->OnDeviceInfoAvailable(link_name,
interface_index) &&
technology == Technology::kTunnel) {
// If VPN does not know anything about this tunnel, it is probably
// left over from a previous instance and should not exist.
- SLOG(Device, 2) << "Tunnel link is unused. Deleting.";
+ SLOG(this, 2) << "Tunnel link is unused. Deleting.";
DeleteInterface(interface_index);
}
break;
case Technology::kLoopback:
// Loopback devices are largely ignored, but we should make sure the
// link is enabled.
- SLOG(Device, 2) << "Bringing up loopback device " << link_name
- << " at index " << interface_index;
+ SLOG(this, 2) << "Bringing up loopback device " << link_name
+ << " at index " << interface_index;
rtnl_handler_->SetInterfaceFlags(interface_index, IFF_UP, IFF_UP);
return nullptr;
case Technology::kCDCEthernet:
@@ -531,11 +536,11 @@
unsigned int change = msg.link_status().change;
bool new_device =
!ContainsKey(infos_, dev_index) || infos_[dev_index].has_addresses_only;
- SLOG(Device, 2) << __func__ << "(index=" << dev_index
- << std::showbase << std::hex
- << ", flags=" << flags << ", change=" << change << ")"
- << std::dec << std::noshowbase
- << ", new_device=" << new_device;
+ SLOG(this, 2) << __func__ << "(index=" << dev_index
+ << std::showbase << std::hex
+ << ", flags=" << flags << ", change=" << change << ")"
+ << std::dec << std::noshowbase
+ << ", new_device=" << new_device;
infos_[dev_index].has_addresses_only = false;
infos_[dev_index].flags = flags;
@@ -550,7 +555,7 @@
}
ByteString b(msg.GetAttribute(IFLA_IFNAME));
string link_name(reinterpret_cast<const char*>(b.GetConstData()));
- SLOG(Device, 2) << "add link index " << dev_index << " name " << link_name;
+ SLOG(this, 2) << "add link index " << dev_index << " name " << link_name;
infos_[dev_index].name = link_name;
indices_[link_name] = dev_index;
@@ -566,8 +571,8 @@
infos_[dev_index].mac_address = msg.GetAttribute(IFLA_ADDRESS);
address =
base::StringToLowerASCII(infos_[dev_index].mac_address.HexEncode());
- SLOG(Device, 2) << "link index " << dev_index << " address "
- << infos_[dev_index].mac_address.HexEncode();
+ SLOG(this, 2) << "link index " << dev_index << " address "
+ << infos_[dev_index].mac_address.HexEncode();
} else if (technology != Technology::kTunnel &&
technology != Technology::kPPP) {
LOG(ERROR) << "Add Link message for link '" << link_name
@@ -586,12 +591,12 @@
}
void DeviceInfo::DelLinkMsgHandler(const RTNLMessage &msg) {
- SLOG(Device, 2) << __func__ << "(index=" << msg.interface_index() << ")";
+ SLOG(this, 2) << __func__ << "(index=" << msg.interface_index() << ")";
DCHECK(msg.type() == RTNLMessage::kTypeLink &&
msg.mode() == RTNLMessage::kModeDelete);
- SLOG(Device, 2) << __func__ << "(index=" << msg.interface_index()
- << std::showbase << std::hex
+ SLOG(this, 2) << __func__ << "(index=" << msg.interface_index()
+ << std::showbase << std::hex
<< ", flags=" << msg.link_status().flags
<< ", change=" << msg.link_status().change << ")";
RemoveInfo(msg.interface_index());
@@ -716,7 +721,7 @@
}
void DeviceInfo::FlushAddresses(int interface_index) const {
- SLOG(Device, 2) << __func__ << "(" << interface_index << ")";
+ SLOG(this, 2) << __func__ << "(" << interface_index << ")";
const Info *info = GetInfo(interface_index);
if (!info) {
return;
@@ -725,9 +730,9 @@
if (address_info.address.family() == IPAddress::kFamilyIPv4 ||
(address_info.scope == RT_SCOPE_UNIVERSE &&
(address_info.flags & ~IFA_F_TEMPORARY) == 0)) {
- SLOG(Device, 2) << __func__ << ": removing ip address "
- << address_info.address.ToString()
- << " from interface " << interface_index;
+ SLOG(this, 2) << __func__ << ": removing ip address "
+ << address_info.address.ToString()
+ << " from interface " << interface_index;
rtnl_handler_->RemoveInterfaceAddress(interface_index,
address_info.address);
}
@@ -736,7 +741,7 @@
bool DeviceInfo::HasOtherAddress(
int interface_index, const IPAddress &this_address) const {
- SLOG(Device, 3) << __func__ << "(" << interface_index << ")";
+ SLOG(this, 3) << __func__ << "(" << interface_index << ")";
const Info *info = GetInfo(interface_index);
if (!info) {
return false;
@@ -818,7 +823,7 @@
bool DeviceInfo::HasDirectConnectivityTo(
int interface_index, const IPAddress &address) const {
- SLOG(Device, 3) << __func__ << "(" << interface_index << ")";
+ SLOG(this, 3) << __func__ << "(" << interface_index << ")";
const Info *info = GetInfo(interface_index);
if (!info) {
return false;
@@ -896,7 +901,7 @@
void DeviceInfo::RemoveInfo(int interface_index) {
map<int, Info>::iterator iter = infos_.find(interface_index);
if (iter != infos_.end()) {
- SLOG(Device, 2) << "Removing info for device index: " << interface_index;
+ SLOG(this, 2) << "Removing info for device index: " << interface_index;
// Deregister the device if not deregistered yet. Cellular and WiMax devices
// are deregistered through a call to DeviceInfo::DeregisterDevice.
if (iter->second.device.get()) {
@@ -907,8 +912,8 @@
infos_.erase(iter);
delayed_devices_.erase(interface_index);
} else {
- SLOG(Device, 2) << __func__ << ": Unknown device index: "
- << interface_index;
+ SLOG(this, 2) << __func__ << ": Unknown device index: "
+ << interface_index;
}
}
@@ -924,12 +929,12 @@
}
void DeviceInfo::AddressMsgHandler(const RTNLMessage &msg) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
DCHECK(msg.type() == RTNLMessage::kTypeAddress);
int interface_index = msg.interface_index();
if (!ContainsKey(infos_, interface_index)) {
- SLOG(Device, 2) << "Got advance address information for unknown index "
- << interface_index;
+ SLOG(this, 2) << "Got advance address information for unknown index "
+ << interface_index;
infos_[interface_index].has_addresses_only = true;
}
const RTNLMessage::AddressStatus &status = msg.address_status();
@@ -950,7 +955,7 @@
}
if (iter != address_list.end()) {
if (msg.mode() == RTNLMessage::kModeDelete) {
- SLOG(Device, 2) << "Delete address for interface " << interface_index;
+ SLOG(this, 2) << "Delete address for interface " << interface_index;
address_list.erase(iter);
} else {
iter->flags = status.flags;
@@ -958,8 +963,8 @@
}
} else if (msg.mode() == RTNLMessage::kModeAdd) {
address_list.push_back(AddressData(address, status.flags, status.scope));
- SLOG(Device, 2) << "Add address " << address.ToString()
- << " for interface " << interface_index;
+ SLOG(this, 2) << "Add address " << address.ToString()
+ << " for interface " << interface_index;
}
DeviceRefPtr device = GetDevice(interface_index);
@@ -970,12 +975,12 @@
}
void DeviceInfo::RdnssMsgHandler(const RTNLMessage &msg) {
- SLOG(Device, 2) << __func__;
+ SLOG(this, 2) << __func__;
DCHECK(msg.type() == RTNLMessage::kTypeRdnss);
int interface_index = msg.interface_index();
if (!ContainsKey(infos_, interface_index)) {
- SLOG(Device, 2) << "Got RDNSS option for unknown index "
- << interface_index;
+ SLOG(this, 2) << "Got RDNSS option for unknown index "
+ << interface_index;
}
const RTNLMessage::RdnssOption &rdnss_option = msg.rdnss_option();
@@ -1050,10 +1055,10 @@
}
memcpy(&stats, stats_bytes.GetConstData(), sizeof(stats));
- SLOG(Device, 2) << "Link statistics for "
- << " interface index " << interface_index << ": "
- << "receive: " << stats.rx_bytes << "; "
- << "transmit: " << stats.tx_bytes << ".";
+ SLOG(this, 2) << "Link statistics for "
+ << " interface index " << interface_index << ": "
+ << "receive: " << stats.rx_bytes << "; "
+ << "transmit: " << stats.tx_bytes << ".";
infos_[interface_index].rx_bytes = stats.rx_bytes;
infos_[interface_index].tx_bytes = stats.tx_bytes;
}
diff --git a/dhcp_config.cc b/dhcp_config.cc
index 824cd71..d580478 100644
--- a/dhcp_config.cc
+++ b/dhcp_config.cc
@@ -30,6 +30,16 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDHCP;
+static string ObjectID(DHCPConfig *d) {
+ if (d == nullptr)
+ return "(dhcp_config)";
+ else
+ return d->device_name();
+}
+}
+
// static
const int DHCPConfig::kAcquisitionTimeoutSeconds = 30;
const char DHCPConfig::kConfigurationKeyBroadcastAddress[] = "BroadcastAddress";
@@ -106,21 +116,21 @@
glib_(glib),
metrics_(metrics),
minijail_(chromeos::Minijail::GetInstance()) {
- SLOG(DHCP, 2) << __func__ << ": " << device_name;
+ SLOG(this, 2) << __func__ << ": " << device_name;
if (lease_file_suffix_.empty()) {
lease_file_suffix_ = device_name;
}
}
DHCPConfig::~DHCPConfig() {
- SLOG(DHCP, 2) << __func__ << ": " << device_name();
+ SLOG(this, 2) << __func__ << ": " << device_name();
// Don't leave behind dhcpcd running.
Stop(__func__);
}
bool DHCPConfig::RequestIP() {
- SLOG(DHCP, 2) << __func__ << ": " << device_name();
+ SLOG(this, 2) << __func__ << ": " << device_name();
if (!pid_) {
return Start();
}
@@ -132,7 +142,7 @@
}
bool DHCPConfig::RenewIP() {
- SLOG(DHCP, 2) << __func__ << ": " << device_name();
+ SLOG(this, 2) << __func__ << ": " << device_name();
if (!pid_) {
return Start();
}
@@ -147,7 +157,7 @@
}
bool DHCPConfig::ReleaseIP(ReleaseReason reason) {
- SLOG(DHCP, 2) << __func__ << ": " << device_name();
+ SLOG(this, 2) << __func__ << ": " << device_name();
if (!pid_) {
return true;
}
@@ -222,7 +232,7 @@
}
void DHCPConfig::ProcessStatusChangeSignal(const string &status) {
- SLOG(DHCP, 2) << __func__ << ": " << status;
+ SLOG(this, 2) << __func__ << ": " << status;
if (status == kStatusArpGateway) {
metrics_->NotifyDhcpClientStatus(Metrics::kDhcpClientStatusArpGateway);
@@ -284,7 +294,7 @@
}
bool DHCPConfig::Start() {
- SLOG(DHCP, 2) << __func__ << ": " << device_name();
+ SLOG(this, 2) << __func__ << ": " << device_name();
// TODO(quiche): This should be migrated to use ExternalTask.
// (crbug.com/246263).
@@ -426,7 +436,7 @@
if (destination.prefix() == 0 && properties->gateway.empty()) {
// If a default route is provided in the classless parameters and
// we don't already have one, apply this as the default route.
- SLOG(DHCP, 2) << "In " << __func__ << ": Setting default gateway to "
+ SLOG(nullptr, 2) << "In " << __func__ << ": Setting default gateway to "
<< gateway_as_string;
CHECK(gateway.IntoString(&properties->gateway));
} else {
@@ -437,7 +447,7 @@
CHECK(netmask.IntoString(&route.netmask));
CHECK(gateway.IntoString(&route.gateway));
routes.push_back(route);
- SLOG(DHCP, 2) << "In " << __func__ << ": Adding route to to "
+ SLOG(nullptr, 2) << "In " << __func__ << ": Adding route to to "
<< destination_as_string << " via " << gateway_as_string;
}
}
@@ -452,7 +462,7 @@
// static
bool DHCPConfig::ParseConfiguration(const Configuration &configuration,
IPConfig::Properties *properties) {
- SLOG(DHCP, 2) << __func__;
+ SLOG(nullptr, 2) << __func__;
properties->method = kTypeDHCP;
properties->address_family = IPAddress::kFamilyIPv4;
string classless_static_routes;
@@ -461,7 +471,7 @@
it != configuration.end(); ++it) {
const string &key = it->first;
const DBus::Variant &value = it->second;
- SLOG(DHCP, 2) << "Processing key: " << key;
+ SLOG(nullptr, 2) << "Processing key: " << key;
if (key == kConfigurationKeyIPAddress) {
properties->address = GetIPv4AddressString(value.reader().get_uint32());
if (properties->address.empty()) {
@@ -515,7 +525,7 @@
} else if (key == kConfigurationKeyLeaseTime) {
properties->lease_duration_seconds = value.reader().get_uint32();
} else {
- SLOG(DHCP, 2) << "Key ignored.";
+ SLOG(nullptr, 2) << "Key ignored.";
}
}
ParseClasslessStaticRoutes(classless_static_routes, properties);
@@ -527,7 +537,7 @@
void DHCPConfig::ChildWatchCallback(GPid pid, gint status, gpointer data) {
if (status == EXIT_SUCCESS) {
- SLOG(DHCP, 2) << "pid " << pid << " exit status " << status;
+ SLOG(nullptr, 2) << "pid " << pid << " exit status " << status;
} else {
LOG(WARNING) << "pid " << pid << " exit status " << status;
}
@@ -539,7 +549,7 @@
}
void DHCPConfig::CleanupClientState() {
- SLOG(DHCP, 2) << __func__ << ": " << device_name();
+ SLOG(this, 2) << __func__ << ": " << device_name();
StopAcquisitionTimeout();
StopExpirationTimeout();
if (child_watch_tag_) {
@@ -590,7 +600,7 @@
void DHCPConfig::StartExpirationTimeout(uint32_t lease_duration_seconds) {
CHECK(lease_acquisition_timeout_callback_.IsCancelled());
- SLOG(DHCP, 2) << __func__ << ": " << device_name()
+ SLOG(this, 2) << __func__ << ": " << device_name()
<< ": " << "Lease timeout is " << lease_duration_seconds
<< " seconds.";
lease_expiration_callback_.Reset(
diff --git a/dhcp_provider.cc b/dhcp_provider.cc
index 0f6b4b3..f7b3e67 100644
--- a/dhcp_provider.cc
+++ b/dhcp_provider.cc
@@ -18,6 +18,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDHCP;
+static string ObjectID(DHCPProvider *d) { return "(dhcp_provider)"; }
+}
+
namespace {
base::LazyInstance<DHCPProvider> g_dhcp_provider = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -31,11 +36,11 @@
dispatcher_(nullptr),
glib_(nullptr),
metrics_(nullptr) {
- SLOG(DHCP, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
DHCPProvider::~DHCPProvider() {
- SLOG(DHCP, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
DHCPProvider* DHCPProvider::GetInstance() {
@@ -46,7 +51,7 @@
EventDispatcher *dispatcher,
GLib *glib,
Metrics *metrics) {
- SLOG(DHCP, 2) << __func__;
+ SLOG(this, 2) << __func__;
listener_.reset(new DHCPCDListener(proxy_factory_->connection(), this));
glib_ = glib;
control_interface_ = control_interface;
@@ -58,7 +63,7 @@
const string &host_name,
const string &lease_file_suffix,
bool arp_gateway) {
- SLOG(DHCP, 2) << __func__ << " device: " << device_name;
+ SLOG(this, 2) << __func__ << " device: " << device_name;
return new DHCPConfig(control_interface_,
dispatcher_,
this,
@@ -71,7 +76,7 @@
}
DHCPConfigRefPtr DHCPProvider::GetConfig(int pid) {
- SLOG(DHCP, 2) << __func__ << " pid: " << pid;
+ SLOG(this, 2) << __func__ << " pid: " << pid;
PIDConfigMap::const_iterator it = configs_.find(pid);
if (it == configs_.end()) {
return nullptr;
@@ -80,17 +85,17 @@
}
void DHCPProvider::BindPID(int pid, const DHCPConfigRefPtr &config) {
- SLOG(DHCP, 2) << __func__ << " pid: " << pid;
+ SLOG(this, 2) << __func__ << " pid: " << pid;
configs_[pid] = config;
}
void DHCPProvider::UnbindPID(int pid) {
- SLOG(DHCP, 2) << __func__ << " pid: " << pid;
+ SLOG(this, 2) << __func__ << " pid: " << pid;
configs_.erase(pid);
}
void DHCPProvider::DestroyLease(const string &name) {
- SLOG(DHCP, 2) << __func__ << " name: " << name;
+ SLOG(this, 2) << __func__ << " name: " << name;
base::DeleteFile(root_.Append(
base::StringPrintf(kDHCPCDPathFormatLease,
name.c_str())), false);
diff --git a/dhcpcd_proxy.cc b/dhcpcd_proxy.cc
index cc56ad1..e2c0d49 100644
--- a/dhcpcd_proxy.cc
+++ b/dhcpcd_proxy.cc
@@ -17,6 +17,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDHCP;
+static string ObjectID(DHCPCDProxy *d) { return "(dhcpcd_proxy)"; }
+}
+
const char DHCPCDProxy::kDBusInterfaceName[] = "org.chromium.dhcpcd";
const char DHCPCDProxy::kDBusPath[] = "/org/chromium/dhcpcd";
@@ -29,7 +34,7 @@
: DBus::InterfaceProxy(DHCPCDProxy::kDBusInterfaceName),
DBus::ObjectProxy(*connection, DHCPCDProxy::kDBusPath),
provider_(provider) {
- SLOG(DHCP, 2) << __func__;
+ SLOG(DHCP, nullptr, 2) << __func__;
connect_signal(DHCPCDListener::Proxy, Event, EventSignal);
connect_signal(DHCPCDListener::Proxy, StatusChanged, StatusChangedSignal);
}
@@ -37,7 +42,7 @@
DHCPCDListener::Proxy::~Proxy() {}
void DHCPCDListener::Proxy::EventSignal(const DBus::SignalMessage &signal) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
DBus::MessageIter ri = signal.reader();
unsigned int pid = std::numeric_limits<unsigned int>::max();
try {
@@ -47,7 +52,8 @@
<< " interface: " << signal.interface()
<< " member: " << signal.member() << " path: " << signal.path();
}
- SLOG(DHCP, 2) << "sender(" << signal.sender() << ") pid(" << pid << ")";
+ SLOG(DHCP, nullptr, 2) << "sender(" << signal.sender()
+ << ") pid(" << pid << ")";
DHCPConfigRefPtr config = provider_->GetConfig(pid);
if (!config.get()) {
@@ -77,7 +83,7 @@
void DHCPCDListener::Proxy::StatusChangedSignal(
const DBus::SignalMessage &signal) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
DBus::MessageIter ri = signal.reader();
unsigned int pid = std::numeric_limits<unsigned int>::max();
try {
@@ -87,7 +93,8 @@
<< " interface: " << signal.interface()
<< " member: " << signal.member() << " path: " << signal.path();
}
- SLOG(DHCP, 2) << "sender(" << signal.sender() << ") pid(" << pid << ")";
+ SLOG(DHCP, nullptr, 2) << "sender(" << signal.sender()
+ << ") pid(" << pid << ")";
// Accept StatusChanged signals just to get the sender address and create an
// appropriate proxy for the PID/sender pair.
@@ -111,11 +118,11 @@
DHCPCDProxy::DHCPCDProxy(DBus::Connection *connection, const string &service)
: proxy_(connection, service) {
- SLOG(DHCP, 2) << "DHCPCDProxy(service=" << service << ").";
+ SLOG(this, 2) << "DHCPCDProxy(service=" << service << ").";
}
void DHCPCDProxy::Rebind(const string &interface) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
try {
proxy_.Rebind(interface);
} catch (const DBus::Error &e) {
@@ -125,7 +132,7 @@
}
void DHCPCDProxy::Release(const string &interface) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
try {
proxy_.Release(interface);
} catch (const DBus::Error &e) {
@@ -154,13 +161,13 @@
const uint32_t &/*pid*/,
const std::string &/*reason*/,
const DHCPConfig::Configuration &/*configuration*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
NOTREACHED();
}
void DHCPCDProxy::Proxy::StatusChanged(const uint32_t &/*pid*/,
const std::string &/*status*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
NOTREACHED();
}
diff --git a/dns_client.cc b/dns_client.cc
index ed504e0..0cc5aa9 100644
--- a/dns_client.cc
+++ b/dns_client.cc
@@ -33,6 +33,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDNS;
+static string ObjectID(DNSClient *d) { return d->interface_name(); }
+}
+
const char DNSClient::kErrorNoData[] = "The query response contains no answers";
const char DNSClient::kErrorFormErr[] = "The server says the query is bad";
const char DNSClient::kErrorServerFail[] = "The server says it had a failure";
@@ -156,7 +161,7 @@
}
void DNSClient::Stop() {
- SLOG(DNS, 3) << "In " << __func__;
+ SLOG(this, 3) << "In " << __func__;
if (!resolver_state_.get()) {
return;
}
@@ -178,7 +183,7 @@
// during the process of the execution of the callee (which is free to
// call our destructor safely).
void DNSClient::HandleCompletion() {
- SLOG(DNS, 3) << "In " << __func__;
+ SLOG(this, 3) << "In " << __func__;
Error error;
error.CopyFrom(error_);
IPAddress address(address_);
@@ -215,7 +220,7 @@
// We can be called during ARES shutdown -- ignore these events.
return;
}
- SLOG(DNS, 3) << "In " << __func__;
+ SLOG(this, 3) << "In " << __func__;
running_ = false;
timeout_closure_.Cancel();
dispatcher_->PostTask(Bind(&DNSClient::HandleCompletion,
diff --git a/dns_client.h b/dns_client.h
index a4bc581..ec4e8da 100644
--- a/dns_client.h
+++ b/dns_client.h
@@ -64,6 +64,8 @@
virtual bool IsActive() const;
+ std::string interface_name() { return interface_name_; }
+
private:
friend class DNSClientTest;
diff --git a/eap_credentials.cc b/eap_credentials.cc
index 81eec20..192b47c 100644
--- a/eap_credentials.cc
+++ b/eap_credentials.cc
@@ -30,6 +30,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kService;
+static string ObjectID(const EapCredentials *e) { return "(eap_credentials)"; }
+}
+
const char EapCredentials::kStorageEapAnonymousIdentity[] =
"EAP.AnonymousIdentity";
const char EapCredentials::kStorageEapCACert[] = "EAP.CACert";
@@ -203,14 +208,14 @@
bool EapCredentials::IsConnectable() const {
// Identity is required.
if (identity_.empty()) {
- SLOG(Service, 2) << "Not connectable: Identity is empty.";
+ SLOG(this, 2) << "Not connectable: Identity is empty.";
return false;
}
if (!client_cert_.empty() || !cert_id_.empty()) {
// If a client certificate is being used, we must have a private key.
if (private_key_.empty() && key_id_.empty()) {
- SLOG(Service, 2)
+ SLOG(this, 2)
<< "Not connectable: Client certificate but no private key.";
return false;
}
@@ -219,7 +224,7 @@
!ca_cert_id_.empty()) {
// If PKCS#11 data is needed, a PIN is required.
if (pin_.empty()) {
- SLOG(Service, 2) << "Not connectable: PKCS#11 data but no PIN.";
+ SLOG(this, 2) << "Not connectable: PKCS#11 data but no PIN.";
return false;
}
}
@@ -228,7 +233,7 @@
if (eap_.empty() || eap_ == kEapMethodTLS) {
if ((!client_cert_.empty() || !cert_id_.empty()) &&
(!private_key_.empty() || !key_id_.empty())) {
- SLOG(Service, 2) << "Connectable: EAP-TLS with a client cert and key.";
+ SLOG(this, 2) << "Connectable: EAP-TLS with a client cert and key.";
return true;
}
}
@@ -237,13 +242,12 @@
// minimum requirement), at least an identity + password is required.
if (eap_.empty() || eap_ != kEapMethodTLS) {
if (!password_.empty()) {
- SLOG(Service, 2) << "Connectable. !EAP-TLS and has a password.";
+ SLOG(this, 2) << "Connectable. !EAP-TLS and has a password.";
return true;
}
}
- SLOG(Service, 2)
- << "Not connectable: No suitable EAP configuration was found.";
+ SLOG(this, 2) << "Not connectable: No suitable EAP configuration was found.";
return false;
}
diff --git a/ephemeral_profile.cc b/ephemeral_profile.cc
index 41fe9bf..336eace 100644
--- a/ephemeral_profile.cc
+++ b/ephemeral_profile.cc
@@ -15,6 +15,11 @@
using std::string;
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kProfile;
+static string ObjectID(EphemeralProfile *e) { return e->GetRpcIdentifier(); }
+}
+
// static
const char EphemeralProfile::kFriendlyName[] = "(ephemeral)";
@@ -31,8 +36,8 @@
}
bool EphemeralProfile::AdoptService(const ServiceRefPtr &service) {
- SLOG(Profile, 2) << "Adding service " << service->unique_name()
- << " to ephemeral profile.";
+ SLOG(this, 2) << "Adding service " << service->unique_name()
+ << " to ephemeral profile.";
service->SetProfile(this);
return true;
}
@@ -40,8 +45,8 @@
bool EphemeralProfile::AbandonService(const ServiceRefPtr &service) {
if (service->profile() == this)
service->SetProfile(nullptr);
- SLOG(Profile, 2) << "Removing service " << service->unique_name()
- << " from ephemeral profile.";
+ SLOG(this, 2) << "Removing service " << service->unique_name()
+ << " from ephemeral profile.";
return true;
}
diff --git a/ethernet.cc b/ethernet.cc
index d5b93fc..e51acb5 100644
--- a/ethernet.cc
+++ b/ethernet.cc
@@ -43,6 +43,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kEthernet;
+static string ObjectID(Ethernet *e) { return e->GetRpcIdentifier(); }
+}
+
Ethernet::Ethernet(ControlInterface *control_interface,
EventDispatcher *dispatcher,
Metrics *metrics,
@@ -72,7 +77,7 @@
&is_eap_detected_);
eap_listener_->set_request_received_callback(
base::Bind(&Ethernet::OnEapDetected, weak_ptr_factory_.GetWeakPtr()));
- SLOG(Ethernet, 2) << "Ethernet device " << link_name << " initialized.";
+ SLOG(this, 2) << "Ethernet device " << link_name << " initialized.";
}
Ethernet::~Ethernet() {
diff --git a/hook_table.cc b/hook_table.cc
index 73c1aca..5c3462e 100644
--- a/hook_table.cc
+++ b/hook_table.cc
@@ -23,11 +23,16 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kManager;
+static string ObjectID(const HookTable *h) { return "(hook_table)"; }
+}
+
HookTable::HookTable(EventDispatcher *event_dispatcher)
: event_dispatcher_(event_dispatcher) {}
void HookTable::Add(const string &name, const Closure &start_callback) {
- SLOG(Manager, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Remove(name);
hook_table_.emplace(name, HookAction(start_callback));
}
@@ -37,12 +42,12 @@
}
void HookTable::Remove(const std::string &name) {
- SLOG(Manager, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
hook_table_.erase(name);
}
void HookTable::ActionComplete(const std::string &name) {
- SLOG(Manager, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
HookTableMap::iterator it = hook_table_.find(name);
if (it != hook_table_.end()) {
HookAction *action = &it->second;
@@ -58,7 +63,7 @@
}
void HookTable::Run(int timeout_ms, const ResultCallback &done) {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (hook_table_.empty()) {
done.Run(Error(Error::kSuccess));
return;
@@ -90,7 +95,7 @@
}
bool HookTable::AllActionsComplete() const {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (const auto &hook_entry : hook_table_) {
const HookAction &action = hook_entry.second;
if (action.started && !action.completed) {
diff --git a/http_proxy.cc b/http_proxy.cc
index ba17773..3ae8bbc 100644
--- a/http_proxy.cc
+++ b/http_proxy.cc
@@ -34,6 +34,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kHTTPProxy;
+static string ObjectID(Connection *c) {
+ return c->interface_name();
+}
+}
+
const int HTTPProxy::kClientHeaderTimeoutSeconds = 1;
const int HTTPProxy::kConnectTimeoutSeconds = 10;
const int HTTPProxy::kDNSTimeoutSeconds = 5;
@@ -84,7 +91,7 @@
bool HTTPProxy::Start(EventDispatcher *dispatcher,
Sockets *sockets) {
- SLOG(HTTPProxy, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (sockets_) {
// We are already running.
@@ -136,7 +143,7 @@
}
void HTTPProxy::Stop() {
- SLOG(HTTPProxy, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!sockets_) {
return;
@@ -159,7 +166,7 @@
// proxy's socket. We Accept() the client and start reading a request
// from it.
void HTTPProxy::AcceptClient(int fd) {
- SLOG(HTTPProxy, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
int client_fd = sockets_->Accept(fd, nullptr, nullptr);
if (client_fd < 0) {
@@ -236,7 +243,7 @@
// we should connect to and either start a DNS request or connect to a
// numeric address.
bool HTTPProxy::ParseClientRequest() {
- SLOG(HTTPProxy, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
string host;
bool found_via = false;
@@ -309,7 +316,7 @@
return false;
}
} else {
- SLOG(HTTPProxy, 3) << "Looking up host: " << server_hostname_;
+ SLOG(connection_, 3) << "Looking up host: " << server_hostname_;
Error error;
if (!dns_client_->Start(server_hostname_, &error)) {
SendClientError(502, "Could not resolve hostname: " + error.message());
@@ -462,7 +469,7 @@
// IOInputHandler callback that fires when data is read from the client.
// This could be header data, or perhaps POST data that follows the headers.
void HTTPProxy::ReadFromClient(InputData *data) {
- SLOG(HTTPProxy, 3) << "In " << __func__ << " length " << data->len;
+ SLOG(connection_, 3) << "In " << __func__ << " length " << data->len;
if (data->len == 0) {
// EOF from client.
@@ -495,7 +502,7 @@
// IOInputHandler callback which fires when data has been read from the
// server.
void HTTPProxy::ReadFromServer(InputData *data) {
- SLOG(HTTPProxy, 3) << "In " << __func__ << " length " << data->len;
+ SLOG(connection_, 3) << "In " << __func__ << " length " << data->len;
if (data->len == 0) {
// Server closed connection.
if (server_data_.IsEmpty()) {
@@ -514,7 +521,7 @@
// Return an HTTP error message back to the client.
void HTTPProxy::SendClientError(int code, const string &error) {
- SLOG(HTTPProxy, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
LOG(ERROR) << "Sending error " << error;
SetClientResponse(code, "ERROR", "text/plain", error);
state_ = kStateFlushResponse;
@@ -621,7 +628,7 @@
// which alerts us to new clients connecting. This function is called
// during various error conditions and is a callback for all timeouts.
void HTTPProxy::StopClient() {
- SLOG(HTTPProxy, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (is_route_requested_) {
connection_->ReleaseRouting();
@@ -660,8 +667,8 @@
CHECK_EQ(client_socket_, fd);
int ret = sockets_->Send(fd, server_data_.GetConstData(),
server_data_.GetLength(), 0);
- SLOG(HTTPProxy, 3) << "In " << __func__ << " wrote " << ret << " of "
- << server_data_.GetLength();
+ SLOG(connection_, 3) << "In " << __func__ << " wrote " << ret << " of "
+ << server_data_.GetLength();
if (ret < 0) {
LOG(ERROR) << "Server write failed";
StopClient();
@@ -684,8 +691,8 @@
CHECK_EQ(server_socket_, fd);
int ret = sockets_->Send(fd, client_data_.GetConstData(),
client_data_.GetLength(), 0);
- SLOG(HTTPProxy, 3) << "In " << __func__ << " wrote " << ret << " of "
- << client_data_.GetLength();
+ SLOG(connection_, 3) << "In " << __func__ << " wrote " << ret << " of "
+ << client_data_.GetLength();
if (ret < 0) {
LOG(ERROR) << "Client write failed";
diff --git a/http_request.cc b/http_request.cc
index 2a6f3c8..55b74f7 100644
--- a/http_request.cc
+++ b/http_request.cc
@@ -27,6 +27,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kHTTP;
+static string ObjectID(Connection *c) { return c->interface_name(); }
+}
+
const int HTTPRequest::kConnectTimeoutSeconds = 10;
const int HTTPRequest::kDNSTimeoutSeconds = 5;
const int HTTPRequest::kInputTimeoutSeconds = 10;
@@ -77,7 +82,7 @@
const HTTPURL &url,
const Callback<void(const ByteString &)> &read_event_callback,
const Callback<void(Result, const ByteString &)> &result_callback) {
- SLOG(HTTP, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
DCHECK(!is_running_);
@@ -102,7 +107,7 @@
return kResultConnectionFailure;
}
} else {
- SLOG(HTTP, 3) << "Looking up host: " << server_hostname_;
+ SLOG(connection_, 3) << "Looking up host: " << server_hostname_;
Error error;
if (!dns_client_->Start(server_hostname_, &error)) {
LOG(ERROR) << "Failed to start DNS client: " << error.message();
@@ -119,7 +124,7 @@
}
void HTTPRequest::Stop() {
- SLOG(HTTP, 3) << "In " << __func__ << "; running is " << is_running_;
+ SLOG(connection_, 3) << "In " << __func__ << "; running is " << is_running_;
if (!is_running_) {
return;
@@ -149,7 +154,7 @@
}
bool HTTPRequest::ConnectServer(const IPAddress &address, int port) {
- SLOG(HTTP, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!server_async_connection_->Start(address, port)) {
LOG(ERROR) << "Could not create socket to connect to server at "
<< address.ToString();
@@ -165,7 +170,7 @@
// DNSClient callback that fires when the DNS request completes.
void HTTPRequest::GetDNSResult(const Error &error, const IPAddress &address) {
- SLOG(HTTP, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!error.IsSuccess()) {
LOG(ERROR) << "Could not resolve hostname "
<< server_hostname_
@@ -184,7 +189,7 @@
// AsyncConnection callback routine which fires when the asynchronous Connect()
// to the remote server completes (or fails).
void HTTPRequest::OnConnectCompletion(bool success, int fd) {
- SLOG(HTTP, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!success) {
LOG(ERROR) << "Socket connection delayed failure to "
<< server_hostname_
@@ -209,7 +214,7 @@
// IOInputHandler callback which fires when data has been read from the
// server.
void HTTPRequest::ReadFromServer(InputData *data) {
- SLOG(HTTP, 3) << "In " << __func__ << " length " << data->len;
+ SLOG(connection_, 3) << "In " << __func__ << " length " << data->len;
if (data->len == 0) {
SendStatus(kResultSuccess);
return;
@@ -259,8 +264,8 @@
request_data_.GetLength(), 0);
CHECK(ret < 0 || static_cast<size_t>(ret) <= request_data_.GetLength());
- SLOG(HTTP, 3) << "In " << __func__ << " wrote " << ret << " of "
- << request_data_.GetLength();
+ SLOG(connection_, 3) << "In " << __func__ << " wrote " << ret << " of "
+ << request_data_.GetLength();
if (ret < 0) {
LOG(ERROR) << "Client write failed to "
diff --git a/ipconfig.cc b/ipconfig.cc
index a74f9ee..aac022a 100644
--- a/ipconfig.cc
+++ b/ipconfig.cc
@@ -20,6 +20,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kInet;
+static string ObjectID(IPConfig *i) { return i->GetRpcIdentifier(); }
+}
+
namespace {
const time_t kDefaultLeaseExpirationTime = LONG_MAX;
@@ -70,11 +75,11 @@
&properties_.web_proxy_auto_discovery);
time_ = Time::GetInstance();
current_lease_expiration_time_ = {kDefaultLeaseExpirationTime, 0};
- SLOG(Inet, 2) << __func__ << " device: " << device_name();
+ SLOG(this, 2) << __func__ << " device: " << device_name();
}
IPConfig::~IPConfig() {
- SLOG(Inet, 2) << __func__ << " device: " << device_name();
+ SLOG(this, 2) << __func__ << " device: " << device_name();
}
string IPConfig::GetRpcIdentifier() {
diff --git a/ipconfig_dbus_adaptor.cc b/ipconfig_dbus_adaptor.cc
index 70733cd..2b72a01 100644
--- a/ipconfig_dbus_adaptor.cc
+++ b/ipconfig_dbus_adaptor.cc
@@ -22,6 +22,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(IPConfigDBusAdaptor *i) { return i->GetRpcIdentifier(); }
+}
+
// static
const char IPConfigDBusAdaptor::kPath[] = "/ipconfig/";
@@ -40,36 +45,36 @@
}
void IPConfigDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
}
void IPConfigDBusAdaptor::EmitUintChanged(const string &name,
uint32_t value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
}
void IPConfigDBusAdaptor::EmitIntChanged(const string &name, int value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
}
void IPConfigDBusAdaptor::EmitStringChanged(const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::StringToVariant(value));
}
void IPConfigDBusAdaptor::EmitStringsChanged(const string &name,
const vector<string> &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::StringsToVariant(value));
}
map<string, DBus::Variant> IPConfigDBusAdaptor::GetProperties(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
map<string, DBus::Variant> properties;
DBusAdaptor::GetProperties(ipconfig_->store(), &properties, &error);
return properties;
@@ -78,7 +83,7 @@
void IPConfigDBusAdaptor::SetProperty(const string &name,
const DBus::Variant &value,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
if (DBusAdaptor::SetProperty(ipconfig_->mutable_store(),
name,
value,
@@ -89,16 +94,16 @@
void IPConfigDBusAdaptor::ClearProperty(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
DBusAdaptor::ClearProperty(ipconfig_->mutable_store(), name, &error);
}
void IPConfigDBusAdaptor::Remove(DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
void IPConfigDBusAdaptor::Refresh(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
ipconfig_->Refresh(&e);
e.ToDBusError(&error);
diff --git a/key_file_store.cc b/key_file_store.cc
index 970cefe..fab40c2 100644
--- a/key_file_store.cc
+++ b/key_file_store.cc
@@ -25,6 +25,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kStorage;
+static string ObjectID(const KeyFileStore *k) { return "(key_file_store)"; }
+}
+
const char KeyFileStore::kCorruptSuffix[] = ".corrupted";
KeyFileStore::KeyFileStore(GLib *glib)
@@ -207,8 +212,7 @@
glib_->KeyFileGetString(key_file_, group.c_str(), key.c_str(), &error);
if (!data) {
string s = glib_->ConvertErrorToMessage(error);
- SLOG(Storage, 10) << "Failed to lookup (" << group << ":" << key << "): "
- << s;
+ SLOG(this, 10) << "Failed to lookup (" << group << ":" << key << "): " << s;
return false;
}
if (value) {
@@ -235,8 +239,7 @@
glib_->KeyFileGetBoolean(key_file_, group.c_str(), key.c_str(), &error);
if (error) {
string s = glib_->ConvertErrorToMessage(error);
- SLOG(Storage, 10) << "Failed to lookup (" << group << ":" << key << "): "
- << s;
+ SLOG(this, 10) << "Failed to lookup (" << group << ":" << key << "): " << s;
return false;
}
if (value) {
@@ -262,8 +265,7 @@
glib_->KeyFileGetInteger(key_file_, group.c_str(), key.c_str(), &error);
if (error) {
string s = glib_->ConvertErrorToMessage(error);
- SLOG(Storage, 10) << "Failed to lookup (" << group << ":" << key << "): "
- << s;
+ SLOG(this, 10) << "Failed to lookup (" << group << ":" << key << "): " << s;
return false;
}
if (value) {
@@ -290,8 +292,8 @@
uint64_t data;
if (!base::StringToUint64(data_string, &data)) {
- SLOG(Storage, 10) << "Failed to convert (" << group << ":" << key << "): "
- << "string to uint64_t conversion failed";
+ SLOG(this, 10) << "Failed to convert (" << group << ":" << key << "): "
+ << "string to uint64_t conversion failed";
return false;
}
@@ -323,8 +325,7 @@
&error);
if (!data) {
string s = glib_->ConvertErrorToMessage(error);
- SLOG(Storage, 10) << "Failed to lookup (" << group << ":" << key << "): "
- << s;
+ SLOG(this, 10) << "Failed to lookup (" << group << ":" << key << "): " << s;
return false;
}
if (value) {
diff --git a/l2tp_ipsec_driver.cc b/l2tp_ipsec_driver.cc
index 4ae57a3..d58cf3e 100644
--- a/l2tp_ipsec_driver.cc
+++ b/l2tp_ipsec_driver.cc
@@ -49,6 +49,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kVPN;
+static string ObjectID(L2TPIPSecDriver *l) {
+ return l->GetServiceRpcIdentifier();
+}
+}
+
namespace {
const char kL2TPIPSecIPSecTimeoutProperty[] = "L2TPIPsec.IPsecTimeout";
const char kL2TPIPSecLeftProtoPortProperty[] = "L2TPIPsec.LeftProtoPort";
@@ -111,6 +118,12 @@
IdleService();
}
+std::string L2TPIPSecDriver::GetServiceRpcIdentifier() {
+ if (service_ == nullptr)
+ return "(l2tp_ipsec_driver)";
+ return service_->GetRpcIdentifier();
+}
+
bool L2TPIPSecDriver::ClaimInterface(const string &link_name,
int interface_index) {
// TODO(petkov): crbug.com/212446.
@@ -128,7 +141,7 @@
}
void L2TPIPSecDriver::Disconnect() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
IdleService();
}
@@ -156,9 +169,9 @@
void L2TPIPSecDriver::Cleanup(Service::ConnectState state,
Service::ConnectFailure failure) {
- SLOG(VPN, 2) << __func__ << "("
- << Service::ConnectStateToString(state) << ", "
- << Service::ConnectFailureToString(failure) << ")";
+ SLOG(this, 2) << __func__ << "("
+ << Service::ConnectStateToString(state) << ", "
+ << Service::ConnectFailureToString(failure) << ")";
StopConnectTimeout();
DeleteTemporaryFiles();
external_task_.reset();
@@ -190,7 +203,7 @@
}
bool L2TPIPSecDriver::SpawnL2TPIPSecVPN(Error *error) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
std::unique_ptr<ExternalTask> external_task_local(
new ExternalTask(control_, glib_,
weak_ptr_factory_.GetWeakPtr(),
@@ -456,7 +469,7 @@
}
KeyValueStore L2TPIPSecDriver::GetProvider(Error *error) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
KeyValueStore props = VPNDriver::GetProvider(error);
props.SetBool(kPassphraseRequiredProperty,
args()->LookupString(kL2tpIpsecPasswordProperty, "").empty());
diff --git a/l2tp_ipsec_driver.h b/l2tp_ipsec_driver.h
index 220b2db..373866e 100644
--- a/l2tp_ipsec_driver.h
+++ b/l2tp_ipsec_driver.h
@@ -41,6 +41,9 @@
GLib *glib);
~L2TPIPSecDriver() override;
+ // Method to return service RPC identifier.
+ std::string GetServiceRpcIdentifier();
+
protected:
// Inherited from VPNDriver.
virtual bool ClaimInterface(const std::string &link_name,
diff --git a/link_monitor.cc b/link_monitor.cc
index 8c3ac58..1b925fa 100644
--- a/link_monitor.cc
+++ b/link_monitor.cc
@@ -27,6 +27,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kLink;
+static string ObjectID(Connection *c) { return c->interface_name(); }
+}
+
const int LinkMonitor::kDefaultTestPeriodMilliseconds = 5000;
const char LinkMonitor::kDefaultLinkMonitorTechnologies[] = "wifi";
const int LinkMonitor::kFailureThreshold = 5;
@@ -93,7 +98,7 @@
}
void LinkMonitor::Stop() {
- SLOG(Link, 2) << "In " << __func__ << ".";
+ SLOG(connection_, 2) << "In " << __func__ << ".";
local_mac_address_.Clear();
gateway_mac_address_.Clear();
arp_client_.reset();
@@ -126,8 +131,8 @@
}
void LinkMonitor::AddResponseTimeSample(int response_time_milliseconds) {
- SLOG(Link, 2) << "In " << __func__ << " with sample "
- << response_time_milliseconds << ".";
+ SLOG(connection_, 2) << "In " << __func__ << " with sample "
+ << response_time_milliseconds << ".";
metrics_->NotifyLinkMonitorResponseTimeSampleAdded(
connection_->technology(), response_time_milliseconds);
response_sample_bucket_ += response_time_milliseconds;
@@ -156,8 +161,8 @@
if (!arp_client_->StartReplyListener()) {
return false;
}
- SLOG(Link, 4) << "Created ARP client; listening on socket "
- << arp_client_->socket() << ".";
+ SLOG(connection_, 4) << "Created ARP client; listening on socket "
+ << arp_client_->socket() << ".";
receive_response_handler_.reset(
dispatcher_->CreateReadyHandler(
arp_client_->socket(),
@@ -167,7 +172,7 @@
}
bool LinkMonitor::AddMissedResponse() {
- SLOG(Link, 2) << "In " << __func__ << ".";
+ SLOG(connection_, 2) << "In " << __func__ << ".";
AddResponseTimeSample(test_period_milliseconds_);
if (is_unicast_) {
@@ -211,7 +216,7 @@
}
void LinkMonitor::ReceiveResponse(int fd) {
- SLOG(Link, 2) << "In " << __func__ << ".";
+ SLOG(connection_, 2) << "In " << __func__ << ".";
ArpPacket packet;
ByteString sender;
if (!arp_client_->ReceivePacket(&packet, &sender)) {
@@ -219,24 +224,24 @@
}
if (!packet.IsReply()) {
- SLOG(Link, 4) << "This is not a reply packet. Ignoring.";
+ SLOG(connection_, 4) << "This is not a reply packet. Ignoring.";
return;
}
if (!connection_->local().address().Equals(
packet.remote_ip_address().address())) {
- SLOG(Link, 4) << "Response is not for our IP address.";
+ SLOG(connection_, 4) << "Response is not for our IP address.";
return;
}
if (!local_mac_address_.Equals(packet.remote_mac_address())) {
- SLOG(Link, 4) << "Response is not for our MAC address.";
+ SLOG(connection_, 4) << "Response is not for our MAC address.";
return;
}
if (!connection_->gateway().address().Equals(
packet.local_ip_address().address())) {
- SLOG(Link, 4) << "Response is not from the gateway IP address.";
+ SLOG(connection_, 4) << "Response is not from the gateway IP address.";
return;
}
@@ -267,10 +272,10 @@
if (!gateway_mac_address_.Equals(packet.local_mac_address())) {
const ByteString &new_mac_address = packet.local_mac_address();
if (!IsGatewayFound()) {
- SLOG(Link, 2) << "Found gateway at "
- << HardwareAddressToString(new_mac_address);
+ SLOG(connection_, 2) << "Found gateway at "
+ << HardwareAddressToString(new_mac_address);
} else {
- SLOG(Link, 2) << "Gateway MAC address changed.";
+ SLOG(connection_, 2) << "Gateway MAC address changed.";
}
gateway_mac_address_ = new_mac_address;
@@ -286,7 +291,7 @@
}
bool LinkMonitor::SendRequest() {
- SLOG(Link, 2) << "In " << __func__ << ".";
+ SLOG(connection_, 2) << "In " << __func__ << ".";
if (!arp_client_.get()) {
if (!CreateClient()) {
LOG(ERROR) << "Failed to start ARP client.";
@@ -309,7 +314,6 @@
// Therefore we keep the already open ArpClient in the case of
// a non-fatal timeout.
}
-
ByteString destination_mac_address(gateway_mac_address_.GetLength());
if (!IsGatewayFound()) {
// The remote MAC addess is set by convention to be all-zeroes in the
diff --git a/link_monitor_unittest.cc b/link_monitor_unittest.cc
index e325778..5aad8f5 100644
--- a/link_monitor_unittest.cc
+++ b/link_monitor_unittest.cc
@@ -43,10 +43,12 @@
namespace shill {
namespace {
+const char kInterfaceName[] = "int0";
const char kLocalIPAddress[] = "10.0.1.1";
const uint8_t kLocalMACAddress[] = { 0, 1, 2, 3, 4, 5 };
const char kRemoteIPAddress[] = "10.0.1.2";
const uint8_t kRemoteMACAddress[] = { 6, 7, 8, 9, 10, 11 };
+const char kDBusPath[] = "/dbus/path";
} // namespace
@@ -121,7 +123,8 @@
gateway_mac_(kRemoteMACAddress, arraysize(kRemoteMACAddress)),
local_mac_(kLocalMACAddress, arraysize(kLocalMACAddress)),
zero_mac_(arraysize(kLocalMACAddress)),
- link_scope_logging_was_enabled_(false) {}
+ link_scope_logging_was_enabled_(false),
+ interface_name_(kInterfaceName) {}
virtual ~LinkMonitorTest() {}
virtual void SetUp() {
@@ -141,6 +144,10 @@
EXPECT_CALL(*connection_, gateway()).WillRepeatedly(ReturnRef(gateway_ip_));
EXPECT_CALL(*connection_, technology())
.WillRepeatedly(Return(Technology::kEthernet));
+ EXPECT_CALL(*connection_, ipconfig_rpc_identifier())
+ .WillRepeatedly(testing::ReturnPointee(&kDBusPath));
+ EXPECT_CALL(*connection_, interface_name())
+ .WillRepeatedly(ReturnRef(interface_name_));
}
virtual void TearDown() {
@@ -387,6 +394,7 @@
ByteString zero_mac_;
ArpPacket rx_packet_;
bool link_scope_logging_was_enabled_;
+ const string interface_name_;
};
diff --git a/logging.h b/logging.h
index 6bac931..cf38b70 100644
--- a/logging.h
+++ b/logging.h
@@ -27,6 +27,8 @@
// "is greater than or equal to 1, and size is more than 1024";
//
+#define GET_MACRO_OVERLOAD2(arg1, arg2, arg3, macro_name, ...) macro_name
+
#define SLOG_IS_ON(scope, verbose_level) \
::shill::ScopeLogger::GetInstance()->IsLogEnabled( \
::shill::ScopeLogger::k##scope, verbose_level)
@@ -34,8 +36,20 @@
#define SLOG_STREAM(verbose_level) \
::logging::LogMessage(__FILE__, __LINE__, -verbose_level).stream()
-#define SLOG(scope, verbose_level) \
- LAZY_STREAM(SLOG_STREAM(verbose_level), SLOG_IS_ON(scope, verbose_level))
+#define SLOG_2ARG(object, verbose_level) \
+ LAZY_STREAM(SLOG_STREAM(verbose_level), \
+ ::shill::ScopeLogger::GetInstance()->IsLogEnabled( \
+ Logging::kModuleLogScope, verbose_level)) \
+ << (object ? Logging::ObjectID(object) : "(anon)") << " "
+
+#define SLOG_3ARG(scope, object, verbose_level) \
+ LAZY_STREAM(SLOG_STREAM(verbose_level), \
+ ::shill::ScopeLogger::GetInstance()->IsLogEnabled( \
+ ::shill::ScopeLogger::k##scope, verbose_level)) \
+ << (object ? Logging::ObjectID(object) : "(anon)") << " "
+
+#define SLOG(...) \
+ GET_MACRO_OVERLOAD2(__VA_ARGS__, SLOG_3ARG, SLOG_2ARG)(__VA_ARGS__)
#define SLOG_IF(scope, verbose_level, condition) \
LAZY_STREAM(SLOG_STREAM(verbose_level), \
diff --git a/mac80211_monitor.cc b/mac80211_monitor.cc
index 98bb7b0..adbb06e 100644
--- a/mac80211_monitor.cc
+++ b/mac80211_monitor.cc
@@ -20,6 +20,11 @@
using std::string;
using std::vector;
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static string ObjectID(Mac80211Monitor *m) { return m->link_name(); }
+}
+
// statics
// At 17-25 bytes per queue, this accommodates 80 queues.
// ath9k has 4 queues, and WP2 has 16 queues.
@@ -58,7 +63,7 @@
}
void Mac80211Monitor::Start(const string &phy_name) {
- SLOG(WiFi, 2) << __func__ << " on " << link_name_ << " (" << phy_name << ")";
+ SLOG(this, 2) << __func__ << " on " << link_name_ << " (" << phy_name << ")";
CHECK(!is_running_);
phy_name_ = phy_name;
queue_state_file_path_ = base::FilePath(
@@ -71,18 +76,18 @@
}
void Mac80211Monitor::Stop() {
- SLOG(WiFi, 2) << __func__ << " on " << link_name_ << " (" << phy_name_ << ")";
+ SLOG(this, 2) << __func__ << " on " << link_name_ << " (" << phy_name_ << ")";
StopTimer();
is_running_ = false;
}
void Mac80211Monitor::UpdateConnectedState(bool new_state) {
- SLOG(WiFi, 2) << __func__ << " (new_state=" << new_state << ")";
+ SLOG(this, 2) << __func__ << " (new_state=" << new_state << ")";
is_device_connected_ = new_state;
}
void Mac80211Monitor::StartTimer() {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (check_queues_callback_.IsCancelled()) {
check_queues_callback_.Reset(
Bind(&Mac80211Monitor::WakeQueuesIfNeeded,
@@ -93,17 +98,17 @@
}
void Mac80211Monitor::StopTimer() {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
check_queues_callback_.Cancel();
}
void Mac80211Monitor::WakeQueuesIfNeeded() {
- SLOG(WiFi, 2) << __func__ << " on " << link_name_ << " (" << phy_name_ << ")";
+ SLOG(this, 2) << __func__ << " on " << link_name_ << " (" << phy_name_ << ")";
CHECK(is_running_);
StartTimer(); // Always re-arm timer.
if (is_device_connected_) {
- SLOG(WiFi, 5) << "Skipping queue check: device is connected.";
+ SLOG(this, 5) << "Skipping queue check: device is connected.";
return;
}
@@ -116,7 +121,7 @@
uint32_t stuck_flags =
CheckAreQueuesStuck(ParseQueueState(queue_state_string));
- SLOG(WiFi, 2) << __func__ << " stuck_flags=" << stuck_flags;
+ SLOG(this, 2) << __func__ << " stuck_flags=" << stuck_flags;
if (!(stuck_flags & kStopFlagPowerSave)) {
if (stuck_flags) {
LOG(INFO) << "Skipping wake: stuck_flags is "
@@ -161,13 +166,13 @@
uint32_t stuck_flags = 0;
for (const auto &queue_state : queue_states) {
if (queue_state.queue_length < queue_length_limit_) {
- SLOG(WiFi, 5) << __func__
+ SLOG(this, 5) << __func__
<< " skipping queue of length " << queue_state.queue_length
<< " (threshold is " << queue_length_limit_ << ")";
continue;
}
if (!queue_state.stop_flags) {
- SLOG(WiFi, 5) << __func__
+ SLOG(this, 5) << __func__
<< " skipping queue of length " << queue_state.queue_length
<< " (not stopped)";
continue;
diff --git a/mac80211_monitor.h b/mac80211_monitor.h
index fe7ae1b..f763c58 100644
--- a/mac80211_monitor.h
+++ b/mac80211_monitor.h
@@ -48,6 +48,8 @@
virtual void Stop();
virtual void UpdateConnectedState(bool new_state);
+ const std::string &link_name() const { return link_name_; }
+
private:
friend class Mac80211MonitorTest;
FRIEND_TEST(Mac80211MonitorTest, CheckAreQueuesStuckMultipleReasons);
diff --git a/manager.cc b/manager.cc
index 0f96f09..d80f673 100644
--- a/manager.cc
+++ b/manager.cc
@@ -64,6 +64,12 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kManager;
+static string ObjectID(const Manager *m) { return "manager"; }
+}
+
+
// statics
const char Manager::kErrorNoDevice[] = "no wifi devices available";
const char Manager::kErrorTypeRequired[] = "must specify service type";
@@ -199,7 +205,7 @@
UpdateProviderMapping();
- SLOG(Manager, 2) << "Manager initialized.";
+ SLOG(this, 2) << "Manager initialized.";
}
Manager::~Manager() {}
@@ -327,7 +333,7 @@
}
void Manager::CreateProfile(const string &name, string *path, Error *error) {
- SLOG(Manager, 2) << __func__ << " " << name;
+ SLOG(this, 2) << __func__ << " " << name;
Profile::Identifier ident;
if (!Profile::ParseIdentifier(name, &ident)) {
Error::PopulateAndLog(error, Error::kInvalidArguments,
@@ -465,7 +471,7 @@
}
void Manager::PushProfile(const string &name, string *path, Error *error) {
- SLOG(Manager, 2) << __func__ << " " << name;
+ SLOG(this, 2) << __func__ << " " << name;
Profile::Identifier ident;
if (!Profile::ParseIdentifier(name, &ident)) {
Error::PopulateAndLog(error, Error::kInvalidArguments,
@@ -479,7 +485,7 @@
const string &user_hash,
string *path,
Error *error) {
- SLOG(Manager, 2) << __func__ << " " << name;
+ SLOG(this, 2) << __func__ << " " << name;
Profile::Identifier ident;
if (!Profile::ParseIdentifier(name, &ident) ||
ident.user.empty()) {
@@ -543,7 +549,7 @@
}
void Manager::PopProfile(const string &name, Error *error) {
- SLOG(Manager, 2) << __func__ << " " << name;
+ SLOG(this, 2) << __func__ << " " << name;
Profile::Identifier ident;
if (profiles_.empty()) {
Error::PopulateAndLog(error, Error::kNotFound, "Profile stack is empty");
@@ -564,7 +570,7 @@
}
void Manager::PopAnyProfile(Error *error) {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
Profile::Identifier ident;
if (profiles_.empty()) {
Error::PopulateAndLog(error, Error::kNotFound, "Profile stack is empty");
@@ -574,7 +580,7 @@
}
void Manager::PopAllUserProfiles(Error */*error*/) {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
while (!profiles_.empty() && !profiles_.back()->GetUser().empty()) {
PopProfileInternal();
}
@@ -687,7 +693,7 @@
if (error) {
error->Populate(Error::kNotFound, error_string);
}
- SLOG(Manager, 2) << error_string;
+ SLOG(this, 2) << error_string;
return nullptr;
}
@@ -705,14 +711,14 @@
if (error) {
error->Populate(Error::kNotFound, error_string);
}
- SLOG(Manager, 2) << error_string;
+ SLOG(this, 2) << error_string;
return nullptr;
}
ServiceRefPtr Manager::GetDefaultService() const {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (services_.empty() || !services_[0]->connection().get()) {
- SLOG(Manager, 2) << "In " << __func__ << ": No default connection exists.";
+ SLOG(this, 2) << "In " << __func__ << ": No default connection exists.";
return nullptr;
}
return services_[0];
@@ -804,12 +810,12 @@
bool Manager::MoveServiceToProfile(const ServiceRefPtr &to_move,
const ProfileRefPtr &destination) {
const ProfileRefPtr from = to_move->profile();
- SLOG(Manager, 2) << "Moving service "
- << to_move->unique_name()
- << " to profile "
- << destination->GetFriendlyName()
- << " from "
- << from->GetFriendlyName();
+ SLOG(this, 2) << "Moving service "
+ << to_move->unique_name()
+ << " to profile "
+ << destination->GetFriendlyName()
+ << " from "
+ << from->GetFriendlyName();
return destination->AdoptService(to_move) && from->AbandonService(to_move);
}
@@ -924,10 +930,10 @@
}
void Manager::DeregisterDevice(const DeviceRefPtr &to_forget) {
- SLOG(Manager, 2) << __func__ << "(" << to_forget->FriendlyName() << ")";
+ SLOG(this, 2) << __func__ << "(" << to_forget->FriendlyName() << ")";
for (auto it = devices_.begin(); it != devices_.end(); ++it) {
if (to_forget.get() == it->get()) {
- SLOG(Manager, 2) << "Deregistered device: " << to_forget->UniqueName();
+ SLOG(this, 2) << "Deregistered device: " << to_forget->UniqueName();
UpdateDevice(to_forget);
to_forget->SetEnabled(false);
devices_.erase(it);
@@ -935,8 +941,8 @@
return;
}
}
- SLOG(Manager, 2) << __func__ << " unknown device: "
- << to_forget->UniqueName();
+ SLOG(this, 2) << __func__ << " unknown device: "
+ << to_forget->UniqueName();
}
void Manager::LoadDeviceFromProfiles(const DeviceRefPtr &device) {
@@ -1013,7 +1019,7 @@
}
void Manager::RegisterService(const ServiceRefPtr &to_manage) {
- SLOG(Manager, 2) << "Registering service " << to_manage->unique_name();
+ SLOG(this, 2) << "Registering service " << to_manage->unique_name();
MatchProfileWithService(to_manage);
@@ -1058,8 +1064,8 @@
<< " state: " << Service::ConnectStateToString(to_update->state())
<< " failure: "
<< Service::ConnectFailureToString(to_update->failure());
- SLOG(Manager, 2) << "IsConnected(): " << to_update->IsConnected();
- SLOG(Manager, 2) << "IsConnecting(): " << to_update->IsConnecting();
+ SLOG(this, 2) << "IsConnected(): " << to_update->IsConnected();
+ SLOG(this, 2) << "IsConnecting(): " << to_update->IsConnecting();
if (to_update->IsConnected()) {
to_update->EnableAndRetainAutoConnect();
// Persists the updated auto_connect setting in the profile.
@@ -1119,12 +1125,12 @@
}
void Manager::TerminationActionComplete(const string &name) {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
termination_actions_.ActionComplete(name);
}
void Manager::RemoveTerminationAction(const string &name) {
- SLOG(Manager, 2) << __func__;
+ SLOG(this, 2) << __func__;
termination_actions_.Remove(name);
}
@@ -1417,7 +1423,7 @@
}
void Manager::SortServicesTask() {
- SLOG(Manager, 4) << "In " << __func__;
+ SLOG(this, 4) << "In " << __func__;
sort_services_task_.Cancel();
ServiceRefPtr default_service;
@@ -1467,7 +1473,7 @@
}
void Manager::DeviceStatusCheckTask() {
- SLOG(Manager, 4) << "In " << __func__;
+ SLOG(this, 4) << "In " << __func__;
ConnectionStatusCheck();
DevicePresenceStatusCheck();
@@ -1477,7 +1483,7 @@
}
void Manager::ConnectionStatusCheck() {
- SLOG(Manager, 4) << "In " << __func__;
+ SLOG(this, 4) << "In " << __func__;
// Report current connection status.
Metrics::ConnectionStatus status = Metrics::kConnectionStatusOffline;
if (IsConnected()) {
@@ -1532,7 +1538,7 @@
}
if (SLOG_IS_ON(Manager, 4)) {
- SLOG(Manager, 4) << "Sorted service list for AutoConnect: ";
+ SLOG(this, 4) << "Sorted service list for AutoConnect: ";
for (size_t i = 0; i < services_.size(); ++i) {
ServiceRefPtr service = services_[i];
const char *compare_reason = nullptr;
@@ -1544,22 +1550,22 @@
} else {
compare_reason = "last";
}
- SLOG(Manager, 4) << "Service " << service->unique_name()
- << " Profile: " << service->profile()->GetFriendlyName()
- << " IsConnected: " << service->IsConnected()
- << " IsConnecting: " << service->IsConnecting()
- << " HasEverConnected: " << service->has_ever_connected()
- << " IsFailed: " << service->IsFailed()
- << " connectable: " << service->connectable()
- << " auto_connect: " << service->auto_connect()
- << " retain_auto_connect: "
- << service->retain_auto_connect()
- << " priority: " << service->priority()
- << " crypto_algorithm: " << service->crypto_algorithm()
- << " key_rotation: " << service->key_rotation()
- << " endpoint_auth: " << service->endpoint_auth()
- << " strength: " << service->strength()
- << " sorted: " << compare_reason;
+ SLOG(this, 4) << "Service " << service->unique_name()
+ << " Profile: " << service->profile()->GetFriendlyName()
+ << " IsConnected: " << service->IsConnected()
+ << " IsConnecting: " << service->IsConnecting()
+ << " HasEverConnected: " << service->has_ever_connected()
+ << " IsFailed: " << service->IsFailed()
+ << " connectable: " << service->connectable()
+ << " auto_connect: " << service->auto_connect()
+ << " retain_auto_connect: "
+ << service->retain_auto_connect()
+ << " priority: " << service->priority()
+ << " crypto_algorithm: " << service->crypto_algorithm()
+ << " key_rotation: " << service->key_rotation()
+ << " endpoint_auth: " << service->endpoint_auth()
+ << " strength: " << service->strength()
+ << " sorted: " << compare_reason;
}
}
@@ -1625,7 +1631,7 @@
}
if (SLOG_IS_ON(Manager, 4)) {
- SLOG(Manager, 4) << "Sorted service list for ConnectToBestServicesTask: ";
+ SLOG(this, 4) << "Sorted service list for ConnectToBestServicesTask: ";
for (size_t i = 0; i < services_copy.size(); ++i) {
ServiceRefPtr service = services_copy[i];
const char *compare_reason = nullptr;
@@ -1642,22 +1648,22 @@
} else {
compare_reason = "last";
}
- SLOG(Manager, 4) << "Service " << service->unique_name()
- << " Profile: " << service->profile()->GetFriendlyName()
- << " IsConnected: " << service->IsConnected()
- << " IsConnecting: " << service->IsConnecting()
- << " HasEverConnected: " << service->has_ever_connected()
- << " IsFailed: " << service->IsFailed()
- << " connectable: " << service->connectable()
- << " auto_connect: " << service->auto_connect()
- << " retain_auto_connect: "
- << service->retain_auto_connect()
- << " priority: " << service->priority()
- << " crypto_algorithm: " << service->crypto_algorithm()
- << " key_rotation: " << service->key_rotation()
- << " endpoint_auth: " << service->endpoint_auth()
- << " strength: " << service->strength()
- << " sorted: " << compare_reason;
+ SLOG(this, 4) << "Service " << service->unique_name()
+ << " Profile: " << service->profile()->GetFriendlyName()
+ << " IsConnected: " << service->IsConnected()
+ << " IsConnecting: " << service->IsConnecting()
+ << " HasEverConnected: " << service->has_ever_connected()
+ << " IsFailed: " << service->IsFailed()
+ << " connectable: " << service->connectable()
+ << " auto_connect: " << service->auto_connect()
+ << " retain_auto_connect: "
+ << service->retain_auto_connect()
+ << " priority: " << service->priority()
+ << " crypto_algorithm: " << service->crypto_algorithm()
+ << " key_rotation: " << service->key_rotation()
+ << " endpoint_auth: " << service->endpoint_auth()
+ << " strength: " << service->strength()
+ << " sorted: " << compare_reason;
}
}
}
@@ -1677,11 +1683,11 @@
for (const auto &device : devices_) {
if (device->IsConnectedToService(service)) {
if (device->StartConnectivityTest()) {
- SLOG(Manager, 3) << "Started connectivity test for service "
- << service->unique_name();
+ SLOG(this, 3) << "Started connectivity test for service "
+ << service->unique_name();
} else {
- SLOG(Manager, 3) << "Failed to start connectivity test for service "
- << service->unique_name()
+ SLOG(this, 3) << "Failed to start connectivity test for service "
+ << service->unique_name()
<< " device not reporting IsConnected.";
}
break;
@@ -1862,7 +1868,7 @@
ServiceRefPtr Manager::GetServiceInner(const KeyValueStore &args,
Error *error) {
if (args.ContainsString(kGuidProperty)) {
- SLOG(Manager, 2) << __func__ << ": searching by GUID";
+ SLOG(this, 2) << __func__ << ": searching by GUID";
ServiceRefPtr service =
GetServiceWithGUID(args.GetString(kGuidProperty), nullptr);
if (service) {
@@ -1883,7 +1889,7 @@
return nullptr;
}
- SLOG(Manager, 2) << __func__ << ": getting " << type << " Service";
+ SLOG(this, 2) << __func__ << ": getting " << type << " Service";
return providers_[technology]->GetService(args, error);
}
@@ -1910,20 +1916,20 @@
// First pull in any stored configuration associated with the service.
if (service->profile() == profile) {
- SLOG(Manager, 2) << __func__ << ": service " << service->unique_name()
- << " is already a member of profile "
+ SLOG(this, 2) << __func__ << ": service " << service->unique_name()
+ << " is already a member of profile "
<< profile->GetFriendlyName()
<< " so a load is not necessary.";
} else if (profile->LoadService(service)) {
- SLOG(Manager, 2) << __func__ << ": applied stored information from profile "
- << profile->GetFriendlyName()
- << " into service "
- << service->unique_name();
+ SLOG(this, 2) << __func__ << ": applied stored information from profile "
+ << profile->GetFriendlyName()
+ << " into service "
+ << service->unique_name();
} else {
- SLOG(Manager, 2) << __func__ << ": no previous information in profile "
- << profile->GetFriendlyName()
- << " exists for service "
- << service->unique_name();
+ SLOG(this, 2) << __func__ << ": no previous information in profile "
+ << profile->GetFriendlyName()
+ << " exists for service "
+ << service->unique_name();
}
// Overlay this with the passed-in configuration parameters.
@@ -1942,8 +1948,8 @@
// profiles.
if (IsServiceEphemeral(service) ||
(profile_specified && service->profile() != profile)) {
- SLOG(Manager, 2) << "Moving service to profile "
- << profile->GetFriendlyName();
+ SLOG(this, 2) << "Moving service to profile "
+ << profile->GetFriendlyName();
if (!MoveServiceToProfile(service, profile)) {
Error::PopulateAndLog(error, Error::kInternalError,
"Unable to move service to profile");
@@ -1991,7 +1997,7 @@
ServiceRefPtr service;
if (args.ContainsString(kGuidProperty)) {
- SLOG(Manager, 2) << __func__ << ": searching by GUID";
+ SLOG(this, 2) << __func__ << ": searching by GUID";
service = GetServiceWithGUID(args.GetString(kGuidProperty), nullptr);
if (service && service->technology() != technology) {
Error::PopulateAndLog(error, Error::kNotSupported,
@@ -2137,8 +2143,8 @@
}
void Manager::OnDeviceGeolocationInfoUpdated(const DeviceRefPtr &device) {
- SLOG(Manager, 2) << __func__ << " for technology "
- << Technology::NameFromIdentifier(device->technology());
+ SLOG(this, 2) << __func__ << " for technology "
+ << Technology::NameFromIdentifier(device->technology());
switch (device->technology()) {
// TODO(gauravsh): crbug.com/217833 Need a strategy for combining
// geolocation objects from multiple devices of the same technolgy.
@@ -2208,7 +2214,7 @@
void Manager::SetTechnologyOrder(const string &order, Error *error) {
vector<Technology::Identifier> new_order;
- SLOG(Manager, 2) << "Setting technology order to " << order;
+ SLOG(this, 2) << "Setting technology order to " << order;
if (!Technology::GetTechnologyVectorFromString(order, &new_order, error)) {
return;
}
diff --git a/manager_dbus_adaptor.cc b/manager_dbus_adaptor.cc
index 9a66e9e..753be5a 100644
--- a/manager_dbus_adaptor.cc
+++ b/manager_dbus_adaptor.cc
@@ -25,6 +25,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(ManagerDBusAdaptor *m) { return m->GetRpcIdentifier(); }
+}
+
// static
const char ManagerDBusAdaptor::kPath[] = "/";
@@ -40,44 +45,44 @@
void ManagerDBusAdaptor::UpdateRunning() {}
void ManagerDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
}
void ManagerDBusAdaptor::EmitUintChanged(const string &name,
uint32_t value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
}
void ManagerDBusAdaptor::EmitIntChanged(const string &name, int value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
}
void ManagerDBusAdaptor::EmitStringChanged(const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::StringToVariant(value));
}
void ManagerDBusAdaptor::EmitStringsChanged(const string &name,
const vector<string> &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::StringsToVariant(value));
}
void ManagerDBusAdaptor::EmitRpcIdentifierChanged(
const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::PathToVariant(value));
}
void ManagerDBusAdaptor::EmitRpcIdentifierArrayChanged(
const string &name,
const vector<string> &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
vector<DBus::Path> paths;
for (const auto &element : value) {
paths.push_back(element);
@@ -87,13 +92,13 @@
}
void ManagerDBusAdaptor::EmitStateChanged(const string &new_state) {
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
StateChanged(new_state);
}
map<string, DBus::Variant> ManagerDBusAdaptor::GetProperties(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
map<string, DBus::Variant> properties;
DBusAdaptor::GetProperties(manager_->store(), &properties, &error);
return properties;
@@ -102,7 +107,7 @@
void ManagerDBusAdaptor::SetProperty(const string &name,
const DBus::Variant &value,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
if (DBusAdaptor::SetProperty(manager_->mutable_store(),
name,
value,
@@ -112,13 +117,13 @@
}
string ManagerDBusAdaptor::GetState(DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return manager_->CalculateState(nullptr);
}
DBus::Path ManagerDBusAdaptor::CreateProfile(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
string path;
manager_->CreateProfile(name, &path, &e);
@@ -130,7 +135,7 @@
void ManagerDBusAdaptor::RemoveProfile(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
manager_->RemoveProfile(name, &e);
e.ToDBusError(&error);
@@ -138,7 +143,7 @@
DBus::Path ManagerDBusAdaptor::PushProfile(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
string path;
manager_->PushProfile(name, &path, &e);
@@ -152,7 +157,7 @@
const string &name,
const string &user_hash,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
string path;
manager_->InsertUserProfile(name, user_hash, &path, &e);
@@ -164,28 +169,28 @@
void ManagerDBusAdaptor::PopProfile(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
manager_->PopProfile(name, &e);
e.ToDBusError(&error);
}
void ManagerDBusAdaptor::PopAnyProfile(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->PopAnyProfile(&e);
e.ToDBusError(&error);
}
void ManagerDBusAdaptor::PopAllUserProfiles(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->PopAllUserProfiles(&e);
e.ToDBusError(&error);
}
void ManagerDBusAdaptor::RecheckPortal(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->RecheckPortal(&e);
e.ToDBusError(&error);
@@ -193,7 +198,7 @@
void ManagerDBusAdaptor::RequestScan(const string &technology,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << technology;
+ SLOG(this, 2) << __func__ << ": " << technology;
Error e;
manager_->RequestScan(Device::kFullScan, technology, &e);
e.ToDBusError(&error);
@@ -201,7 +206,7 @@
void ManagerDBusAdaptor::EnableTechnology(const string &technology_name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << technology_name;
+ SLOG(this, 2) << __func__ << ": " << technology_name;
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
manager_->SetEnabledStateForTechnology(technology_name, true, &e,
@@ -211,7 +216,7 @@
void ManagerDBusAdaptor::DisableTechnology(const string &technology_name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << technology_name;
+ SLOG(this, 2) << __func__ << ": " << technology_name;
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
manager_->SetEnabledStateForTechnology(technology_name, false, &e,
@@ -223,7 +228,7 @@
DBus::Path ManagerDBusAdaptor::GetService(
const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
ServiceRefPtr service;
KeyValueStore args_store;
Error e;
@@ -241,7 +246,7 @@
DBus::Path ManagerDBusAdaptor::GetVPNService(
const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return GetService(args, error);
}
@@ -249,7 +254,7 @@
DBus::Path ManagerDBusAdaptor::GetWifiService(
const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return GetService(args, error);
}
@@ -257,7 +262,7 @@
DBus::Path ManagerDBusAdaptor::ConfigureService(
const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
ServiceRefPtr service;
KeyValueStore args_store;
Error key_value_store_error;
@@ -277,7 +282,7 @@
const DBus::Path &profile_rpcid,
const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
ServiceRefPtr service;
KeyValueStore args_store;
Error key_value_store_error;
@@ -297,7 +302,7 @@
DBus::Path ManagerDBusAdaptor::FindMatchingService(
const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
KeyValueStore args_store;
Error value_error;
DBusAdaptor::ArgsToKeyValueStore(args, &args_store, &value_error);
@@ -318,7 +323,7 @@
void ManagerDBusAdaptor::AddWakeOnPacketConnection(
const string &ip_endpoint,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->AddWakeOnPacketConnection(ip_endpoint, &e);
e.ToDBusError(&error);
@@ -326,7 +331,7 @@
void ManagerDBusAdaptor::RemoveWakeOnPacketConnection(
const string &ip_endpoint, DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->RemoveWakeOnPacketConnection(ip_endpoint, &e);
e.ToDBusError(&error);
@@ -334,20 +339,20 @@
void ManagerDBusAdaptor::RemoveAllWakeOnPacketConnections(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->RemoveAllWakeOnPacketConnections(&e);
e.ToDBusError(&error);
}
int32_t ManagerDBusAdaptor::GetDebugLevel(DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return logging::GetMinLogLevel();
}
void ManagerDBusAdaptor::SetDebugLevel(const int32_t &level,
DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << level;
+ SLOG(this, 2) << __func__ << ": " << level;
if (level < logging::LOG_NUM_SEVERITIES) {
logging::SetMinLogLevel(level);
// Like VLOG, SLOG uses negative verbose level.
@@ -358,37 +363,37 @@
}
string ManagerDBusAdaptor::GetServiceOrder(DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return manager_->GetTechnologyOrder();
}
void ManagerDBusAdaptor::SetServiceOrder(const string &order,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << order;
+ SLOG(this, 2) << __func__ << ": " << order;
Error e;
manager_->SetTechnologyOrder(order, &e);
e.ToDBusError(&error);
}
string ManagerDBusAdaptor::GetDebugTags(DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return ScopeLogger::GetInstance()->GetEnabledScopeNames();
}
void ManagerDBusAdaptor::SetDebugTags(const string &tags,
DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << tags;
+ SLOG(this, 2) << __func__ << ": " << tags;
ScopeLogger::GetInstance()->EnableScopesByName(tags);
}
string ManagerDBusAdaptor::ListDebugTags(DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
return ScopeLogger::GetInstance()->GetAllScopeNames();
}
map<string, DBus::Variant> ManagerDBusAdaptor::GetNetworksForGeolocation(
DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
map<string, DBus::Variant> networks;
for (const auto &network : manager_->GetNetworksForGeolocation()) {
Stringmaps value;
@@ -409,7 +414,7 @@
const string &hotspot_ssid,
const string &hotspot_bssid,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
manager_->VerifyDestination(certificate, public_key, nonce,
@@ -431,7 +436,7 @@
const string &hotspot_bssid,
const DBus::Path &network,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
manager_->VerifyAndEncryptCredentials(certificate, public_key, nonce,
@@ -455,7 +460,7 @@
const string &hotspot_bssid,
const string &data,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
manager_->VerifyAndEncryptData(certificate, public_key, nonce,
@@ -469,14 +474,14 @@
}
void ManagerDBusAdaptor::ConnectToBestServices(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->ConnectToBestServices(&e);
e.ToDBusError(&error);
}
void ManagerDBusAdaptor::CreateConnectivityReport(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
Error e;
manager_->CreateConnectivityReport(&e);
e.ToDBusError(&error);
diff --git a/metrics.cc b/metrics.cc
index d81c72a..27e55bb 100644
--- a/metrics.cc
+++ b/metrics.cc
@@ -19,6 +19,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kMetrics;
+static string ObjectID(const Metrics *m) { return "(metrics)"; }
+}
+
static const char kMetricPrefix[] = "Network.Shill";
// static
@@ -433,8 +438,8 @@
if (channel == kWiFiChannelUndef)
LOG(WARNING) << "no mapping for frequency " << frequency;
else
- SLOG(Metrics, 3) << "mapped frequency " << frequency
- << " to enum bucket " << channel;
+ SLOG(nullptr, 3) << "mapped frequency " << frequency
+ << " to enum bucket " << channel;
return channel;
}
@@ -577,15 +582,15 @@
}
void Metrics::Start() {
- SLOG(Metrics, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
void Metrics::Stop() {
- SLOG(Metrics, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
void Metrics::RegisterService(const Service &service) {
- SLOG(Metrics, 2) << __func__;
+ SLOG(this, 2) << __func__;
LOG_IF(WARNING, ContainsKey(services_metrics_, &service))
<< "Repeatedly registering " << service.unique_name();
shared_ptr<ServiceMetrics> service_metrics(new ServiceMetrics());
@@ -602,12 +607,12 @@
const string &histogram_name,
Service::ConnectState start_state,
Service::ConnectState stop_state) {
- SLOG(Metrics, 2) << __func__ << ": adding " << histogram_name << " for "
- << Service::ConnectStateToString(start_state) << " -> "
- << Service::ConnectStateToString(stop_state);
+ SLOG(this, 2) << __func__ << ": adding " << histogram_name << " for "
+ << Service::ConnectStateToString(start_state) << " -> "
+ << Service::ConnectStateToString(stop_state);
ServiceMetricsLookupMap::iterator it = services_metrics_.find(&service);
if (it == services_metrics_.end()) {
- SLOG(Metrics, 1) << "service not found";
+ SLOG(this, 1) << "service not found";
DCHECK(false);
return;
}
@@ -668,7 +673,7 @@
Service::ConnectState new_state) {
ServiceMetricsLookupMap::iterator it = services_metrics_.find(&service);
if (it == services_metrics_.end()) {
- SLOG(Metrics, 1) << "service not found";
+ SLOG(this, 1) << "service not found";
DCHECK(false);
return;
}
@@ -908,7 +913,7 @@
void Metrics::RegisterDevice(int interface_index,
Technology::Identifier technology) {
- SLOG(Metrics, 2) << __func__ << ": " << interface_index;
+ SLOG(this, 2) << __func__ << ": " << interface_index;
shared_ptr<DeviceMetrics> device_metrics(new DeviceMetrics);
devices_metrics_[interface_index] = device_metrics;
device_metrics->technology = technology;
@@ -973,8 +978,8 @@
bool Metrics::IsDeviceRegistered(int interface_index,
Technology::Identifier technology) {
- SLOG(Metrics, 2) << __func__ << ": interface index: " << interface_index
- << ", technology: " << technology;
+ SLOG(this, 2) << __func__ << ": interface index: " << interface_index
+ << ", technology: " << technology;
DeviceMetrics *device_metrics = GetDeviceMetrics(interface_index);
if (device_metrics == nullptr)
return false;
@@ -983,7 +988,7 @@
}
void Metrics::DeregisterDevice(int interface_index) {
- SLOG(Metrics, 2) << __func__ << ": interface index: " << interface_index;
+ SLOG(this, 2) << __func__ << ": interface index: " << interface_index;
DeviceMetrics *device_metrics = GetDeviceMetrics(interface_index);
if (device_metrics != nullptr) {
@@ -1132,8 +1137,8 @@
void Metrics::NotifyCellularDeviceDrop(const string &network_technology,
uint16_t signal_strength) {
- SLOG(Metrics, 2) << __func__ << ": " << network_technology
- << ", " << signal_strength;
+ SLOG(this, 2) << __func__ << ": " << network_technology
+ << ", " << signal_strength;
CellularDropTechnology drop_technology = kCellularDropTechnologyUnknown;
if (network_technology == kNetworkTechnology1Xrtt) {
drop_technology = kCellularDropTechnology1Xrtt;
@@ -1355,14 +1360,14 @@
}
bool Metrics::SendEnumToUMA(const string &name, int sample, int max) {
- SLOG(Metrics, 5)
+ SLOG(this, 5)
<< "Sending enum " << name << " with value " << sample << ".";
return library_->SendEnumToUMA(name, sample, max);
}
bool Metrics::SendToUMA(const string &name, int sample, int min, int max,
int num_buckets) {
- SLOG(Metrics, 5)
+ SLOG(this, 5)
<< "Sending metric " << name << " with value " << sample << ".";
return library_->SendToUMA(name, sample, min, max, num_buckets);
}
@@ -1396,18 +1401,18 @@
ServiceMetrics *service_metrics,
Service::ConnectState new_state) {
const char *state_string = Service::ConnectStateToString(new_state);
- SLOG(Metrics, 5) << __func__ << ": new_state=" << state_string;
+ SLOG(this, 5) << __func__ << ": new_state=" << state_string;
TimerReportersList &start_timers = service_metrics->start_on_state[new_state];
for (auto &start_timer : start_timers) {
- SLOG(Metrics, 5) << "Starting timer for " << start_timer->histogram_name()
- << " due to new state " << state_string << ".";
+ SLOG(this, 5) << "Starting timer for " << start_timer->histogram_name()
+ << " due to new state " << state_string << ".";
start_timer->Start();
}
TimerReportersList &stop_timers = service_metrics->stop_on_state[new_state];
for (auto &stop_timer : stop_timers) {
- SLOG(Metrics, 5) << "Stopping timer for " << stop_timer->histogram_name()
- << " due to new state " << state_string << ".";
+ SLOG(this, 5) << "Stopping timer for " << stop_timer->histogram_name()
+ << " due to new state " << state_string << ".";
if (stop_timer->Stop())
stop_timer->ReportMilliseconds();
}
@@ -1494,8 +1499,8 @@
DeviceMetricsLookupMap::const_iterator it =
devices_metrics_.find(interface_index);
if (it == devices_metrics_.end()) {
- SLOG(Metrics, 2) << __func__ << ": device " << interface_index
- << " not found";
+ SLOG(this, 2) << __func__ << ": device " << interface_index
+ << " not found";
return nullptr;
}
return it->second.get();
diff --git a/metrics_unittest.cc b/metrics_unittest.cc
index e1e31c3..b369912 100644
--- a/metrics_unittest.cc
+++ b/metrics_unittest.cc
@@ -708,7 +708,7 @@
const int kEnumValue = 1;
const int kEnumMax = 12;
EXPECT_CALL(log, Log(kVerboseLevel5, _,
- "Sending enum fake-enum with value 1."));
+ "(metrics) Sending enum fake-enum with value 1."));
EXPECT_CALL(library_, SendEnumToUMA(kEnumName, kEnumValue, kEnumMax));
metrics_.SendEnumToUMA(kEnumName, kEnumValue, kEnumMax);
@@ -718,7 +718,7 @@
const int kHistogramMax = 100;
const int kHistogramBuckets = 10;
EXPECT_CALL(log, Log(kVerboseLevel5, _,
- "Sending metric fake-metric with value 2."));
+ "(metrics) Sending metric fake-metric with value 2."));
EXPECT_CALL(library_, SendToUMA(kMetricName, kMetricValue, kHistogramMin,
kHistogramMax, kHistogramBuckets));
metrics_.SendToUMA(kMetricName, kMetricValue,
diff --git a/mm1_bearer_proxy.cc b/mm1_bearer_proxy.cc
index 93fdf7b..b7ded9a 100644
--- a/mm1_bearer_proxy.cc
+++ b/mm1_bearer_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
BearerProxy::BearerProxy(DBus::Connection *connection,
@@ -46,12 +47,11 @@
BearerProxy::Proxy::~Proxy() {}
-
// Method callbacks inherited from
// org::freedesktop::ModemManager1::BearerProxy
void BearerProxy::Proxy::ConnectCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -60,7 +60,7 @@
void BearerProxy::Proxy::DisconnectCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
diff --git a/mm1_modem_location_proxy.cc b/mm1_modem_location_proxy.cc
index 754bbcd..c9f11c2 100644
--- a/mm1_modem_location_proxy.cc
+++ b/mm1_modem_location_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
ModemLocationProxy::ModemLocationProxy(DBus::Connection *connection,
@@ -51,7 +52,7 @@
// org::freedesktop::ModemManager1::Modem:LocationProxy
void ModemLocationProxy::Proxy::SetupCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -62,7 +63,7 @@
const DBusEnumValueMap &location,
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<DBusEnumValueMapCallback> callback(
reinterpret_cast<DBusEnumValueMapCallback *>(data));
Error error;
diff --git a/mm1_modem_modem3gpp_proxy.cc b/mm1_modem_modem3gpp_proxy.cc
index 8915de2..ad4c8d7 100644
--- a/mm1_modem_modem3gpp_proxy.cc
+++ b/mm1_modem_modem3gpp_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
ModemModem3gppProxy::ModemModem3gppProxy(
@@ -52,7 +53,7 @@
// org::freedesktop::ModemManager1::Modem::ModemModem3gppProxy
void ModemModem3gppProxy::Proxy::RegisterCallback(const ::DBus::Error& dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -62,7 +63,7 @@
void ModemModem3gppProxy::Proxy::ScanCallback(
const std::vector<DBusPropertiesMap> &results,
const ::DBus::Error& dberror, void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<DBusPropertyMapsCallback> callback(
reinterpret_cast<DBusPropertyMapsCallback *>(data));
Error error;
diff --git a/mm1_modem_modemcdma_proxy.cc b/mm1_modem_modemcdma_proxy.cc
index 9080a68..141c828 100644
--- a/mm1_modem_modemcdma_proxy.cc
+++ b/mm1_modem_modemcdma_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
ModemModemCdmaProxy::ModemModemCdmaProxy(DBus::Connection *connection,
@@ -65,7 +66,7 @@
const uint32_t &activation_state,
const uint32_t &activation_error,
const DBusPropertiesMap &status_changes) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
activation_state_callback_.Run(activation_state,
activation_error,
status_changes);
@@ -75,7 +76,7 @@
// org::freedesktop::ModemManager1::Modem::ModemModemCdmaProxy
void ModemModemCdmaProxy::Proxy::ActivateCallback(const ::DBus::Error& dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -85,7 +86,7 @@
void ModemModemCdmaProxy::Proxy::ActivateManualCallback(
const ::DBus::Error& dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
diff --git a/mm1_modem_proxy.cc b/mm1_modem_proxy.cc
index 7c9a1ac..deb980e 100644
--- a/mm1_modem_proxy.cc
+++ b/mm1_modem_proxy.cc
@@ -16,6 +16,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
template<typename TraceMsgT, typename CallT, typename CallbackT,
@@ -43,7 +44,8 @@
Error *error,
const ResultCallback &callback,
int timeout) {
- SLOG(Modem, 2) << __func__ << "(" << enable << ", " << timeout << ")";
+ SLOG(&proxy_.path(), 2) << __func__ << "(" << enable << ", "
+ << timeout << ")";
BeginCall(__func__, &Proxy::EnableAsync, callback, error, timeout,
enable);
}
@@ -137,7 +139,7 @@
void ModemProxy::Proxy::StateChanged(const int32_t &old,
const int32_t &_new,
const uint32_t &reason) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
if (!state_changed_callback_.is_null())
state_changed_callback_.Run(old, _new, reason);
}
@@ -146,7 +148,7 @@
// org::freedesktop::ModemManager1::ModemProxy
void ModemProxy::Proxy::EnableCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -156,7 +158,7 @@
void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path, 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -165,7 +167,7 @@
void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -174,7 +176,7 @@
void ModemProxy::Proxy::ResetCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -183,7 +185,7 @@
void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -193,7 +195,7 @@
void ModemProxy::Proxy::SetCurrentCapabilitesCallback(
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -202,7 +204,7 @@
void ModemProxy::Proxy::SetCurrentModesCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -211,7 +213,7 @@
void ModemProxy::Proxy::SetCurrentBandsCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -221,7 +223,7 @@
void ModemProxy::Proxy::CommandCallback(const std::string &response,
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -230,7 +232,7 @@
void ModemProxy::Proxy::SetPowerStateCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
diff --git a/mm1_modem_simple_proxy.cc b/mm1_modem_simple_proxy.cc
index 5b680fd..b194d8c 100644
--- a/mm1_modem_simple_proxy.cc
+++ b/mm1_modem_simple_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
ModemSimpleProxy::ModemSimpleProxy(DBus::Connection *connection,
@@ -63,7 +64,7 @@
void ModemSimpleProxy::Proxy::ConnectCallback(const ::DBus::Path &bearer,
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&bearer, 2) << __func__;
unique_ptr<DBusPathCallback> callback(
reinterpret_cast<DBusPathCallback *>(data));
Error error;
@@ -73,7 +74,7 @@
void ModemSimpleProxy::Proxy::DisconnectCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -84,7 +85,7 @@
const DBusPropertiesMap &properties,
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<DBusPropertyMapCallback> callback(
reinterpret_cast<DBusPropertyMapCallback *>(data));
Error error;
diff --git a/mm1_modem_time_proxy.cc b/mm1_modem_time_proxy.cc
index 5df6f32..fe0f3f3 100644
--- a/mm1_modem_time_proxy.cc
+++ b/mm1_modem_time_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
ModemTimeProxy::ModemTimeProxy(DBus::Connection *connection,
@@ -49,7 +50,7 @@
// Signal callbacks inherited from Proxy
void ModemTimeProxy::Proxy::NetworkTimeChanged(const string &time) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
if (!network_time_changed_callback_.is_null())
network_time_changed_callback_.Run(time);
}
@@ -59,7 +60,7 @@
void ModemTimeProxy::Proxy::GetNetworkTimeCallback(const string &time,
const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<StringCallback> callback(reinterpret_cast<StringCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
diff --git a/mm1_sim_proxy.cc b/mm1_sim_proxy.cc
index f596b05..f4f2118 100644
--- a/mm1_sim_proxy.cc
+++ b/mm1_sim_proxy.cc
@@ -14,6 +14,7 @@
using std::unique_ptr;
namespace shill {
+
namespace mm1 {
template<typename TraceMsgT, typename CallT, typename CallbackT,
@@ -38,7 +39,7 @@
const ResultCallback &callback,
int timeout) {
// pin is intentionally not logged.
- SLOG(Modem, 2) << __func__ << "( XXX, " << timeout << ")";
+ SLOG(&proxy_.path(), 2) << __func__ << "( XXX, " << timeout << ")";
BeginCall(__func__, &Proxy::SendPinAsync, callback, error, timeout,
pin);
}
@@ -49,7 +50,7 @@
const ResultCallback &callback,
int timeout) {
// pin and puk are intentionally not logged.
- SLOG(Modem, 2) << __func__ << "( XXX, XXX, " << timeout << ")";
+ SLOG(&proxy_.path(), 2) << __func__ << "( XXX, XXX, " << timeout << ")";
BeginCall(__func__, &Proxy::SendPukAsync, callback, error, timeout,
puk, pin);
}
@@ -60,7 +61,8 @@
const ResultCallback &callback,
int timeout) {
// pin is intentionally not logged.
- SLOG(Modem, 2) << __func__ << "( XXX, " << enabled << ", " << timeout << ")";
+ SLOG(&proxy_.path(), 2) << __func__ << "( XXX, "
+ << enabled << ", " << timeout << ")";
BeginCall(__func__, &Proxy::EnablePinAsync, callback, error, timeout,
pin, enabled);
}
@@ -71,7 +73,7 @@
const ResultCallback &callback,
int timeout) {
// old_pin and new_pin are intentionally not logged.
- SLOG(Modem, 2) << __func__ << "( XXX, XXX, " << timeout << ")";
+ SLOG(&proxy_.path(), 2) << __func__ << "( XXX, XXX, " << timeout << ")";
BeginCall(__func__, &Proxy::ChangePinAsync, callback, error, timeout,
old_pin, new_pin);
}
@@ -83,12 +85,11 @@
SimProxy::Proxy::~Proxy() {}
-
// Method callbacks inherited from
// org::freedesktop::ModemManager1::SimProxy
void SimProxy::Proxy::SendPinCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -97,7 +98,7 @@
void SimProxy::Proxy::SendPukCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -106,7 +107,7 @@
void SimProxy::Proxy::EnablePinCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
@@ -115,7 +116,7 @@
void SimProxy::Proxy::ChangePinCallback(const ::DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, &path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromMM1DBusError(dberror, &error);
diff --git a/mobile_operator_info.cc b/mobile_operator_info.cc
index 5606377..744de8d 100644
--- a/mobile_operator_info.cc
+++ b/mobile_operator_info.cc
@@ -16,6 +16,13 @@
using std::stringstream;
using std::vector;
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(const MobileOperatorInfo *m) {
+ return "(mobile_operator_info)";
+}
+}
+
// /////////////////////////////////////////////////////////////////////////////
// MobileOperatorInfo implementation note:
// MobileOperatorInfo simply forwards all operations to |impl_|.
@@ -33,78 +40,78 @@
}
void MobileOperatorInfo::ClearDatabasePaths() {
- SLOG(Cellular, 3) << GetLogPrefix(__func__);
+ SLOG(this, 3) << GetLogPrefix(__func__);
impl_->ClearDatabasePaths();
}
void MobileOperatorInfo::AddDatabasePath(const FilePath &absolute_path) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << absolute_path.value()
- << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << absolute_path.value()
+ << ")";
impl_->AddDatabasePath(absolute_path);
}
bool MobileOperatorInfo::Init() {
auto result = impl_->Init();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
void MobileOperatorInfo::AddObserver(MobileOperatorInfo::Observer *observer) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__);
+ SLOG(this, 3) << GetLogPrefix(__func__);
impl_->AddObserver(observer);
}
void MobileOperatorInfo::RemoveObserver(
MobileOperatorInfo::Observer *observer) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__);
+ SLOG(this, 3) << GetLogPrefix(__func__);
impl_->RemoveObserver(observer);
}
bool MobileOperatorInfo::IsMobileNetworkOperatorKnown() const {
auto result = impl_->IsMobileNetworkOperatorKnown();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
bool MobileOperatorInfo::IsMobileVirtualNetworkOperatorKnown() const {
auto result = impl_->IsMobileVirtualNetworkOperatorKnown();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
const string &MobileOperatorInfo::uuid() const {
const auto &result = impl_->uuid();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
const string &MobileOperatorInfo::operator_name() const {
const auto &result = impl_->operator_name();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
const string &MobileOperatorInfo::country() const {
const auto &result = impl_->country();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
const string &MobileOperatorInfo::mccmnc() const {
const auto &result = impl_->mccmnc();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
const string &MobileOperatorInfo::sid() const {
const auto &result = impl_->sid();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
const string &MobileOperatorInfo::nid() const {
const auto &result = impl_->nid();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
@@ -115,8 +122,8 @@
for (const auto &mccmnc : result) {
pp_result << mccmnc << " ";
}
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result["
- << pp_result.str() << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result["
+ << pp_result.str() << "]";
}
return result;
}
@@ -128,8 +135,8 @@
for (const auto &sid : result) {
pp_result << sid << " ";
}
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result["
- << pp_result.str() << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result["
+ << pp_result.str() << "]";
}
return result;
}
@@ -143,8 +150,8 @@
pp_result << "(" << operator_name.name << ", " << operator_name.language
<< ") ";
}
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result["
- << pp_result.str() << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result["
+ << pp_result.str() << "]";
}
return result;
}
@@ -165,8 +172,8 @@
}
pp_result << "') ";
}
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result["
- << pp_result.str() << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result["
+ << pp_result.str() << "]";
}
return result;
}
@@ -180,66 +187,66 @@
pp_result << "(url: " << olp.url << ", method: " << olp.method
<< ", post_data: " << olp.post_data << ") ";
}
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result["
- << pp_result.str() << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result["
+ << pp_result.str() << "]";
}
return result;
}
const string &MobileOperatorInfo::activation_code() const {
const auto &result = impl_->activation_code();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
bool MobileOperatorInfo::requires_roaming() const {
auto result = impl_->requires_roaming();
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
+ SLOG(this, 3) << GetLogPrefix(__func__) << ": Result[" << result << "]";
return result;
}
void MobileOperatorInfo::UpdateIMSI(const string &imsi) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << imsi << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << imsi << ")";
impl_->UpdateIMSI(imsi);
}
void MobileOperatorInfo::UpdateICCID(const string &iccid) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << iccid << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << iccid << ")";
impl_->UpdateICCID(iccid);
}
void MobileOperatorInfo::UpdateMCCMNC(const string &mccmnc) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << mccmnc << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << mccmnc << ")";
impl_->UpdateMCCMNC(mccmnc);
}
void MobileOperatorInfo::UpdateSID(const string &sid) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << sid << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << sid << ")";
impl_->UpdateSID(sid);
}
void MobileOperatorInfo::UpdateNID(const string &nid) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << nid << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << nid << ")";
impl_->UpdateNID(nid);
}
void MobileOperatorInfo::UpdateOperatorName(const string &operator_name) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__) << "(" << operator_name << ")";
+ SLOG(this, 3) << GetLogPrefix(__func__) << "(" << operator_name << ")";
impl_->UpdateOperatorName(operator_name);
}
void MobileOperatorInfo::UpdateOnlinePortal(const string &url,
const string &method,
const string &post_data) {
- SLOG(Cellular, 3) << GetLogPrefix(__func__)
- << "(" << url
+ SLOG(this, 3) << GetLogPrefix(__func__)
+ << "(" << url
<< ", " << method
<< ", " << post_data << ")";
impl_->UpdateOnlinePortal(url, method, post_data);
}
void MobileOperatorInfo::Reset() {
- SLOG(Cellular, 3) << GetLogPrefix(__func__);
+ SLOG(this, 3) << GetLogPrefix(__func__);
impl_->Reset();
}
diff --git a/mobile_operator_info_impl.cc b/mobile_operator_info_impl.cc
index 53d45cb..c9c65d3 100644
--- a/mobile_operator_info_impl.cc
+++ b/mobile_operator_info_impl.cc
@@ -36,6 +36,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(const MobileOperatorInfoImpl *m) {
+ return "(mobile_operator_info_impl)";
+}
+}
+
// static
const char *MobileOperatorInfoImpl::kDefaultDatabasePath =
"/usr/share/shill/serviceproviders.pbf";
@@ -382,7 +389,7 @@
}
void MobileOperatorInfoImpl::PreprocessDatabase() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
mccmnc_to_mnos_.clear();
sid_to_mnos_.clear();
@@ -491,7 +498,7 @@
}
bool MobileOperatorInfoImpl::UpdateMNO() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
const MobileNetworkOperator *candidate = nullptr;
// The only way |operator_code_type_| can be |kOperatorCodeTypeUnknown| is
@@ -530,12 +537,12 @@
const string &operator_code =
(operator_code_type_ == kOperatorCodeTypeMCCMNC) ? user_mccmnc_ :
user_sid_;
- SLOG(Cellular, 1) << "MNO determined by "
- << OperatorCodeString() << " [" << operator_code
- << "] does not match any suggested by name["
- << user_operator_name_
- << "]. "
- << OperatorCodeString() << " overrides name!";
+ SLOG(this, 1) << "MNO determined by "
+ << OperatorCodeString() << " [" << operator_code
+ << "] does not match any suggested by name["
+ << user_operator_name_
+ << "]. "
+ << OperatorCodeString() << " overrides name!";
}
}
} else if (candidates_by_operator_code_.size() > 1) {
@@ -556,12 +563,12 @@
const string &operator_code =
(operator_code_type_ == kOperatorCodeTypeMCCMNC) ? user_mccmnc_ :
user_sid_;
- SLOG(Cellular, 1) << "MNOs suggested by "
- << OperatorCodeString() << " [" << operator_code
- << "] are multiple and disjoint from those suggested "
- << "by name["
- << user_operator_name_
- << "].";
+ SLOG(this, 1) << "MNOs suggested by "
+ << OperatorCodeString() << " [" << operator_code
+ << "] are multiple and disjoint from those suggested "
+ << "by name["
+ << user_operator_name_
+ << "].";
candidate = PickOneFromDuplicates(candidates_by_operator_code_);
}
} else { // candidates_by_operator_code_.size() == 0
@@ -571,19 +578,19 @@
if ((operator_code_type_ == kOperatorCodeTypeMCCMNC &&
!user_mccmnc_.empty()) ||
(operator_code_type_ == kOperatorCodeTypeSID && !user_sid_.empty())) {
- SLOG(Cellular, 1) << "A non-matching "
- << OperatorCodeString() << " "
- << "was reported by the user."
- << "We fail the MNO match in this case.";
+ SLOG(this, 1) << "A non-matching "
+ << OperatorCodeString() << " "
+ << "was reported by the user."
+ << "We fail the MNO match in this case.";
} else if (candidates_by_name_.size() == 1) {
candidate = candidates_by_name_[0];
} else if (candidates_by_name_.size() > 1) {
- SLOG(Cellular, 1) << "Multiple MNOs suggested by name["
- << user_operator_name_
- << "], and none by MCCMNC.";
+ SLOG(this, 1) << "Multiple MNOs suggested by name["
+ << user_operator_name_
+ << "], and none by MCCMNC.";
candidate = PickOneFromDuplicates(candidates_by_name_);
} else { // candidates_by_name_.size() == 0
- SLOG(Cellular, 1) << "No candidates suggested.";
+ SLOG(this, 1) << "No candidates suggested.";
}
}
@@ -596,7 +603,7 @@
}
bool MobileOperatorInfoImpl::UpdateMVNO() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
if (current_mno_ == nullptr) {
return false;
}
@@ -635,12 +642,12 @@
for (auto candidate : duplicates) {
if (candidate->earmarked()) {
- SLOG(Cellular, 2) << "Picking earmarked candidate: "
- << candidate->data().uuid();
+ SLOG(this, 2) << "Picking earmarked candidate: "
+ << candidate->data().uuid();
return candidate;
}
}
- SLOG(Cellular, 2) << "No earmarked candidate found. Choosing the first.";
+ SLOG(this, 2) << "No earmarked candidate found. Choosing the first.";
return duplicates[0];
}
@@ -664,14 +671,14 @@
to_match = user_mccmnc_;
break;
default:
- SLOG(Cellular, 1) << "Unknown filter type [" << filter.type() << "]";
+ SLOG(this, 1) << "Unknown filter type [" << filter.type() << "]";
return false;
}
// |to_match| can be empty if we have no *user provided* information of the
// correct type.
if (to_match.empty()) {
- SLOG(Cellular, 2) << "Nothing to match against (filter: "
- << filter.regex() << ").";
+ SLOG(this, 2) << "Nothing to match against (filter: "
+ << filter.regex() << ").";
return false;
}
@@ -709,9 +716,9 @@
if (regexec_error) {
string error_string;
error_string = GetRegError(regcomp_error, &filter_regex);
- SLOG(Cellular, 2) << "Could not match string " << to_match << " "
- << "against regexp " << filter.regex() << ". "
- << "Error returned: " << error_string << ". ";
+ SLOG(this, 2) << "Could not match string " << to_match << " "
+ << "against regexp " << filter.regex() << ". "
+ << "Error returned: " << error_string << ". ";
regfree(&filter_regex);
return false;
}
@@ -728,13 +735,13 @@
// |data| is a required field.
DCHECK(current_mno_->has_data());
- SLOG(Cellular, 2) << "Reloading MNO data.";
+ SLOG(this, 2) << "Reloading MNO data.";
ReloadData(current_mno_->data());
if (current_mvno_ != nullptr) {
// |data| is a required field.
DCHECK(current_mvno_->has_data());
- SLOG(Cellular, 2) << "Reloading MVNO data.";
+ SLOG(this, 2) << "Reloading MVNO data.";
ReloadData(current_mvno_->data());
}
}
@@ -758,7 +765,7 @@
}
void MobileOperatorInfoImpl::ReloadData(const Data &data) {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// |uuid_| is *always* overwritten. An MNO and MVNO should not share the
// |uuid_|.
CHECK(data.has_uuid());
@@ -923,7 +930,7 @@
}
void MobileOperatorInfoImpl::PostNotifyOperatorChanged() {
- SLOG(Cellular, 3) << __func__;
+ SLOG(this, 3) << __func__;
// If there was an outstanding task, it will get replaced.
notify_operator_changed_task_.Reset(
Bind(&MobileOperatorInfoImpl::NotifyOperatorChanged,
diff --git a/mock_log_unittest.cc b/mock_log_unittest.cc
index 87bcaef..685a36c 100644
--- a/mock_log_unittest.cc
+++ b/mock_log_unittest.cc
@@ -9,11 +9,17 @@
#include "shill/logging.h"
+
using ::std::string;
using ::testing::_;
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kManager;
+static string ObjectID(testing::Test *m) { return "(mock_log_test)"; }
+}
+
class MockLogTest : public testing::Test {
protected:
MockLogTest() {}
@@ -21,10 +27,10 @@
void LogSomething(const string &message) const {
LOG(INFO) << message;
}
- void SlogSomething(const string &message) const {
+ void SlogSomething(testing::Test *t, const string &message) const {
ScopeLogger::GetInstance()->EnableScopesByName("manager");
ScopeLogger::GetInstance()->set_verbose_level(2);
- SLOG(Manager, 2) << message;
+ SLOG(t, 2) << message;
ScopeLogger::GetInstance()->EnableScopesByName("-manager");
ScopeLogger::GetInstance()->set_verbose_level(0);
}
@@ -69,8 +75,17 @@
TEST_F(MockLogTest, MatchSlog) {
ScopedMockLog log;
const string kMessage("Something");
- EXPECT_CALL(log, Log(_, _, kMessage));
- SlogSomething(kMessage);
+ const string kLogMessage("(anon) Something");
+ EXPECT_CALL(log, Log(_, _, kLogMessage));
+ SlogSomething(nullptr, kMessage);
+}
+
+TEST_F(MockLogTest, MatchSlogWithObject) {
+ ScopedMockLog log;
+ const string kMessage("Something");
+ const string kLogMessage("(mock_log_test) Something");
+ EXPECT_CALL(log, Log(_, _, kLogMessage));
+ SlogSomething(this, kMessage);
}
TEST_F(MockLogTest, MatchWithGmockMatchers) {
diff --git a/modem.cc b/modem.cc
index e70f2dd..0993419 100644
--- a/modem.cc
+++ b/modem.cc
@@ -20,6 +20,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kModem;
+static string ObjectID(Modem *m) { return m->path().c_str(); }
+}
+
// TODO(petkov): Consider generating these in mm/mm-modem.h.
const char Modem::kPropertyLinkName[] = "Device";
const char Modem::kPropertyIPMethod[] = "IpMethod";
@@ -64,7 +69,7 @@
}
void Modem::OnDeviceInfoAvailable(const string &link_name) {
- SLOG(Modem, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (pending_device_info_ && link_name_ == link_name) {
// pending_device_info_ is only set if we've already been through
// CreateDeviceFromModemProperties() and saved our initial
@@ -92,7 +97,7 @@
void Modem::CreateDeviceFromModemProperties(
const DBusInterfaceToProperties &properties) {
- SLOG(Modem, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (device_.get()) {
return;
@@ -170,8 +175,8 @@
const string &interface,
const DBusPropertiesMap &changed_properties,
const vector<string> &invalidated_properties) {
- SLOG(Modem, 2) << __func__;
- SLOG(Modem, 3) << "PropertiesChanged signal received.";
+ SLOG(this, 2) << __func__;
+ SLOG(this, 3) << "PropertiesChanged signal received.";
if (device_.get()) {
device_->OnDBusPropertiesChanged(interface,
changed_properties,
diff --git a/modem_cdma_proxy.cc b/modem_cdma_proxy.cc
index 8544467..15e7bdd 100644
--- a/modem_cdma_proxy.cc
+++ b/modem_cdma_proxy.cc
@@ -48,7 +48,7 @@
const string ModemCDMAProxy::MEID() {
LOG(INFO) << "ModemCDMAProxy::" << __func__;
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Meid();
} catch (const DBus::Error &e) {
@@ -98,30 +98,30 @@
const uint32_t &activation_state,
const uint32_t &activation_error,
const DBusPropertiesMap &status_changes) {
- SLOG(DBus, 2) << __func__ << "(" << activation_state << ", "
- << activation_error << ")";
+ SLOG(&path(), 2) << __func__ << "(" << activation_state << ", "
+ << activation_error << ")";
activation_state_callback_.Run(activation_state,
activation_error,
status_changes);
}
void ModemCDMAProxy::Proxy::SignalQuality(const uint32_t &quality) {
- SLOG(DBus, 2) << __func__ << "(" << quality << ")";
+ SLOG(&path(), 2) << __func__ << "(" << quality << ")";
signal_quality_callback_.Run(quality);
}
void ModemCDMAProxy::Proxy::RegistrationStateChanged(
const uint32_t &cdma_1x_state,
const uint32_t &evdo_state) {
- SLOG(DBus, 2) << __func__ << "(" << cdma_1x_state << ", "
- << evdo_state << ")";
+ SLOG(&path(), 2) << __func__ << "(" << cdma_1x_state << ", "
+ << evdo_state << ")";
registration_state_callback_.Run(cdma_1x_state, evdo_state);
}
void ModemCDMAProxy::Proxy::ActivateCallback(const uint32_t &status,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__ << "(" << status << ")";
+ SLOG(&path(), 2) << __func__ << "(" << status << ")";
unique_ptr<ActivationResultCallback> callback(
reinterpret_cast<ActivationResultCallback *>(data));
Error error;
@@ -132,7 +132,7 @@
void ModemCDMAProxy::Proxy::GetRegistrationStateCallback(
const uint32_t &state_1x, const uint32_t &state_evdo,
const DBus::Error &dberror, void *data) {
- SLOG(DBus, 2) << __func__ << "(" << state_1x << ", " << state_evdo << ")";
+ SLOG(&path(), 2) << __func__ << "(" << state_1x << ", " << state_evdo << ")";
unique_ptr<RegistrationStateCallback> callback(
reinterpret_cast<RegistrationStateCallback *>(data));
Error error;
@@ -144,7 +144,7 @@
void ModemCDMAProxy::Proxy::GetSignalQualityCallback(const uint32_t &quality,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__ << "(" << quality << ")";
+ SLOG(&path(), 2) << __func__ << "(" << quality << ")";
unique_ptr<SignalQualityCallback> callback(
reinterpret_cast<SignalQualityCallback *>(data));
Error error;
diff --git a/modem_gobi_proxy.cc b/modem_gobi_proxy.cc
index 9e2f2cc..d77f31c 100644
--- a/modem_gobi_proxy.cc
+++ b/modem_gobi_proxy.cc
@@ -45,7 +45,7 @@
void ModemGobiProxy::Proxy::SetCarrierCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromDBusError(dberror, &error);
diff --git a/modem_gsm_card_proxy.cc b/modem_gsm_card_proxy.cc
index fd8f3e3..49f0807 100644
--- a/modem_gsm_card_proxy.cc
+++ b/modem_gsm_card_proxy.cc
@@ -94,7 +94,7 @@
}
uint32_t ModemGSMCardProxy::EnabledFacilityLocks() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.EnabledFacilityLocks();
} catch (const DBus::Error &e) {
@@ -111,7 +111,7 @@
void ModemGSMCardProxy::Proxy::GetIdCallback(const string &id,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<GSMIdentifierCallback> callback(
reinterpret_cast<GSMIdentifierCallback *>(data));
Error error;
@@ -122,34 +122,34 @@
void ModemGSMCardProxy::Proxy::GetImeiCallback(const string &imei,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
GetIdCallback(imei, dberror, data);
}
void ModemGSMCardProxy::Proxy::GetImsiCallback(const string &imsi,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
GetIdCallback(imsi, dberror, data);
}
void ModemGSMCardProxy::Proxy::GetSpnCallback(const string &spn,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
GetIdCallback(spn, dberror, data);
}
void ModemGSMCardProxy::Proxy::GetMsIsdnCallback(const string &msisdn,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
GetIdCallback(msisdn, dberror, data);
}
void ModemGSMCardProxy::Proxy::PinCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromDBusError(dberror, &error);
@@ -158,25 +158,25 @@
void ModemGSMCardProxy::Proxy::EnablePinCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
PinCallback(dberror, data);
}
void ModemGSMCardProxy::Proxy::SendPinCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
PinCallback(dberror, data);
}
void ModemGSMCardProxy::Proxy::SendPukCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
PinCallback(dberror, data);
}
void ModemGSMCardProxy::Proxy::ChangePinCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
PinCallback(dberror, data);
}
diff --git a/modem_gsm_network_proxy.cc b/modem_gsm_network_proxy.cc
index 585ec89..278df00 100644
--- a/modem_gsm_network_proxy.cc
+++ b/modem_gsm_network_proxy.cc
@@ -58,7 +58,7 @@
}
uint32_t ModemGSMNetworkProxy::AccessTechnology() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.AccessTechnology();
} catch (const DBus::Error &e) {
@@ -105,7 +105,7 @@
}
void ModemGSMNetworkProxy::Proxy::SignalQuality(const uint32_t &quality) {
- SLOG(DBus, 2) << __func__ << "(" << quality << ")";
+ SLOG(&path(), 2) << __func__ << "(" << quality << ")";
if (!signal_quality_callback_.is_null())
signal_quality_callback_.Run(quality);
}
@@ -114,21 +114,21 @@
const uint32_t &status,
const string &operator_code,
const string &operator_name) {
- SLOG(DBus, 2) << __func__ << "(" << status << ", " << operator_code << ", "
+ SLOG(&path(), 2) << __func__ << "(" << status << ", " << operator_code << ", "
<< operator_name << ")";
if (!registration_info_callback_.is_null())
registration_info_callback_.Run(status, operator_code, operator_name);
}
void ModemGSMNetworkProxy::Proxy::NetworkMode(const uint32_t &mode) {
- SLOG(DBus, 2) << __func__ << "(" << mode << ")";
+ SLOG(&path(), 2) << __func__ << "(" << mode << ")";
if (!network_mode_callback_.is_null())
network_mode_callback_.Run(mode);
}
void ModemGSMNetworkProxy::Proxy::RegisterCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromDBusError(dberror, &error);
@@ -137,7 +137,7 @@
void ModemGSMNetworkProxy::Proxy::GetRegistrationInfoCallback(
const GSMRegistrationInfo &info, const DBus::Error &dberror, void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<RegistrationInfoCallback> callback(
reinterpret_cast<RegistrationInfoCallback *>(data));
Error error;
@@ -147,7 +147,7 @@
void ModemGSMNetworkProxy::Proxy::GetSignalQualityCallback(
const uint32_t &quality, const DBus::Error &dberror, void *data) {
- SLOG(DBus, 2) << __func__ << "(" << quality << ")";
+ SLOG(&path(), 2) << __func__ << "(" << quality << ")";
unique_ptr<SignalQualityCallback> callback(
reinterpret_cast<SignalQualityCallback *>(data));
Error error;
@@ -158,7 +158,7 @@
void ModemGSMNetworkProxy::Proxy::ScanCallback(const GSMScanResults &results,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ScanResultsCallback> callback(
reinterpret_cast<ScanResultsCallback *>(data));
Error error;
diff --git a/modem_manager_proxy.cc b/modem_manager_proxy.cc
index b89b3e6..e593e7f 100644
--- a/modem_manager_proxy.cc
+++ b/modem_manager_proxy.cc
@@ -12,6 +12,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p; }
+}
+
ModemManagerProxy::ModemManagerProxy(DBus::Connection *connection,
ModemManagerClassic *manager,
const string &path,
@@ -21,7 +26,7 @@
ModemManagerProxy::~ModemManagerProxy() {}
vector<DBus::Path> ModemManagerProxy::EnumerateDevices() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.EnumerateDevices();
} catch (const DBus::Error &e) {
@@ -40,12 +45,12 @@
ModemManagerProxy::Proxy::~Proxy() {}
void ModemManagerProxy::Proxy::DeviceAdded(const DBus::Path &device) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
manager_->OnDeviceAdded(device);
}
void ModemManagerProxy::Proxy::DeviceRemoved(const DBus::Path &device) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
manager_->OnDeviceRemoved(device);
}
diff --git a/modem_proxy.cc b/modem_proxy.cc
index 1c7c6ac..be79ccb 100644
--- a/modem_proxy.cc
+++ b/modem_proxy.cc
@@ -72,13 +72,13 @@
void ModemProxy::Proxy::StateChanged(
const uint32_t &old, const uint32_t &_new, const uint32_t &reason) {
- SLOG(DBus, 2) << __func__ << "(" << old << ", " << _new << ", "
- << reason << ")";
+ SLOG(&path(), 2) << __func__ << "(" << old << ", " << _new << ", "
+ << reason << ")";
state_changed_callback_.Run(old, _new, reason);
}
void ModemProxy::Proxy::EnableCallback(const DBus::Error &dberror, void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromDBusError(dberror, &error);
@@ -88,7 +88,7 @@
void ModemProxy::Proxy::GetInfoCallback(const ModemHardwareInfo &info,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ModemInfoCallback> callback(
reinterpret_cast<ModemInfoCallback *>(data));
Error error;
@@ -98,7 +98,7 @@
void ModemProxy::Proxy::DisconnectCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromDBusError(dberror, &error);
diff --git a/modem_simple_proxy.cc b/modem_simple_proxy.cc
index ce5ca43..8d597a2 100644
--- a/modem_simple_proxy.cc
+++ b/modem_simple_proxy.cc
@@ -56,7 +56,7 @@
void ModemSimpleProxy::Proxy::GetStatusCallback(const DBusPropertiesMap &props,
const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<DBusPropertyMapCallback> callback(
reinterpret_cast<DBusPropertyMapCallback *>(data));
Error error;
@@ -66,7 +66,7 @@
void ModemSimpleProxy::Proxy::ConnectCallback(const DBus::Error &dberror,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
unique_ptr<ResultCallback> callback(reinterpret_cast<ResultCallback *>(data));
Error error;
CellularError::FromDBusError(dberror, &error);
diff --git a/net/netlink_attribute.cc b/net/netlink_attribute.cc
index 7692c1e..98f3248 100644
--- a/net/netlink_attribute.cc
+++ b/net/netlink_attribute.cc
@@ -465,7 +465,6 @@
reinterpret_cast<const unsigned char *>(&value_), sizeof(value_));
}
-
// NetlinkU16Attribute
const char NetlinkU16Attribute::kMyTypeString[] = "uint16_t";
diff --git a/net/netlink_socket.cc b/net/netlink_socket.cc
index d99f28d..d263df5 100644
--- a/net/netlink_socket.cc
+++ b/net/netlink_socket.cc
@@ -4,6 +4,8 @@
#include "shill/net/netlink_socket.h"
+#include <string>
+
#include <linux/if_packet.h>
#include <linux/netlink.h>
#include <sys/socket.h>
diff --git a/openvpn_driver.cc b/openvpn_driver.cc
index 9db51ac..be7dd85 100644
--- a/openvpn_driver.cc
+++ b/openvpn_driver.cc
@@ -37,6 +37,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kVPN;
+static string ObjectID(const OpenVPNDriver *o) {
+ return o->GetServiceRpcIdentifier();
+}
+}
+
namespace {
const char kOpenVPNForeignOptionPrefix[] = "foreign_option_";
@@ -172,8 +179,8 @@
void OpenVPNDriver::Cleanup(Service::ConnectState state,
Service::ConnectFailure failure,
const string &error_details) {
- SLOG(VPN, 2) << __func__ << "(" << Service::ConnectStateToString(state)
- << ", " << error_details << ")";
+ SLOG(this, 2) << __func__ << "(" << Service::ConnectStateToString(state)
+ << ", " << error_details << ")";
StopConnectTimeout();
if (child_watch_tag_) {
glib_->SourceRemove(child_watch_tag_);
@@ -284,7 +291,7 @@
}
bool OpenVPNDriver::SpawnOpenVPN() {
- SLOG(VPN, 2) << __func__ << "(" << tunnel_interface_ << ")";
+ SLOG(this, 2) << __func__ << "(" << tunnel_interface_ << ")";
vector<vector<string>> options;
Error error;
@@ -334,7 +341,7 @@
// static
void OpenVPNDriver::OnOpenVPNDied(GPid pid, gint status, gpointer data) {
- SLOG(VPN, 2) << __func__ << "(" << pid << ", " << status << ")";
+ SLOG(nullptr, 2) << __func__ << "(" << pid << ", " << status << ")";
OpenVPNDriver *me = reinterpret_cast<OpenVPNDriver *>(data);
me->child_watch_tag_ = 0;
CHECK_EQ(pid, me->pid_);
@@ -358,7 +365,7 @@
return false;
}
- SLOG(VPN, 2) << "Claiming " << link_name << " for OpenVPN tunnel";
+ SLOG(this, 2) << "Claiming " << link_name << " for OpenVPN tunnel";
CHECK(!device_);
device_ = new VirtualDevice(control_, dispatcher(), metrics_, manager(),
@@ -410,7 +417,7 @@
for (const auto &configuration_map : configuration) {
const string &key = configuration_map.first;
const string &value = configuration_map.second;
- SLOG(VPN, 2) << "Processing: " << key << " -> " << value;
+ SLOG(this, 2) << "Processing: " << key << " -> " << value;
if (LowerCaseEqualsASCII(key, kOpenVPNIfconfigLocal)) {
properties->address = value;
} else if (LowerCaseEqualsASCII(key, kOpenVPNIfconfigBroadcast)) {
@@ -460,7 +467,7 @@
ParseRouteOption(key.substr(strlen(kOpenVPNRouteOptionPrefix)),
value, &routes);
} else {
- SLOG(VPN, 2) << "Key ignored.";
+ SLOG(this, 2) << "Key ignored.";
}
}
ParseForeignOptions(foreign_options, properties);
@@ -471,8 +478,8 @@
LOG(INFO) << "Configuration request to ignore default route is "
<< "overridden by the remote server.";
} else {
- SLOG(VPN, 2) << "Ignoring default route parameter as requested by "
- << "configuration.";
+ SLOG(this, 2) << "Ignoring default route parameter as requested by "
+ << "configuration.";
properties->gateway.clear();
}
}
@@ -502,7 +509,7 @@
void OpenVPNDriver::ParseForeignOption(const string &option,
vector<string> *domain_search,
vector<string> *dns_servers) {
- SLOG(VPN, 2) << __func__ << "(" << option << ")";
+ SLOG(nullptr, 2) << __func__ << "(" << option << ")";
vector<string> tokens;
SplitString(option, ' ', &tokens);
if (tokens.size() != 3 || !LowerCaseEqualsASCII(tokens[0], "dhcp-option")) {
@@ -915,8 +922,14 @@
return false;
}
+string OpenVPNDriver::GetServiceRpcIdentifier() const {
+ if (service_ == nullptr)
+ return "(openvpn_driver)";
+ return service_->GetRpcIdentifier();
+}
+
void OpenVPNDriver::Disconnect() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
IdleService();
}
@@ -981,7 +994,7 @@
}
KeyValueStore OpenVPNDriver::GetProvider(Error *error) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
KeyValueStore props = VPNDriver::GetProvider(error);
props.SetBool(kPassphraseRequiredProperty,
args()->LookupString(kOpenVPNPasswordProperty, "").empty() &&
@@ -992,7 +1005,7 @@
// TODO(petkov): Consider refactoring lsb-release parsing out into a shared
// singleton if it's used outside OpenVPN.
bool OpenVPNDriver::ParseLSBRelease(map<string, string> *lsb_release) {
- SLOG(VPN, 2) << __func__ << "(" << lsb_release_file_.value() << ")";
+ SLOG(this, 2) << __func__ << "(" << lsb_release_file_.value() << ")";
string contents;
if (!base::ReadFileToString(lsb_release_file_, &contents)) {
LOG(ERROR) << "Unable to read the lsb-release file: "
@@ -1027,8 +1040,8 @@
}
void OpenVPNDriver::OnDefaultServiceChanged(const ServiceRefPtr &service) {
- SLOG(VPN, 2) << __func__
- << "(" << (service ? service->unique_name() : "-") << ")";
+ SLOG(this, 2) << __func__
+ << "(" << (service ? service->unique_name() : "-") << ")";
// Allow the openvpn client to connect/reconnect only over a connected
// underlying default service. If there's no default connected service, hold
// the openvpn client until an underlying connection is established. If the
diff --git a/openvpn_driver.h b/openvpn_driver.h
index 20db682..c0c045e 100644
--- a/openvpn_driver.h
+++ b/openvpn_driver.h
@@ -103,6 +103,8 @@
const std::string &option,
std::vector<std::vector<std::string>> *options);
+ virtual std::string GetServiceRpcIdentifier() const;
+
protected:
// Inherited from VPNDriver. |Connect| initiates the VPN connection by
// creating a tunnel device. When the device index becomes available, this
diff --git a/openvpn_management_server.cc b/openvpn_management_server.cc
index 58a6e5b..255c1e8 100644
--- a/openvpn_management_server.cc
+++ b/openvpn_management_server.cc
@@ -31,6 +31,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kVPN;
+static string ObjectID(OpenVPNManagementServer *o) {
+ return o->GetServiceRpcIdentifier();
+}
+}
+
namespace {
const char kPasswordTagAuth[] = "Auth";
} // namespace
@@ -56,7 +63,7 @@
bool OpenVPNManagementServer::Start(EventDispatcher *dispatcher,
Sockets *sockets,
vector<vector<string>> *options) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (IsStarted()) {
return true;
}
@@ -82,7 +89,7 @@
return false;
}
- SLOG(VPN, 2) << "Listening socket: " << socket;
+ SLOG(this, 2) << "Listening socket: " << socket;
sockets_ = sockets;
socket_ = socket;
ready_handler_.reset(
@@ -109,7 +116,7 @@
}
void OpenVPNManagementServer::Stop() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!IsStarted()) {
return;
}
@@ -129,7 +136,7 @@
}
void OpenVPNManagementServer::ReleaseHold() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
hold_release_ = true;
if (!hold_waiting_) {
return;
@@ -140,7 +147,7 @@
}
void OpenVPNManagementServer::Hold() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
hold_release_ = false;
}
@@ -149,8 +156,12 @@
SendSignal("SIGUSR1");
}
+std::string OpenVPNManagementServer::GetServiceRpcIdentifier() {
+ return driver_->GetServiceRpcIdentifier();
+}
+
void OpenVPNManagementServer::OnReady(int fd) {
- SLOG(VPN, 2) << __func__ << "(" << fd << ")";
+ SLOG(this, 2) << __func__ << "(" << fd << ")";
connected_socket_ = sockets_->Accept(fd, nullptr, nullptr);
if (connected_socket_ < 0) {
PLOG(ERROR) << "Connected socket accept failed.";
@@ -165,7 +176,7 @@
}
void OpenVPNManagementServer::OnInput(InputData *data) {
- SLOG(VPN, 2) << __func__ << "(" << data->len << ")";
+ SLOG(this, 2) << __func__ << "(" << data->len << ")";
vector<string> messages;
SplitString(
string(reinterpret_cast<char *>(data->buf), data->len), '\n', &messages);
@@ -181,7 +192,7 @@
}
void OpenVPNManagementServer::ProcessMessage(const string &message) {
- SLOG(VPN, 2) << __func__ << "(" << message << ")";
+ SLOG(this, 2) << __func__ << "(" << message << ")";
if (message.empty()) {
return;
}
@@ -230,8 +241,8 @@
string OpenVPNManagementServer::ParseSubstring(const string &message,
const string &start,
const string &end) {
- SLOG(VPN, 2) << __func__ << "(" << message
- << ", " << start << ", " << end << ")";
+ SLOG(VPN, nullptr, 2) << __func__ << "(" << message
+ << ", " << start << ", " << end << ")";
DCHECK(!start.empty() && !end.empty());
size_t start_pos = message.find(start);
if (start_pos == string::npos) {
@@ -311,7 +322,7 @@
}
void OpenVPNManagementServer::SupplyTPMToken(const string &tag) {
- SLOG(VPN, 2) << __func__ << "(" << tag << ")";
+ SLOG(this, 2) << __func__ << "(" << tag << ")";
string pin = driver_->args()->LookupString(kOpenVPNPinProperty, "");
if (pin.empty()) {
NOTIMPLEMENTED() << ": Missing PIN.";
@@ -408,38 +419,38 @@
}
void OpenVPNManagementServer::Send(const string &data) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
ssize_t len = sockets_->Send(connected_socket_, data.data(), data.size(), 0);
PLOG_IF(ERROR, len < 0 || static_cast<size_t>(len) != data.size())
<< "Send failed.";
}
void OpenVPNManagementServer::SendState(const string &state) {
- SLOG(VPN, 2) << __func__ << "(" << state << ")";
+ SLOG(this, 2) << __func__ << "(" << state << ")";
Send(StringPrintf("state %s\n", state.c_str()));
}
void OpenVPNManagementServer::SendUsername(const string &tag,
const string &username) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
Send(StringPrintf("username \"%s\" %s\n", tag.c_str(), username.c_str()));
}
void OpenVPNManagementServer::SendPassword(const string &tag,
const string &password) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
Send(StringPrintf("password \"%s\" \"%s\"\n",
tag.c_str(),
EscapeToQuote(password).c_str()));
}
void OpenVPNManagementServer::SendSignal(const string &signal) {
- SLOG(VPN, 2) << __func__ << "(" << signal << ")";
+ SLOG(this, 2) << __func__ << "(" << signal << ")";
Send(StringPrintf("signal %s\n", signal.c_str()));
}
void OpenVPNManagementServer::SendHoldRelease() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
Send("hold release\n");
}
diff --git a/openvpn_management_server.h b/openvpn_management_server.h
index 340a8a1..0aaf5fc 100644
--- a/openvpn_management_server.h
+++ b/openvpn_management_server.h
@@ -54,6 +54,9 @@
// OpenVPN client state.
const std::string &state() const { return state_; }
+ // Method to get service identifier for logging.
+ virtual std::string GetServiceRpcIdentifier();
+
private:
friend class OpenVPNDriverTest;
friend class OpenVPNManagementServerTest;
diff --git a/out_of_credits_detector.cc b/out_of_credits_detector.cc
index b493cec..f7361ee 100644
--- a/out_of_credits_detector.cc
+++ b/out_of_credits_detector.cc
@@ -4,6 +4,8 @@
#include "shill/out_of_credits_detector.h"
+#include <string>
+
#include "shill/active_passive_out_of_credits_detector.h"
#include "shill/cellular_service.h"
#include "shill/logging.h"
@@ -12,6 +14,13 @@
namespace shill {
+using std::string;
+
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularService *c) { return c->GetRpcIdentifier(); }
+}
+
OutOfCreditsDetector::OutOfCreditsDetector(EventDispatcher *dispatcher,
Manager *manager,
Metrics *metrics,
@@ -61,7 +70,7 @@
}
void OutOfCreditsDetector::ReportOutOfCredits(bool state) {
- SLOG(Cellular, 2) << __func__ << ": " << state;
+ SLOG(service_, 2) << __func__ << ": " << state;
if (state == out_of_credits_) {
return;
}
diff --git a/out_of_credits_detector.h b/out_of_credits_detector.h
index 8ccf3f1..79aa389 100644
--- a/out_of_credits_detector.h
+++ b/out_of_credits_detector.h
@@ -7,6 +7,8 @@
#include <base/macros.h>
+#include <string>
+
#include "shill/service.h"
namespace shill {
diff --git a/pending_activation_store.cc b/pending_activation_store.cc
index bedf196..0f3c22b 100644
--- a/pending_activation_store.cc
+++ b/pending_activation_store.cc
@@ -12,6 +12,13 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(const PendingActivationStore *p) {
+ return "(pending_activation_store)";
+}
+}
+
const char PendingActivationStore::kIccidGroupId[] = "iccid_list";
const char PendingActivationStore::kMeidGroupId[] = "meid_list";
// We're keeping the old file name here for backwards compatibility.
@@ -66,7 +73,7 @@
case kIdentifierMEID:
return kMeidGroupId;
default:
- SLOG(Cellular, 2) << "Incorrect identifier type: " << type;
+ SLOG(Cellular, nullptr, 2) << "Incorrect identifier type: " << type;
return "";
}
}
@@ -107,19 +114,19 @@
IdentifierType type,
const string &identifier) const {
string formatted_identifier = FormattedIdentifier(type, identifier);
- SLOG(Cellular, 2) << __func__ << ": " << formatted_identifier;
+ SLOG(this, 2) << __func__ << ": " << formatted_identifier;
if (!storage_.get()) {
LOG(ERROR) << "Underlying storage not initialized.";
return kStateUnknown;
}
int state = 0;
if (!storage_->GetInt(IdentifierTypeToGroupId(type), identifier, &state)) {
- SLOG(Cellular, 2) << "No entry exists for " << formatted_identifier;
+ SLOG(this, 2) << "No entry exists for " << formatted_identifier;
return kStateUnknown;
}
if (state <= 0 || state >= kStateMax) {
- SLOG(Cellular, 2) << "State value read for " << formatted_identifier
- << " is invalid.";
+ SLOG(this, 2) << "State value read for " << formatted_identifier
+ << " is invalid.";
return kStateUnknown;
}
return static_cast<State>(state);
@@ -129,25 +136,25 @@
IdentifierType type,
const string &identifier,
State state) {
- SLOG(Cellular, 2) << __func__ << ": State=" << StateToString(state) << ", "
- << FormattedIdentifier(type, identifier);
+ SLOG(this, 2) << __func__ << ": State=" << StateToString(state) << ", "
+ << FormattedIdentifier(type, identifier);
if (!storage_.get()) {
LOG(ERROR) << "Underlying storage not initialized.";
return false;
}
if (state == kStateUnknown) {
- SLOG(Cellular, 2) << "kStateUnknown cannot be used as a value.";
+ SLOG(this, 2) << "kStateUnknown cannot be used as a value.";
return false;
}
if (state < 0 || state >= kStateMax) {
- SLOG(Cellular, 2) << "Cannot set state to \"" << StateToString(state)
- << "\"";
+ SLOG(this, 2) << "Cannot set state to \"" << StateToString(state)
+ << "\"";
return false;
}
if (!storage_->SetInt(
IdentifierTypeToGroupId(type), identifier, static_cast<int>(state))) {
- SLOG(Cellular, 2) << "Failed to store the given identifier and state "
- << "values.";
+ SLOG(this, 2) << "Failed to store the given identifier and state "
+ << "values.";
return false;
}
return storage_->Flush();
@@ -155,14 +162,14 @@
bool PendingActivationStore::RemoveEntry(IdentifierType type,
const std::string &identifier) {
- SLOG(Cellular, 2) << __func__ << ": "
- << FormattedIdentifier(type, identifier);
+ SLOG(this, 2) << __func__ << ": "
+ << FormattedIdentifier(type, identifier);
if (!storage_.get()) {
LOG(ERROR) << "Underlying storage not initialized.";
return false;
}
if (!storage_->DeleteKey(IdentifierTypeToGroupId(type), identifier)) {
- SLOG(Cellular, 2) << "Failed to remove the given identifier.";
+ SLOG(this, 2) << "Failed to remove the given identifier.";
return false;
}
return storage_->Flush();
diff --git a/portal_detector.cc b/portal_detector.cc
index 62fbb96..fdb1221 100644
--- a/portal_detector.cc
+++ b/portal_detector.cc
@@ -23,6 +23,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kPortal;
+static string ObjectID(Connection *c) { return c->interface_name(); }
+}
+
const int PortalDetector::kDefaultCheckIntervalSeconds = 30;
const char PortalDetector::kDefaultCheckPortalList[] = "ethernet,wifi,cellular";
@@ -61,7 +66,7 @@
bool PortalDetector::StartAfterDelay(const string &url_string,
int delay_seconds) {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
if (!connectivity_trial_->Start(url_string, delay_seconds * 1000)) {
return false;
@@ -77,7 +82,7 @@
}
void PortalDetector::Stop() {
- SLOG(Portal, 3) << "In " << __func__;
+ SLOG(connection_, 3) << "In " << __func__;
attempt_count_ = 0;
failures_in_content_phase_ = 0;
@@ -144,8 +149,8 @@
struct timeval now, elapsed_time;
time_->GetTimeMonotonic(&now);
timersub(&now, &attempt_start_time_, &elapsed_time);
- SLOG(Portal, 4) << "Elapsed time from previous attempt is "
- << elapsed_time.tv_sec << " seconds.";
+ SLOG(connection_, 4) << "Elapsed time from previous attempt is "
+ << elapsed_time.tv_sec << " seconds.";
if (elapsed_time.tv_sec < kMinTimeBetweenAttemptsSeconds) {
next_attempt_delay_seconds = kMinTimeBetweenAttemptsSeconds -
elapsed_time.tv_sec;
@@ -154,9 +159,9 @@
LOG(FATAL) << "AdjustStartDelay in PortalDetector called without "
"previous attempts";
}
- SLOG(Portal, 3) << "Adjusting trial start delay from "
- << init_delay_seconds << " seconds to "
- << next_attempt_delay_seconds << " seconds.";
+ SLOG(connection_, 3) << "Adjusting trial start delay from "
+ << init_delay_seconds << " seconds to "
+ << next_attempt_delay_seconds << " seconds.";
return next_attempt_delay_seconds;
}
diff --git a/ppp_device.cc b/ppp_device.cc
index e069e54..c69dcd0 100644
--- a/ppp_device.cc
+++ b/ppp_device.cc
@@ -14,6 +14,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kPPP;
+static string ObjectID(PPPDevice *p) { return p->link_name(); }
+}
+
// statics
const char PPPDevice::kDaemonPath[] = "/usr/sbin/pppd";
const char PPPDevice::kPluginPath[] = SHIMDIR "/shill-pppd-plugin.so";
@@ -31,7 +36,7 @@
void PPPDevice::UpdateIPConfigFromPPP(const map<string, string> &configuration,
bool blackhole_ipv6) {
- SLOG(PPP, 2) << __func__ << " on " << link_name();
+ SLOG(this, 2) << __func__ << " on " << link_name();
IPConfig::Properties properties =
ParseIPConfiguration(link_name(), configuration);
properties.blackhole_ipv6 = blackhole_ipv6;
@@ -49,7 +54,7 @@
// static
IPConfig::Properties PPPDevice::ParseIPConfiguration(
const string &link_name, const map<string, string> &configuration) {
- SLOG(PPP, 2) << __func__ << " on " << link_name;
+ SLOG(PPP, nullptr, 2) << __func__ << " on " << link_name;
IPConfig::Properties properties;
properties.address_family = IPAddress::kFamilyIPv4;
properties.subnet_prefix = IPAddress::GetMaxPrefixLength(
@@ -57,7 +62,7 @@
for (const auto &it : configuration) {
const string &key = it.first;
const string &value = it.second;
- SLOG(PPP, 2) << "Processing: " << key << " -> " << value;
+ SLOG(PPP, nullptr, 2) << "Processing: " << key << " -> " << value;
if (key == kPPPInternalIP4Address) {
properties.address = value;
} else if (key == kPPPExternalIP4Address) {
@@ -73,7 +78,7 @@
// our PPP plugin.
properties.trusted_ip = value;
} else {
- SLOG(PPP, 2) << "Key ignored.";
+ SLOG(PPP, nullptr, 2) << "Key ignored.";
}
}
if (properties.gateway.empty()) {
diff --git a/profile_dbus_adaptor.cc b/profile_dbus_adaptor.cc
index 91a5a0c..79117be 100644
--- a/profile_dbus_adaptor.cc
+++ b/profile_dbus_adaptor.cc
@@ -22,6 +22,12 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(ProfileDBusAdaptor *p) { return p->GetRpcIdentifier(); }
+}
+
+
// static
const char ProfileDBusAdaptor::kPath[] = "/profile/";
@@ -35,30 +41,30 @@
}
void ProfileDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
}
void ProfileDBusAdaptor::EmitUintChanged(const string &name,
uint32_t value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
}
void ProfileDBusAdaptor::EmitIntChanged(const string &name, int value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
}
void ProfileDBusAdaptor::EmitStringChanged(const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
PropertyChanged(name, DBusAdaptor::StringToVariant(value));
}
map<string, DBus::Variant> ProfileDBusAdaptor::GetProperties(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
map<string, DBus::Variant> properties;
DBusAdaptor::GetProperties(profile_->store(), &properties, &error);
return properties;
@@ -67,7 +73,7 @@
void ProfileDBusAdaptor::SetProperty(const string &name,
const DBus::Variant &value,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
if (DBusAdaptor::SetProperty(profile_->mutable_store(),
name,
value,
@@ -79,7 +85,7 @@
map<string, DBus::Variant> ProfileDBusAdaptor::GetEntry(
const std::string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
ServiceRefPtr service = profile_->GetServiceFromEntry(name, &e);
map<string, DBus::Variant> properties;
@@ -97,7 +103,7 @@
void ProfileDBusAdaptor::DeleteEntry(const std::string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << name;
+ SLOG(this, 2) << __func__ << ": " << name;
Error e;
profile_->DeleteEntry(name, &e);
e.ToDBusError(&error);
diff --git a/property_store.cc b/property_store.cc
index ccbf7e5..00300b6 100644
--- a/property_store.cc
+++ b/property_store.cc
@@ -20,6 +20,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kProperty;
+static string ObjectID(const PropertyStore *p) { return "(property_store)"; }
+}
+
PropertyStore::PropertyStore() {}
PropertyStore::PropertyStore(PropertyChangeCallback on_property_changed) :
@@ -226,7 +231,7 @@
}
bool PropertyStore::ClearProperty(const string &name, Error *error) {
- SLOG(Property, 2) << "Clearing " << name << ".";
+ SLOG(this, 2) << "Clearing " << name << ".";
if (ContainsKey(bool_properties_, name)) {
bool_properties_[name]->Clear(error);
@@ -654,8 +659,8 @@
Error *error,
const map<string, std::shared_ptr<AccessorInterface<V>>> &collection,
const string &value_type_english) const {
- SLOG(Property, 2) << "Getting " << name << " as " << value_type_english
- << ".";
+ SLOG(this, 2) << "Getting " << name << " as " << value_type_english
+ << ".";
typename map<string, std::shared_ptr<AccessorInterface<V>>>::const_iterator
it = collection.find(name);
if (it != collection.end()) {
@@ -684,8 +689,8 @@
map<string, std::shared_ptr<AccessorInterface<V>>>* collection,
const string &value_type_english) {
bool ret = false;
- SLOG(Property, 2) << "Setting " << name << " as " << value_type_english
- << ".";
+ SLOG(this, 2) << "Setting " << name << " as " << value_type_english
+ << ".";
if (ContainsKey(*collection, name)) {
ret = (*collection)[name]->Set(value, error);
if (ret) {
diff --git a/resolver.cc b/resolver.cc
index 785993c..f45c337 100644
--- a/resolver.cc
+++ b/resolver.cc
@@ -21,6 +21,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kResolver;
+static string ObjectID(Resolver *r) { return "(resolver)"; }
+}
+
namespace {
base::LazyInstance<Resolver> g_resolver = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -37,10 +42,10 @@
bool Resolver::SetDNSFromLists(const std::vector<std::string> &dns_servers,
const std::vector<std::string> &domain_search) {
- SLOG(Resolver, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (dns_servers.empty() && domain_search.empty()) {
- SLOG(Resolver, 2) << "DNS list is empty";
+ SLOG(this, 2) << "DNS list is empty";
return ClearDNS();
}
@@ -83,14 +88,14 @@
string contents = JoinString(lines, '\n');
- SLOG(Resolver, 2) << "Writing DNS out to " << path_.value();
+ SLOG(this, 2) << "Writing DNS out to " << path_.value();
int count = base::WriteFile(path_, contents.c_str(), contents.size());
return count == static_cast<int>(contents.size());
}
bool Resolver::ClearDNS() {
- SLOG(Resolver, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(!path_.empty());
diff --git a/routing_table.cc b/routing_table.cc
index c3f578c..bf9e906 100644
--- a/routing_table.cc
+++ b/routing_table.cc
@@ -42,6 +42,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kRoute;
+static string ObjectID(RoutingTable *r) { return "(routing_table)"; }
+}
+
namespace {
base::LazyInstance<RoutingTable> g_routing_table = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -54,7 +59,7 @@
RoutingTable::RoutingTable()
: route_callback_(Bind(&RoutingTable::RouteMsgHandler, Unretained(this))),
rtnl_handler_(RTNLHandler::GetInstance()) {
- SLOG(Route, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
RoutingTable::~RoutingTable() {}
@@ -64,7 +69,7 @@
}
void RoutingTable::Start() {
- SLOG(Route, 2) << __func__;
+ SLOG(this, 2) << __func__;
route_listener_.reset(
new RTNLListener(RTNLHandler::kRequestRoute, route_callback_));
@@ -72,18 +77,18 @@
}
void RoutingTable::Stop() {
- SLOG(Route, 2) << __func__;
+ SLOG(this, 2) << __func__;
route_listener_.reset();
}
bool RoutingTable::AddRoute(int interface_index,
const RoutingTableEntry &entry) {
- SLOG(Route, 2) << __func__ << ": "
- << "destination " << entry.dst.ToString()
- << " index " << interface_index
- << " gateway " << entry.gateway.ToString()
- << " metric " << entry.metric;
+ SLOG(this, 2) << __func__ << ": "
+ << "destination " << entry.dst.ToString()
+ << " index " << interface_index
+ << " gateway " << entry.gateway.ToString()
+ << " metric " << entry.metric;
CHECK(!entry.from_rtnl);
if (!ApplyRoute(interface_index,
@@ -110,34 +115,34 @@
bool RoutingTable::GetDefaultRouteInternal(int interface_index,
IPAddress::Family family,
RoutingTableEntry **entry) {
- SLOG(Route, 2) << __func__ << " index " << interface_index
- << " family " << IPAddress::GetAddressFamilyName(family);
+ SLOG(this, 2) << __func__ << " index " << interface_index
+ << " family " << IPAddress::GetAddressFamilyName(family);
Tables::iterator table = tables_.find(interface_index);
if (table == tables_.end()) {
- SLOG(Route, 2) << __func__ << " no table";
+ SLOG(this, 2) << __func__ << " no table";
return false;
}
for (auto &nent : table->second) {
if (nent.dst.IsDefault() && nent.dst.family() == family) {
*entry = &nent;
- SLOG(Route, 2) << __func__ << ": found"
- << " gateway " << nent.gateway.ToString()
- << " metric " << nent.metric;
+ SLOG(this, 2) << __func__ << ": found"
+ << " gateway " << nent.gateway.ToString()
+ << " metric " << nent.metric;
return true;
}
}
- SLOG(Route, 2) << __func__ << " no route";
+ SLOG(this, 2) << __func__ << " no route";
return false;
}
bool RoutingTable::SetDefaultRoute(int interface_index,
const IPAddress &gateway_address,
uint32_t metric) {
- SLOG(Route, 2) << __func__ << " index " << interface_index
- << " metric " << metric;
+ SLOG(this, 2) << __func__ << " index " << interface_index
+ << " metric " << metric;
RoutingTableEntry *old_entry;
@@ -179,10 +184,10 @@
const vector<IPConfig::Route> &routes = ipconfig->properties().routes;
for (const auto &route : routes) {
- SLOG(Route, 3) << "Installing route:"
- << " Destination: " << route.host
- << " Netmask: " << route.netmask
- << " Gateway: " << route.gateway;
+ SLOG(this, 3) << "Installing route:"
+ << " Destination: " << route.host
+ << " Netmask: " << route.netmask
+ << " Gateway: " << route.gateway;
IPAddress destination_address(address_family);
IPAddress source_address(address_family); // Left as default.
IPAddress gateway_address(address_family);
@@ -214,7 +219,7 @@
}
void RoutingTable::FlushRoutes(int interface_index) {
- SLOG(Route, 2) << __func__;
+ SLOG(this, 2) << __func__;
auto table = tables_.find(interface_index);
if (table == tables_.end()) {
@@ -228,7 +233,7 @@
}
void RoutingTable::FlushRoutesWithTag(int tag) {
- SLOG(Route, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (auto &table : tables_) {
for (auto nent = table.second.begin(); nent != table.second.end();) {
@@ -247,8 +252,8 @@
}
void RoutingTable::SetDefaultMetric(int interface_index, uint32_t metric) {
- SLOG(Route, 2) << __func__ << " index " << interface_index
- << " metric " << metric;
+ SLOG(this, 2) << __func__ << " index " << interface_index
+ << " metric " << metric;
RoutingTableEntry *entry;
if (GetDefaultRouteInternal(
@@ -328,9 +333,9 @@
if (!route_queries_.empty() &&
message.route_status().protocol == RTPROT_UNSPEC) {
- SLOG(Route, 3) << __func__ << ": Message seq: " << message.seq()
- << " mode " << message.mode()
- << ", next query seq: " << route_queries_.front().sequence;
+ SLOG(this, 3) << __func__ << ": Message seq: " << message.seq()
+ << " mode " << message.mode()
+ << ", next query seq: " << route_queries_.front().sequence;
// Purge queries that have expired (sequence number of this message is
// greater than that of the head of the route query sequence). Do the
@@ -351,15 +356,15 @@
add_entry.tag = query.tag;
bool added = true;
if (add_entry.gateway.IsDefault()) {
- SLOG(Route, 2) << __func__ << ": Ignoring route result with no gateway "
- << "since we don't need to plumb these.";
+ SLOG(this, 2) << __func__ << ": Ignoring route result with no gateway "
+ << "since we don't need to plumb these.";
} else {
- SLOG(Route, 2) << __func__ << ": Adding host route to "
- << add_entry.dst.ToString();
+ SLOG(this, 2) << __func__ << ": Adding host route to "
+ << add_entry.dst.ToString();
added = AddRoute(interface_index, add_entry);
}
if (added && !query.callback.is_null()) {
- SLOG(Route, 2) << "Running query callback.";
+ SLOG(this, 2) << "Running query callback.";
query.callback.Run(interface_index, add_entry);
}
route_queries_.pop_front();
@@ -390,11 +395,11 @@
}
if (message.mode() == RTNLMessage::kModeAdd) {
- SLOG(Route, 2) << __func__ << " adding"
- << " destination " << entry.dst.ToString()
- << " index " << interface_index
- << " gateway " << entry.gateway.ToString()
- << " metric " << entry.metric;
+ SLOG(this, 2) << __func__ << " adding"
+ << " destination " << entry.dst.ToString()
+ << " index " << interface_index
+ << " gateway " << entry.gateway.ToString()
+ << " metric " << entry.metric;
table.push_back(entry);
}
}
@@ -403,7 +408,7 @@
const RoutingTableEntry &entry,
RTNLMessage::Mode mode,
unsigned int flags) {
- SLOG(Route, 2) << base::StringPrintf(
+ SLOG(this, 2) << base::StringPrintf(
"%s: dst %s/%d src %s/%d index %d mode %d flags 0x%x",
__func__, entry.dst.ToString().c_str(), entry.dst.prefix(),
entry.src.ToString().c_str(), entry.src.prefix(),
@@ -451,8 +456,8 @@
void RoutingTable::ReplaceMetric(uint32_t interface_index,
RoutingTableEntry *entry,
uint32_t metric) {
- SLOG(Route, 2) << __func__ << " index " << interface_index
- << " metric " << metric;
+ SLOG(this, 2) << __func__ << " index " << interface_index
+ << " metric " << metric;
RoutingTableEntry new_entry = *entry;
new_entry.metric = metric;
// First create the route at the new metric.
@@ -468,7 +473,7 @@
static const char *kPaths[2] = { kRouteFlushPath4, kRouteFlushPath6 };
bool ret = true;
- SLOG(Route, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (size_t i = 0; i < arraysize(kPaths); ++i) {
if (base::WriteFile(FilePath(kPaths[i]), "-1", 2) != 2) {
@@ -521,7 +526,7 @@
bool RoutingTable::CreateBlackholeRoute(int interface_index,
IPAddress::Family family,
uint32_t metric) {
- SLOG(Route, 2) << base::StringPrintf(
+ SLOG(this, 2) << base::StringPrintf(
"%s: index %d family %s metric %d",
__func__, interface_index,
IPAddress::GetAddressFamilyName(family).c_str(), metric);
@@ -567,9 +572,9 @@
IPAddress destination_address(remote_address);
destination_address.set_prefix(
IPAddress::GetMaxPrefixLength(remote_address.family()));
- SLOG(Route, 2) << "Creating link route to " << destination_address.ToString()
- << " from " << local_address.ToString()
- << " on interface index " << interface_index;
+ SLOG(this, 2) << "Creating link route to " << destination_address.ToString()
+ << " from " << local_address.ToString()
+ << " on interface index " << interface_index;
return AddRoute(interface_index,
RoutingTableEntry(destination_address,
local_address,
diff --git a/rpc_task_dbus_adaptor.cc b/rpc_task_dbus_adaptor.cc
index b9ec651..e4f68e2 100644
--- a/rpc_task_dbus_adaptor.cc
+++ b/rpc_task_dbus_adaptor.cc
@@ -13,6 +13,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(RPCTaskDBusAdaptor *r) { return r->GetRpcIdentifier(); }
+}
+
// static
const char RPCTaskDBusAdaptor::kPath[] = "/task/";
@@ -43,14 +48,14 @@
void RPCTaskDBusAdaptor::getsec(
string &user, string &password, DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << user;
+ SLOG(this, 2) << __func__ << ": " << user;
task_->GetLogin(&user, &password);
}
void RPCTaskDBusAdaptor::notify(const string &reason,
const map<string, string> &dict,
DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": " << reason;
+ SLOG(this, 2) << __func__ << ": " << reason;
task_->Notify(reason, dict);
}
diff --git a/scan_session.cc b/scan_session.cc
index 6884f38..9c95d76 100644
--- a/scan_session.cc
+++ b/scan_session.cc
@@ -29,6 +29,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static string ObjectID(ScanSession *s) { return "(scan_session)"; }
+}
+
const float ScanSession::kAllFrequencies = 1.1;
const uint64_t ScanSession::kScanRetryDelayMilliseconds = 200; // Arbitrary.
const size_t ScanSession::kScanRetryCount = 50;
@@ -75,9 +80,9 @@
}
}
- SLOG(WiFi, 6) << "Frequency connections vector:";
+ SLOG(this, 6) << "Frequency connections vector:";
for (const auto &freq_conn : frequency_list_) {
- SLOG(WiFi, 6) << " freq[" << freq_conn.frequency << "] = "
+ SLOG(this, 6) << " freq[" << freq_conn.frequency << "] = "
<< freq_conn.connection_count;
}
@@ -104,7 +109,7 @@
vector<uint16_t> frequencies;
WiFiProvider::FrequencyCountList::iterator freq_connect =
frequency_list_.begin();
- SLOG(WiFi, 7) << "Scanning for frequencies:";
+ SLOG(this, 7) << "Scanning for frequencies:";
while (freq_connect != frequency_list_.end()) {
if (frequencies.size() >= min_frequencies) {
if (total_connects_provided_ >= total_connects_wanted)
@@ -116,7 +121,7 @@
size_t connection_count = freq_connect->connection_count;
total_connects_provided_ += connection_count;
frequencies.push_back(frequency);
- SLOG(WiFi, 7) << " freq[" << frequency << "] = " << connection_count;
+ SLOG(this, 7) << " freq[" << frequency << "] = " << connection_count;
freq_connect = frequency_list_.erase(freq_connect);
}
@@ -156,11 +161,11 @@
trigger_scan.attributes()->SetNestedAttributeHasAValue(
NL80211_ATTR_SCAN_FREQUENCIES);
- SLOG(WiFi, 6) << "We have requested scan frequencies:";
+ SLOG(this, 6) << "We have requested scan frequencies:";
string attribute_name;
int i = 0;
for (const auto freq : scan_frequencies) {
- SLOG(WiFi, 6) << " " << freq;
+ SLOG(this, 6) << " " << freq;
attribute_name = StringPrintf("Frequency-%d", i);
frequency_list->CreateU32Attribute(i, attribute_name.c_str());
frequency_list->SetU32AttributeValue(i, freq);
@@ -238,7 +243,7 @@
return;
}
--scan_tries_left_;
- SLOG(WiFi, 3) << __func__ << " - trying again (" << scan_tries_left_
+ SLOG(this, 3) << __func__ << " - trying again (" << scan_tries_left_
<< " remaining after this)";
ebusy_timer_.Resume();
dispatcher_->PostDelayedTask(Bind(&ScanSession::ReInitiateScan,
@@ -249,7 +254,7 @@
found_error_ = true;
on_scan_failed_.Run();
} else {
- SLOG(WiFi, 6) << __func__ << ": Message ACKed";
+ SLOG(this, 6) << __func__ << ": Message ACKed";
}
}
break;
@@ -277,17 +282,17 @@
}
void ScanSession::ReportResults(int log_level) {
- SLOG(WiFi, log_level) << "------ ScanSession finished ------";
- SLOG(WiFi, log_level) << "Scanned "
+ SLOG(this, log_level) << "------ ScanSession finished ------";
+ SLOG(this, log_level) << "Scanned "
<< original_frequency_count_ - frequency_list_.size()
<< " frequencies (" << frequency_list_.size()
<< " remaining)";
if (found_error_) {
- SLOG(WiFi, log_level) << "ERROR encountered during scan ("
+ SLOG(this, log_level) << "ERROR encountered during scan ("
<< current_scan_frequencies_.size() << " frequencies"
<< " dangling - counted as scanned but, really, not)";
} else {
- SLOG(WiFi, log_level) << "No error encountered during scan.";
+ SLOG(this, log_level) << "No error encountered during scan.";
}
base::TimeDelta elapsed_time;
@@ -299,7 +304,7 @@
Metrics::kMetricTimeToScanMillisecondsMax,
Metrics::kMetricTimeToScanMillisecondsNumBuckets);
}
- SLOG(WiFi, log_level) << "Spent " << elapsed_time.InMillisecondsRoundedUp()
+ SLOG(this, log_level) << "Spent " << elapsed_time.InMillisecondsRoundedUp()
<< " milliseconds waiting for EBUSY.";
}
diff --git a/service.cc b/service.cc
index ed105e8..0e86377 100644
--- a/service.cc
+++ b/service.cc
@@ -42,6 +42,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kService;
+static string ObjectID(const Service *s) { return s->GetRpcIdentifier(); }
+}
+
const char Service::kAutoConnBusy[] = "busy";
const char Service::kAutoConnConnected[] = "connected";
const char Service::kAutoConnConnecting[] = "connecting";
@@ -277,7 +282,7 @@
Connect(&error, __func__);
} else {
if (reason == kAutoConnConnected || reason == kAutoConnBusy) {
- SLOG(Service, 1)
+ SLOG(this, 1)
<< "Suppressed autoconnect to service " << unique_name_ << " "
<< "(" << reason << ")";
} else {
@@ -598,60 +603,60 @@
}
void Service::Configure(const KeyValueStore &args, Error *error) {
- SLOG(Service, 5) << "Configuring bool properties:";
+ SLOG(this, 5) << "Configuring bool properties:";
for (const auto &bool_it : args.bool_properties()) {
if (ContainsKey(parameters_ignored_for_configure_, bool_it.first)) {
continue;
}
- SLOG(Service, 5) << " " << bool_it.first;
+ SLOG(this, 5) << " " << bool_it.first;
Error set_error;
store_.SetBoolProperty(bool_it.first, bool_it.second, &set_error);
if (error->IsSuccess() && set_error.IsFailure()) {
error->CopyFrom(set_error);
}
}
- SLOG(Service, 5) << "Configuring int32_t properties:";
+ SLOG(this, 5) << "Configuring int32_t properties:";
for (const auto &int_it : args.int_properties()) {
if (ContainsKey(parameters_ignored_for_configure_, int_it.first)) {
continue;
}
- SLOG(Service, 5) << " " << int_it.first;
+ SLOG(this, 5) << " " << int_it.first;
Error set_error;
store_.SetInt32Property(int_it.first, int_it.second, &set_error);
if (error->IsSuccess() && set_error.IsFailure()) {
error->CopyFrom(set_error);
}
}
- SLOG(Service, 5) << "Configuring string properties:";
+ SLOG(this, 5) << "Configuring string properties:";
for (const auto &string_it : args.string_properties()) {
if (ContainsKey(parameters_ignored_for_configure_, string_it.first)) {
continue;
}
- SLOG(Service, 5) << " " << string_it.first;
+ SLOG(this, 5) << " " << string_it.first;
Error set_error;
store_.SetStringProperty(string_it.first, string_it.second, &set_error);
if (error->IsSuccess() && set_error.IsFailure()) {
error->CopyFrom(set_error);
}
}
- SLOG(Service, 5) << "Configuring string array properties:";
+ SLOG(this, 5) << "Configuring string array properties:";
for (const auto &strings_it : args.strings_properties()) {
if (ContainsKey(parameters_ignored_for_configure_, strings_it.first)) {
continue;
}
- SLOG(Service, 5) << " " << strings_it.first;
+ SLOG(this, 5) << " " << strings_it.first;
Error set_error;
store_.SetStringsProperty(strings_it.first, strings_it.second, &set_error);
if (error->IsSuccess() && set_error.IsFailure()) {
error->CopyFrom(set_error);
}
}
- SLOG(Service, 5) << "Configuring string map properties:";
+ SLOG(this, 5) << "Configuring string map properties:";
for (const auto &stringmap_it : args.stringmap_properties()) {
if (ContainsKey(parameters_ignored_for_configure_, stringmap_it.first)) {
continue;
}
- SLOG(Service, 5) << " " << stringmap_it.first;
+ SLOG(this, 5) << " " << stringmap_it.first;
Error set_error;
store_.SetStringmapProperty(
stringmap_it.first, stringmap_it.second, &set_error);
@@ -662,9 +667,9 @@
}
bool Service::DoPropertiesMatch(const KeyValueStore &args) const {
- SLOG(Service, 5) << "Checking bool properties:";
+ SLOG(this, 5) << "Checking bool properties:";
for (const auto &bool_it : args.bool_properties()) {
- SLOG(Service, 5) << " " << bool_it.first;
+ SLOG(this, 5) << " " << bool_it.first;
Error get_error;
bool value;
if (!store_.GetBoolProperty(bool_it.first, &value, &get_error) ||
@@ -672,9 +677,9 @@
return false;
}
}
- SLOG(Service, 5) << "Checking int32_t properties:";
+ SLOG(this, 5) << "Checking int32_t properties:";
for (const auto &int_it : args.int_properties()) {
- SLOG(Service, 5) << " " << int_it.first;
+ SLOG(this, 5) << " " << int_it.first;
Error get_error;
int32_t value;
if (!store_.GetInt32Property(int_it.first, &value, &get_error) ||
@@ -682,9 +687,9 @@
return false;
}
}
- SLOG(Service, 5) << "Checking string properties:";
+ SLOG(this, 5) << "Checking string properties:";
for (const auto &string_it : args.string_properties()) {
- SLOG(Service, 5) << " " << string_it.first;
+ SLOG(this, 5) << " " << string_it.first;
Error get_error;
string value;
if (!store_.GetStringProperty(string_it.first, &value, &get_error) ||
@@ -692,9 +697,9 @@
return false;
}
}
- SLOG(Service, 5) << "Checking string array properties:";
+ SLOG(this, 5) << "Checking string array properties:";
for (const auto &strings_it : args.strings_properties()) {
- SLOG(Service, 5) << " " << strings_it.first;
+ SLOG(this, 5) << " " << strings_it.first;
Error get_error;
vector<string> value;
if (!store_.GetStringsProperty(strings_it.first, &value, &get_error) ||
@@ -901,22 +906,22 @@
}
void Service::NoteDisconnectEvent() {
- SLOG(Service, 2) << __func__;
+ SLOG(this, 2) << __func__;
// Ignore the event if it's user-initiated explicit disconnect.
if (explicitly_disconnected_) {
- SLOG(Service, 2) << "Explicit disconnect ignored.";
+ SLOG(this, 2) << "Explicit disconnect ignored.";
return;
}
// Ignore the event if manager is not running (e.g., service disconnects on
// shutdown).
if (!manager_->running()) {
- SLOG(Service, 2) << "Disconnect while manager stopped ignored.";
+ SLOG(this, 2) << "Disconnect while manager stopped ignored.";
return;
}
// Ignore the event if the system is suspending.
PowerManager *power_manager = manager_->power_manager();
if (!power_manager || power_manager->suspending()) {
- SLOG(Service, 2) << "Disconnect in transitional power state ignored.";
+ SLOG(this, 2) << "Disconnect in transitional power state ignored.";
return;
}
int period = 0;
@@ -936,7 +941,7 @@
threshold = kReportMisconnectsThreshold;
events = &misconnects_;
} else {
- SLOG(Service, 2)
+ SLOG(this, 2)
<< "Not connected or connecting, state transition ignored.";
return;
}
@@ -1109,10 +1114,10 @@
void Service::set_profile(const ProfileRefPtr &p) { profile_ = p; }
void Service::SetProfile(const ProfileRefPtr &p) {
- SLOG(Service, 2) << "SetProfile from "
- << (profile_ ? profile_->GetFriendlyName() : "(none)")
- << " to " << (p ? p->GetFriendlyName() : "(none)")
- << ".";
+ SLOG(this, 2) << "SetProfile from "
+ << (profile_ ? profile_->GetFriendlyName() : "(none)")
+ << " to " << (p ? p->GetFriendlyName() : "(none)")
+ << ".";
if (profile_ == p) {
return;
}
@@ -1126,7 +1131,7 @@
}
void Service::OnPropertyChanged(const string &property) {
- SLOG(Service, 1) << __func__ << " " << property;
+ SLOG(this, 1) << __func__ << " " << property;
if (Is8021x() && EapCredentials::IsEapAuthenticationProperty(property)) {
OnEapCredentialsChanged(kReasonPropertyUpdate);
}
diff --git a/service_dbus_adaptor.cc b/service_dbus_adaptor.cc
index 8b2720f..94af00b 100644
--- a/service_dbus_adaptor.cc
+++ b/service_dbus_adaptor.cc
@@ -17,6 +17,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(ServiceDBusAdaptor *s) { return s->GetRpcIdentifier(); }
+}
+
// static
const char ServiceDBusAdaptor::kPath[] = "/service/";
@@ -30,66 +35,66 @@
void ServiceDBusAdaptor::UpdateConnected() {}
void ServiceDBusAdaptor::EmitBoolChanged(const string &name, bool value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
}
void ServiceDBusAdaptor::EmitUint8Changed(const string &name, uint8_t value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::ByteToVariant(value));
}
void ServiceDBusAdaptor::EmitUint16Changed(const string &name, uint16_t value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Uint16ToVariant(value));
}
void ServiceDBusAdaptor::EmitUint16sChanged(const string &name,
const Uint16s &value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Uint16sToVariant(value));
}
void ServiceDBusAdaptor::EmitUintChanged(const string &name, uint32_t value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
}
void ServiceDBusAdaptor::EmitIntChanged(const string &name, int value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
}
void ServiceDBusAdaptor::EmitRpcIdentifierChanged(const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::PathToVariant(value));
}
void ServiceDBusAdaptor::EmitStringChanged(const string &name,
const string &value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::StringToVariant(value));
}
void ServiceDBusAdaptor::EmitStringmapChanged(const string &name,
const Stringmap &value) {
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
PropertyChanged(name, DBusAdaptor::StringmapToVariant(value));
}
map<string, DBus::Variant> ServiceDBusAdaptor::GetProperties(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
map<string, DBus::Variant> properties;
DBusAdaptor::GetProperties(service_->store(), &properties, &error);
return properties;
@@ -98,14 +103,14 @@
void ServiceDBusAdaptor::SetProperty(const string &name,
const DBus::Variant &value,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
DBusAdaptor::SetProperty(service_->mutable_store(), name, value, &error);
}
void ServiceDBusAdaptor::SetProperties(const map<string, DBus::Variant> &args,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
KeyValueStore args_store;
Error key_value_store_error;
DBusAdaptor::ArgsToKeyValueStore(args, &args_store, &key_value_store_error);
@@ -119,7 +124,7 @@
void ServiceDBusAdaptor::ClearProperty(const string &name,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name()
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name()
<< " " << name;
DBusAdaptor::ClearProperty(service_->mutable_store(), name, &error);
if (!error.is_set()) {
@@ -129,7 +134,7 @@
vector<bool> ServiceDBusAdaptor::ClearProperties(
const vector<string> &names, DBus::Error &/*error*/) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
vector<bool> results;
vector<string>::const_iterator it;
for (it = names.begin(); it != names.end(); ++it) {
@@ -141,21 +146,21 @@
}
void ServiceDBusAdaptor::Connect(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
Error e;
service_->UserInitiatedConnect(&e);
e.ToDBusError(&error);
}
void ServiceDBusAdaptor::Disconnect(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
Error e;
service_->UserInitiatedDisconnect(&e);
e.ToDBusError(&error);
}
void ServiceDBusAdaptor::Remove(DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
Error e;
service_->Remove(&e);
e.ToDBusError(&error);
@@ -163,7 +168,7 @@
void ServiceDBusAdaptor::ActivateCellularModem(const string &carrier,
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
Error e(Error::kOperationInitiated);
DBus::Tag *tag = new DBus::Tag();
service_->ActivateCellularModem(carrier, &e, GetMethodReplyCallback(tag));
@@ -172,7 +177,7 @@
void ServiceDBusAdaptor::CompleteCellularActivation(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
Error e;
service_->CompleteCellularActivation(&e);
e.ToDBusError(&error);
@@ -180,7 +185,7 @@
map<DBus::Path, string> ServiceDBusAdaptor::GetLoadableProfileEntries(
DBus::Error &error) { // NOLINT
- SLOG(DBus, 2) << __func__ << ": Service " << service_->unique_name();
+ SLOG(this, 2) << __func__ << ": Service " << service_->unique_name();
map<string, string> profile_entry_strings =
service_->GetLoadableProfileEntries();
map<DBus::Path, string> profile_entries;
diff --git a/shill_daemon.cc b/shill_daemon.cc
index 1cfe159..c65bd53 100644
--- a/shill_daemon.cc
+++ b/shill_daemon.cc
@@ -26,6 +26,12 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDaemon;
+static string ObjectID(Daemon *d) { return "(shill_daemon)"; }
+}
+
+
Daemon::Daemon(Config *config, ControlInterface *control)
: config_(config),
control_(control),
@@ -57,22 +63,22 @@
void Daemon::Run() {
Start();
- SLOG(Daemon, 1) << "Running main loop.";
+ SLOG(this, 1) << "Running main loop.";
dispatcher_.DispatchForever();
- SLOG(Daemon, 1) << "Exited main loop.";
+ SLOG(this, 1) << "Exited main loop.";
}
void Daemon::Quit() {
- SLOG(Daemon, 1) << "Starting termination actions.";
+ SLOG(this, 1) << "Starting termination actions.";
if (!manager_->RunTerminationActionsAndNotifyMetrics(
Bind(&Daemon::TerminationActionsCompleted, Unretained(this)))) {
- SLOG(Daemon, 1) << "No termination actions were run";
+ SLOG(this, 1) << "No termination actions were run";
StopAndReturnToMain();
}
}
void Daemon::TerminationActionsCompleted(const Error &error) {
- SLOG(Daemon, 1) << "Finished termination actions. Result: " << error;
+ SLOG(this, 1) << "Finished termination actions. Result: " << error;
metrics_->NotifyTerminationActionsCompleted(error.IsSuccess());
// Daemon::TerminationActionsCompleted() should not directly call
diff --git a/shill_main.cc b/shill_main.cc
index 59526cb..b5fa360 100644
--- a/shill_main.cc
+++ b/shill_main.cc
@@ -64,6 +64,10 @@
} // namespace
+namespace Logging {
+static string ObjectID(shill::Daemon *d) { return "(shill_main_daemon)"; }
+}
+
// Always logs to the syslog and logs to stderr if
// we are running in the foreground.
void SetupLogging(bool foreground, char *daemon_name) {
@@ -107,7 +111,7 @@
}
void DeleteDBusControl(void* param) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
shill::DBusControl* dbus_control =
reinterpret_cast<shill::DBusControl*>(param);
delete dbus_control;
diff --git a/socket_info_reader.cc b/socket_info_reader.cc
index 155bf2b..bfdb065 100644
--- a/socket_info_reader.cc
+++ b/socket_info_reader.cc
@@ -19,6 +19,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kLink;
+static string ObjectID(SocketInfoReader *s) { return "(socket_info_reader)"; }
+}
+
namespace {
const char kTcpv4SocketInfoFilePath[] = "/proc/net/tcp";
@@ -51,7 +56,7 @@
vector<SocketInfo> *info_list) {
FileReader file_reader;
if (!file_reader.Open(info_file_path)) {
- SLOG(Link, 2) << __func__ << ": Failed to open '"
+ SLOG(this, 2) << __func__ << ": Failed to open '"
<< info_file_path.value() << "'.";
return false;
}
diff --git a/subscription_state_out_of_credits_detector.cc b/subscription_state_out_of_credits_detector.cc
index 5ee3419..fa7c073 100644
--- a/subscription_state_out_of_credits_detector.cc
+++ b/subscription_state_out_of_credits_detector.cc
@@ -4,12 +4,22 @@
#include "shill/subscription_state_out_of_credits_detector.h"
+#include <string>
+
#include "ModemManager/ModemManager.h"
+#include "shill/cellular_service.h"
#include "shill/logging.h"
+using std::string;
+
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kCellular;
+static string ObjectID(CellularService *c) { return c->GetRpcIdentifier(); }
+}
+
SubscriptionStateOutOfCreditsDetector::SubscriptionStateOutOfCreditsDetector(
EventDispatcher *dispatcher,
Manager *manager,
@@ -28,9 +38,9 @@
MM_MODEM_3GPP_SUBSCRIPTION_STATE_OUT_OF_DATA);
if (ooc != out_of_credits()) {
if (ooc)
- SLOG(Cellular, 2) << "Marking service out-of-credits";
+ SLOG(service(), 2) << "Marking service out-of-credits";
else
- SLOG(Cellular, 2) << "Marking service as not out-of-credits";
+ SLOG(service(), 2) << "Marking service as not out-of-credits";
}
ReportOutOfCredits(ooc);
}
diff --git a/supplicant_bss_proxy.cc b/supplicant_bss_proxy.cc
index d8494f9..7f782cc 100644
--- a/supplicant_bss_proxy.cc
+++ b/supplicant_bss_proxy.cc
@@ -17,6 +17,12 @@
namespace shill {
+namespace Logging {
+static string ObjectID(SupplicantBSSProxy *s) {
+ return "(supplicant_bss_proxy)";
+}
+}
+
SupplicantBSSProxy::SupplicantBSSProxy(
WiFiEndpoint *wifi_endpoint,
DBus::Connection *bus,
@@ -38,7 +44,7 @@
void SupplicantBSSProxy::Proxy::PropertiesChanged(
const std::map<string, ::DBus::Variant> &properties) {
- SLOG(DBus, 2) << __func__;
+ SLOG(DBus, nullptr, 2) << __func__;
wifi_endpoint_->PropertiesChanged(properties);
}
diff --git a/supplicant_interface_proxy.cc b/supplicant_interface_proxy.cc
index 9c904b2..76da6d6 100644
--- a/supplicant_interface_proxy.cc
+++ b/supplicant_interface_proxy.cc
@@ -17,6 +17,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p; }
+}
+
SupplicantInterfaceProxy::SupplicantInterfaceProxy(
SupplicantEventDelegateInterface *delegate,
DBus::Connection *bus,
@@ -28,7 +33,7 @@
::DBus::Path SupplicantInterfaceProxy::AddNetwork(
const map<string, ::DBus::Variant> &args) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.AddNetwork(args);
} catch (const DBus::Error &e) {
@@ -39,7 +44,7 @@
}
void SupplicantInterfaceProxy::EnableHighBitrates() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.EnableHighBitrates();
} catch (const DBus::Error &e) {
@@ -49,7 +54,7 @@
}
void SupplicantInterfaceProxy::EAPLogoff() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.EAPLogoff();
} catch (const DBus::Error &e) {
@@ -59,7 +64,7 @@
}
void SupplicantInterfaceProxy::EAPLogon() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.EAPLogon();
} catch (const DBus::Error &e) {
@@ -69,7 +74,7 @@
}
void SupplicantInterfaceProxy::Disconnect() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Disconnect();
} catch (const DBus::Error &e) {
@@ -79,7 +84,7 @@
}
void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.FlushBSS(age);
} catch (const DBus::Error &e) {
@@ -91,7 +96,7 @@
void SupplicantInterfaceProxy::NetworkReply(const ::DBus::Path &network,
const string &field,
const string &value) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.NetworkReply(network, field, value);
} catch (const DBus::Error &e) {
@@ -101,7 +106,7 @@
}
void SupplicantInterfaceProxy::Reassociate() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Reassociate();
} catch (const DBus::Error &e) {
@@ -111,7 +116,7 @@
}
void SupplicantInterfaceProxy::Reattach() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Reattach();
} catch (const DBus::Error &e) {
@@ -121,7 +126,7 @@
}
void SupplicantInterfaceProxy::RemoveAllNetworks() {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.RemoveAllNetworks();
} catch (const DBus::Error &e) {
@@ -130,7 +135,7 @@
}
void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.RemoveNetwork(network);
} catch (const DBus::Error &e) {
@@ -140,7 +145,7 @@
}
void SupplicantInterfaceProxy::Scan(const map<string, ::DBus::Variant> &args) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Scan(args);
} catch (const DBus::Error &e) {
@@ -151,7 +156,7 @@
}
void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.SelectNetwork(network);
} catch (const DBus::Error &e) {
@@ -161,7 +166,7 @@
void SupplicantInterfaceProxy::SetHT40Enable(const ::DBus::Path &network,
bool enable) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.SetHT40Enable(network, enable);
} catch (const DBus::Error &e) {
@@ -170,7 +175,7 @@
}
void SupplicantInterfaceProxy::SetFastReauth(bool enabled) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.FastReauth(enabled);
} catch (const DBus::Error &e) {
@@ -181,7 +186,7 @@
}
void SupplicantInterfaceProxy::SetRoamThreshold(uint16_t threshold) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
proxy_.RoamThreshold(threshold);
return;
@@ -193,7 +198,7 @@
}
void SupplicantInterfaceProxy::SetScanInterval(int32_t scan_interval) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.ScanInterval(scan_interval);
} catch (const DBus::Error &e) {
@@ -205,7 +210,7 @@
void SupplicantInterfaceProxy::SetDisableHighBitrates(
bool disable_high_bitrates) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.DisableHighBitrates(disable_high_bitrates);
} catch (const DBus::Error &e) {
@@ -216,7 +221,7 @@
}
void SupplicantInterfaceProxy::TDLSDiscover(const string &peer) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.TDLSDiscover(peer);
} catch (const DBus::Error &e) {
@@ -226,7 +231,7 @@
}
void SupplicantInterfaceProxy::TDLSSetup(const string &peer) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.TDLSSetup(peer);
} catch (const DBus::Error &e) {
@@ -236,7 +241,7 @@
}
string SupplicantInterfaceProxy::TDLSStatus(const string &peer) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.TDLSStatus(peer);
} catch (const DBus::Error &e) {
@@ -246,7 +251,7 @@
}
void SupplicantInterfaceProxy::TDLSTeardown(const string &peer) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.TDLSTeardown(peer);
} catch (const DBus::Error &e) {
@@ -266,68 +271,68 @@
SupplicantInterfaceProxy::Proxy::~Proxy() {}
void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
void SupplicantInterfaceProxy::Proxy::BSSAdded(
const ::DBus::Path &BSS,
const std::map<string, ::DBus::Variant> &properties) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
delegate_->BSSAdded(BSS, properties);
}
void SupplicantInterfaceProxy::Proxy::Certification(
const std::map<string, ::DBus::Variant> &properties) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
delegate_->Certification(properties);
}
void SupplicantInterfaceProxy::Proxy::EAP(
const string &status, const string ¶meter) {
- SLOG(DBus, 2) << __func__ << ": status " << status
+ SLOG(&path(), 2) << __func__ << ": status " << status
<< ", parameter " << parameter;
delegate_->EAPEvent(status, parameter);
}
void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
delegate_->BSSRemoved(BSS);
}
void SupplicantInterfaceProxy::Proxy::NetworkAdded(
const ::DBus::Path &/*network*/,
const std::map<string, ::DBus::Variant> &/*properties*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
void SupplicantInterfaceProxy::Proxy::NetworkRemoved(
const ::DBus::Path &/*network*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// TODO(quiche): Pass this up to the delegate, so that it can clean its
// rpcid_by_service_ map. crbug.com/207648
}
void SupplicantInterfaceProxy::Proxy::NetworkSelected(
const ::DBus::Path &/*network*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
void SupplicantInterfaceProxy::Proxy::PropertiesChanged(
const std::map<string, ::DBus::Variant> &properties) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
delegate_->PropertiesChanged(properties);
}
void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) {
- SLOG(DBus, 2) << __func__ << ": " << success;
+ SLOG(&path(), 2) << __func__ << ": " << success;
if (success) {
delegate_->ScanDone();
}
diff --git a/supplicant_network_proxy.cc b/supplicant_network_proxy.cc
index 309f306..d97fba7 100644
--- a/supplicant_network_proxy.cc
+++ b/supplicant_network_proxy.cc
@@ -16,6 +16,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p; }
+}
+
SupplicantNetworkProxy::SupplicantNetworkProxy(
DBus::Connection *bus,
const ::DBus::Path &object_path,
@@ -25,7 +30,7 @@
SupplicantNetworkProxy::~SupplicantNetworkProxy() {}
void SupplicantNetworkProxy::SetEnabled(bool enabled) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Enabled(enabled);
} catch (const DBus::Error &e) {
@@ -45,7 +50,7 @@
void SupplicantNetworkProxy::Proxy::PropertiesChanged(
const map<string, ::DBus::Variant> &properties) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// TODO(pstew): Some day we could notify someone about this state change.
}
diff --git a/supplicant_process_proxy.cc b/supplicant_process_proxy.cc
index 771f47b..3369a12 100644
--- a/supplicant_process_proxy.cc
+++ b/supplicant_process_proxy.cc
@@ -17,6 +17,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p; }
+}
+
SupplicantProcessProxy::SupplicantProcessProxy(DBus::Connection *bus,
const char *dbus_path,
const char *dbus_addr)
@@ -26,7 +31,7 @@
::DBus::Path SupplicantProcessProxy::CreateInterface(
const map<string, ::DBus::Variant> &args) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.CreateInterface(args);
} catch (const DBus::Error &e) {
@@ -37,7 +42,7 @@
}
void SupplicantProcessProxy::RemoveInterface(const ::DBus::Path &path) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.RemoveInterface(path);
} catch (const DBus::Error &e) {
@@ -46,7 +51,7 @@
}
::DBus::Path SupplicantProcessProxy::GetInterface(const string &ifname) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.GetInterface(ifname);
} catch (const DBus::Error &e) {
@@ -84,19 +89,19 @@
void SupplicantProcessProxy::Proxy::InterfaceAdded(
const ::DBus::Path& /*path*/,
const map<string, ::DBus::Variant> &/*properties*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
void SupplicantProcessProxy::Proxy::InterfaceRemoved(
const ::DBus::Path& /*path*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
void SupplicantProcessProxy::Proxy::PropertiesChanged(
const map<string, ::DBus::Variant>& /*properties*/) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
// XXX
}
diff --git a/traffic_monitor.cc b/traffic_monitor.cc
index 1969362..edc34ed 100644
--- a/traffic_monitor.cc
+++ b/traffic_monitor.cc
@@ -20,6 +20,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kLink;
+static string ObjectID(Device *d) { return d->link_name(); }
+}
+
// static
const uint16_t TrafficMonitor::kDnsPort = 53;
const int64_t TrafficMonitor::kDnsTimedOutThresholdSeconds = 15;
@@ -41,7 +46,7 @@
}
void TrafficMonitor::Start() {
- SLOG(Link, 2) << __func__;
+ SLOG(device_, 2) << __func__;
Stop();
sample_traffic_callback_.Reset(base::Bind(&TrafficMonitor::SampleTraffic,
@@ -51,7 +56,7 @@
}
void TrafficMonitor::Stop() {
- SLOG(Link, 2) << __func__;
+ SLOG(device_, 2) << __func__;
sample_traffic_callback_.Cancel();
ResetCongestedTxQueuesStats();
ResetDnsFailingStats();
@@ -62,31 +67,32 @@
}
void TrafficMonitor::ResetCongestedTxQueuesStatsWithLogging() {
- SLOG(Link, 2) << __func__ << ": Tx-queues decongested";
+ SLOG(device_, 2) << __func__ << ": Tx-queues decongested";
ResetCongestedTxQueuesStats();
}
void TrafficMonitor::BuildIPPortToTxQueueLength(
const vector<SocketInfo> &socket_infos,
IPPortToTxQueueLengthMap *tx_queue_lengths) {
- SLOG(Link, 3) << __func__;
+ SLOG(device_, 3) << __func__;
string device_ip_address = device_->ipconfig()->properties().address;
for (const auto &info : socket_infos) {
- SLOG(Link, 4) << "SocketInfo(IP=" << info.local_ip_address().ToString()
- << ", TX=" << info.transmit_queue_value()
- << ", State=" << info.connection_state()
- << ", TimerState=" << info.timer_state();
+ SLOG(device_, 4) << "SocketInfo(IP=" << info.local_ip_address().ToString()
+ << ", TX=" << info.transmit_queue_value()
+ << ", State=" << info.connection_state()
+ << ", TimerState=" << info.timer_state();
if (info.local_ip_address().ToString() != device_ip_address ||
info.transmit_queue_value() == 0 ||
info.connection_state() != SocketInfo::kConnectionStateEstablished ||
(info.timer_state() != SocketInfo::kTimerStateRetransmitTimerPending &&
info.timer_state() !=
SocketInfo::kTimerStateZeroWindowProbeTimerPending)) {
- SLOG(Link, 4) << "Connection Filtered.";
+ SLOG(device_, 4) << "Connection Filtered.";
continue;
}
- SLOG(Link, 3) << "Monitoring connection: TX=" << info.transmit_queue_value()
- << " TimerState=" << info.timer_state();
+ SLOG(device_, 3) << "Monitoring connection: TX="
+ << info.transmit_queue_value()
+ << " TimerState=" << info.timer_state();
string local_ip_port =
StringPrintf("%s:%d",
@@ -97,11 +103,11 @@
}
bool TrafficMonitor::IsCongestedTxQueues() {
- SLOG(Link, 4) << __func__;
+ SLOG(device_, 4) << __func__;
vector<SocketInfo> socket_infos;
if (!socket_info_reader_->LoadTcpSocketInfo(&socket_infos) ||
socket_infos.empty()) {
- SLOG(Link, 3) << __func__ << ": Empty socket info";
+ SLOG(device_, 3) << __func__ << ": Empty socket info";
ResetCongestedTxQueuesStatsWithLogging();
return false;
}
@@ -109,7 +115,7 @@
IPPortToTxQueueLengthMap curr_tx_queue_lengths;
BuildIPPortToTxQueueLength(socket_infos, &curr_tx_queue_lengths);
if (curr_tx_queue_lengths.empty()) {
- SLOG(Link, 3) << __func__ << ": No interesting socket info";
+ SLOG(device_, 3) << __func__ << ": No interesting socket info";
ResetCongestedTxQueuesStatsWithLogging();
} else {
for (const auto &length_entry : old_tx_queue_lengths_) {
@@ -127,9 +133,9 @@
}
if (congested_tx_queues) {
++accummulated_congested_tx_queues_samples_;
- SLOG(Link, 2) << __func__
- << ": Congested tx-queues detected ("
- << accummulated_congested_tx_queues_samples_ << ")";
+ SLOG(device_, 2) << __func__
+ << ": Congested tx-queues detected ("
+ << accummulated_congested_tx_queues_samples_ << ")";
}
}
old_tx_queue_lengths_ = curr_tx_queue_lengths;
@@ -142,16 +148,16 @@
}
void TrafficMonitor::ResetDnsFailingStatsWithLogging() {
- SLOG(Link, 2) << __func__ << ": DNS queries restored";
+ SLOG(device_, 2) << __func__ << ": DNS queries restored";
ResetDnsFailingStats();
}
bool TrafficMonitor::IsDnsFailing() {
- SLOG(Link, 4) << __func__;
+ SLOG(device_, 4) << __func__;
vector<ConnectionInfo> connection_infos;
if (!connection_info_reader_->LoadConnectionInfo(&connection_infos) ||
connection_infos.empty()) {
- SLOG(Link, 3) << __func__ << ": Empty connection info";
+ SLOG(device_, 3) << __func__ << ": Empty connection info";
} else {
// The time-to-expire counter is used to determine when a DNS request
// has timed out. This counter is the number of seconds remaining until
@@ -177,9 +183,9 @@
continue;
++accummulated_dns_failures_samples_;
- SLOG(Link, 2) << __func__
- << ": DNS failures detected ("
- << accummulated_dns_failures_samples_ << ")";
+ SLOG(device_, 2) << __func__
+ << ": DNS failures detected ("
+ << accummulated_dns_failures_samples_ << ")";
return true;
}
}
@@ -188,7 +194,7 @@
}
void TrafficMonitor::SampleTraffic() {
- SLOG(Link, 3) << __func__;
+ SLOG(device_, 3) << __func__;
// Schedule the sample callback first, so it is possible for the network
// problem callback to stop the traffic monitor.
diff --git a/virtio_ethernet.cc b/virtio_ethernet.cc
index d12c76c..70f3151 100644
--- a/virtio_ethernet.cc
+++ b/virtio_ethernet.cc
@@ -17,6 +17,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kEthernet;
+static string ObjectID(VirtioEthernet *v) { return v->GetRpcIdentifier(); }
+}
+
VirtioEthernet::VirtioEthernet(ControlInterface *control_interface,
EventDispatcher *dispatcher,
Metrics *metrics,
@@ -31,7 +36,7 @@
link_name,
address,
interface_index) {
- SLOG(Ethernet, 2) << "VirtioEthernet device " << link_name << " initialized.";
+ SLOG(this, 2) << "VirtioEthernet device " << link_name << " initialized.";
}
VirtioEthernet::~VirtioEthernet() {
@@ -51,9 +56,9 @@
// transmit any frames. (See crbug.com/212041)
//
// To avoid this, we sleep to let the device setup function complete.
- SLOG(Ethernet, 2) << "Sleeping to let virtio initialize.";
+ SLOG(this, 2) << "Sleeping to let virtio initialize.";
sleep(2);
- SLOG(Ethernet, 2) << "Starting virtio Ethernet.";
+ SLOG(this, 2) << "Starting virtio Ethernet.";
Ethernet::Start(error, callback);
}
diff --git a/virtual_device.cc b/virtual_device.cc
index 71f7562..1a3f8c8 100644
--- a/virtual_device.cc
+++ b/virtual_device.cc
@@ -14,6 +14,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDevice;
+static string ObjectID(VirtualDevice *v) { return "(virtual_device)"; }
+}
+
namespace {
const char kHardwareAddressEmpty[] = "";
} // namespace
@@ -56,7 +61,7 @@
}
void VirtualDevice::UpdateIPConfig(const IPConfig::Properties &properties) {
- SLOG(Device, 2) << __func__ << " on " << link_name();
+ SLOG(this, 2) << __func__ << " on " << link_name();
if (!ipconfig()) {
set_ipconfig(new IPConfig(control_interface(), link_name()));
}
diff --git a/vpn_driver.cc b/vpn_driver.cc
index 468d185..9d7bc72 100644
--- a/vpn_driver.cc
+++ b/vpn_driver.cc
@@ -23,6 +23,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kVPN;
+static string ObjectID(VPNDriver *v) { return "(vpn_driver)"; }
+}
+
// static
const int VPNDriver::kDefaultConnectTimeoutSeconds = 60;
@@ -40,7 +45,7 @@
VPNDriver::~VPNDriver() {}
bool VPNDriver::Load(StoreInterface *storage, const string &storage_id) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (size_t i = 0; i < property_count_; i++) {
if ((properties_[i].flags & Property::kEphemeral)) {
continue;
@@ -73,7 +78,7 @@
bool VPNDriver::Save(StoreInterface *storage,
const string &storage_id,
bool save_credentials) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (size_t i = 0; i < property_count_; i++) {
if ((properties_[i].flags & Property::kEphemeral)) {
continue;
@@ -107,7 +112,7 @@
}
void VPNDriver::UnloadCredentials() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (size_t i = 0; i < property_count_; i++) {
if ((properties_[i].flags &
(Property::kEphemeral | Property::kCredential))) {
@@ -117,7 +122,7 @@
}
void VPNDriver::InitPropertyStore(PropertyStore *store) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
for (size_t i = 0; i < property_count_; i++) {
if (properties_[i].flags & Property::kArray) {
store->RegisterDerivedStrings(
@@ -212,7 +217,7 @@
}
KeyValueStore VPNDriver::GetProvider(Error *error) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
string provider_prefix = string(kProviderProperty) + ".";
KeyValueStore provider_properties;
@@ -262,7 +267,7 @@
}
void VPNDriver::StopConnectTimeout() {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
connect_timeout_callback_.Cancel();
connect_timeout_seconds_ = 0;
}
diff --git a/vpn_provider.cc b/vpn_provider.cc
index f10d4e4..d685036 100644
--- a/vpn_provider.cc
+++ b/vpn_provider.cc
@@ -25,6 +25,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kVPN;
+static string ObjectID(const VPNProvider *v) { return "(vpn_provider)"; }
+}
+
VPNProvider::VPNProvider(ControlInterface *control_interface,
EventDispatcher *dispatcher,
Metrics *metrics,
@@ -46,7 +51,7 @@
string *name_ptr,
string *host_ptr,
Error *error) {
- SLOG(VPN, 2) << __func__;
+ SLOG(nullptr, 2) << __func__;
string type = args.LookupString(kProviderTypeProperty, "");
if (type.empty()) {
Error::PopulateAndLog(
@@ -70,7 +75,7 @@
ServiceRefPtr VPNProvider::GetService(const KeyValueStore &args,
Error *error) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
string type;
string name;
string host;
@@ -94,7 +99,7 @@
ServiceRefPtr VPNProvider::FindSimilarService(const KeyValueStore &args,
Error *error) const {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
string type;
string name;
string host;
@@ -131,7 +136,7 @@
}
void VPNProvider::CreateServicesFromProfile(const ProfileRefPtr &profile) {
- SLOG(VPN, 2) << __func__;
+ SLOG(this, 2) << __func__;
const StoreInterface *storage = profile->GetConstStorage();
for (const auto &group : storage->GetGroupsWithKey(kProviderTypeProperty)) {
if (!StartsWithASCII(group, "vpn_", false)) {
@@ -163,7 +168,7 @@
if (service != nullptr) {
// If the service already exists, it does not need to be configured,
// since PushProfile would have already called ConfigureService on it.
- SLOG(VPN, 2) << "Service already exists " << group;
+ SLOG(this, 2) << "Service already exists " << group;
continue;
}
@@ -186,8 +191,8 @@
const string &name,
const string &storage_id,
Error *error) {
- SLOG(VPN, 2) << __func__ << " type " << type << " name " << name
- << " storage id " << storage_id;
+ SLOG(this, 2) << __func__ << " type " << type << " name " << name
+ << " storage id " << storage_id;
#if defined(DISABLE_VPN)
Error::PopulateAndLog(error, Error::kNotSupported, "VPN is not supported.");
diff --git a/wake_on_wifi.cc b/wake_on_wifi.cc
index 286fcc5..8699415 100644
--- a/wake_on_wifi.cc
+++ b/wake_on_wifi.cc
@@ -36,6 +36,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static std::string ObjectID(WakeOnWiFi *w) { return "(wake_on_wifi)"; }
+}
+
const char WakeOnWiFi::kWakeOnIPAddressPatternsNotSupported[] =
"Wake on IP address patterns not supported by this WiFi device";
const char WakeOnWiFi::kWakeOnPacketDisabled[] =
@@ -592,7 +597,7 @@
const Nl80211Message &nl80211_message) {
if (WakeOnWiFiSettingsMatch(nl80211_message, wake_on_wifi_triggers_,
wake_on_packet_connections_)) {
- SLOG(WiFi, 2) << __func__ << ": "
+ SLOG(this, 2) << __func__ << ": "
<< "Wake-on-packet settings successfully verified";
RunAndResetSuspendActionsDoneCallback(Error(Error::kSuccess));
} else {
@@ -670,11 +675,11 @@
void WakeOnWiFi::RetrySetWakeOnPacketConnections() {
if (num_set_wake_on_packet_retries_ < kMaxSetWakeOnPacketRetries) {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
ApplyWakeOnWiFiSettings();
++num_set_wake_on_packet_retries_;
} else {
- SLOG(WiFi, 2) << __func__ << ": max retry attempts reached";
+ SLOG(this, 2) << __func__ << ": max retry attempts reached";
num_set_wake_on_packet_retries_ = 0;
RunAndResetSuspendActionsDoneCallback(Error(Error::kOperationFailed));
}
@@ -710,7 +715,7 @@
NL80211_WOWLAN_TRIG_DISCONNECT, &disconnect_supported)) {
if (disconnect_supported) {
wake_on_wifi_triggers_supported_.insert(WakeOnWiFi::kDisconnect);
- SLOG(WiFi, 7) << "Waking on disconnect supported by this WiFi device";
+ SLOG(this, 7) << "Waking on disconnect supported by this WiFi device";
}
}
ByteString data;
@@ -737,7 +742,7 @@
std::max(ipv4_pattern_len, ipv6_pattern_len)) {
wake_on_wifi_triggers_supported_.insert(WakeOnWiFi::kIPAddress);
wake_on_wifi_max_patterns_ = patt_support->max_patterns;
- SLOG(WiFi, 7) << "Waking on up to " << wake_on_wifi_max_patterns_
+ SLOG(this, 7) << "Waking on up to " << wake_on_wifi_max_patterns_
<< " registered patterns of "
<< patt_support->min_pattern_len << "-"
<< patt_support->max_pattern_len
diff --git a/wifi.cc b/wifi.cc
index b619cc3..078fd8c 100644
--- a/wifi.cc
+++ b/wifi.cc
@@ -69,6 +69,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static string ObjectID(WiFi *w) { return w->GetRpcIdentifier(); }
+}
+
// statics
const char *WiFi::kDefaultBgscanMethod =
WPASupplicant::kNetworkBgscanMethodSimple;
@@ -197,7 +202,7 @@
// Only do the field trial if the user hasn't already enabled progressive
// scan manually. crbug.com/250945
ParseFieldTrialFile(FilePath(kProgressiveScanFieldTrialFlagFile));
- SLOG(WiFi, 2) << "WiFi device " << link_name() << " initialized.";
+ SLOG(this, 2) << "WiFi device " << link_name() << " initialized.";
}
WiFi::~WiFi() {}
@@ -205,7 +210,7 @@
void WiFi::ParseFieldTrialFile(const FilePath &info_file_path) {
FileReader file_reader;
if (!file_reader.Open(info_file_path)) {
- SLOG(WiFi, 7) << "Not enrolled in progressive scan field trial.";
+ SLOG(this, 7) << "Not enrolled in progressive scan field trial.";
return;
}
string line;
@@ -304,7 +309,7 @@
void WiFi::Start(Error *error,
const EnabledStateChangedCallback &/*callback*/) {
- SLOG(WiFi, 2) << "WiFi " << link_name() << " starting.";
+ SLOG(this, 2) << "WiFi " << link_name() << " starting.";
if (enabled()) {
return;
}
@@ -336,7 +341,7 @@
}
void WiFi::Stop(Error *error, const EnabledStateChangedCallback &/*callback*/) {
- SLOG(WiFi, 2) << "WiFi " << link_name() << " stopping.";
+ SLOG(this, 2) << "WiFi " << link_name() << " stopping.";
// Unlike other devices, we leave the DBus name watcher in place here, because
// WiFi callbacks expect notifications even if the device is disabled.
DropConnection();
@@ -366,22 +371,22 @@
error->Reset(); // indicate immediate completion
weak_ptr_factory_.InvalidateWeakPtrs();
- SLOG(WiFi, 3) << "WiFi " << link_name() << " supplicant_process_proxy_ "
+ SLOG(this, 3) << "WiFi " << link_name() << " supplicant_process_proxy_ "
<< (supplicant_process_proxy_.get() ?
"is set." : "is not set.");
- SLOG(WiFi, 3) << "WiFi " << link_name() << " supplicant_interface_proxy_ "
+ SLOG(this, 3) << "WiFi " << link_name() << " supplicant_interface_proxy_ "
<< (supplicant_interface_proxy_.get() ?
"is set." : "is not set.");
- SLOG(WiFi, 3) << "WiFi " << link_name() << " pending_service_ "
+ SLOG(this, 3) << "WiFi " << link_name() << " pending_service_ "
<< (pending_service_.get() ? "is set." : "is not set.");
- SLOG(WiFi, 3) << "WiFi " << link_name() << " has "
+ SLOG(this, 3) << "WiFi " << link_name() << " has "
<< endpoint_by_rpcid_.size() << " EndpointMap entries.";
}
void WiFi::Scan(ScanType scan_type, Error */*error*/, const string &reason) {
if ((scan_state_ != kScanIdle) ||
(current_service_.get() && current_service_->IsConnecting())) {
- SLOG(WiFi, 2) << "Ignoring scan request while scanning or connecting.";
+ SLOG(this, 2) << "Ignoring scan request while scanning or connecting.";
return;
}
if (progressive_scan_enabled_ && scan_type == kProgressiveScan) {
@@ -458,7 +463,7 @@
}
void WiFi::PropertiesChanged(const map<string, ::DBus::Variant> &properties) {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
// Called from D-Bus signal handler, but may need to send a D-Bus
// message. So defer work to event loop.
dispatcher()->PostTask(Bind(&WiFi::PropertiesChangedTask,
@@ -553,11 +558,11 @@
}
void WiFi::DisconnectFromIfActive(WiFiService *service) {
- SLOG(WiFi, 2) << __func__ << " service " << service->unique_name();
+ SLOG(this, 2) << __func__ << " service " << service->unique_name();
if (service != current_service_ && service != pending_service_) {
if (!service->IsActive(nullptr)) {
- SLOG(WiFi, 2) << "In " << __func__ << "(): service "
+ SLOG(this, 2) << "In " << __func__ << "(): service "
<< service->unique_name()
<< " is not active, no need to initiate disconnect";
return;
@@ -568,7 +573,7 @@
}
void WiFi::DisconnectFrom(WiFiService *service) {
- SLOG(WiFi, 2) << __func__ << " service " << service->unique_name();
+ SLOG(this, 2) << __func__ << " service " << service->unique_name();
if (service != current_service_ && service != pending_service_) {
// TODO(quiche): Once we have asynchronous reply support, we should
@@ -642,7 +647,7 @@
if (service == selected_service()) {
DropConnection();
} else {
- SLOG(WiFi, 5) << __func__ << " skipping DropConnection, "
+ SLOG(this, 5) << __func__ << " skipping DropConnection, "
<< "selected_service is "
<< (selected_service() ?
selected_service()->unique_name() : "(null)");
@@ -828,7 +833,7 @@
}
void WiFi::CurrentBSSChanged(const ::DBus::Path &new_bss) {
- SLOG(WiFi, 3) << "WiFi " << link_name() << " CurrentBSS "
+ SLOG(this, 3) << "WiFi " << link_name() << " CurrentBSS "
<< supplicant_bss_ << " -> " << new_bss;
supplicant_bss_ = new_bss;
has_already_completed_ = false;
@@ -897,12 +902,12 @@
current_service_.get() ? current_service_.get() : pending_service_.get();
if (!affected_service) {
- SLOG(WiFi, 2) << "WiFi " << link_name()
+ SLOG(this, 2) << "WiFi " << link_name()
<< " disconnected while not connected or connecting";
return;
}
- SLOG(WiFi, 2) << "WiFi " << link_name() << " disconnected from "
+ SLOG(this, 2) << "WiFi " << link_name() << " disconnected from "
<< " (or failed to connect to) service "
<< affected_service->unique_name();
@@ -925,7 +930,7 @@
Error error;
if (!DisableNetworkForService(affected_service, &error)) {
if (error.type() == Error::kNotFound) {
- SLOG(WiFi, 2) << "WiFi " << link_name() << " disconnected from "
+ SLOG(this, 2) << "WiFi " << link_name() << " disconnected from "
<< " (or failed to connect to) service "
<< affected_service->unique_name() << ", "
<< "but could not find supplicant network to disable.";
@@ -957,7 +962,7 @@
//
// Log this fact, to help us debug (in case our assumptions are
// wrong).
- SLOG(WiFi, 2) << "WiFi " << link_name() << " pending connection to service "
+ SLOG(this, 2) << "WiFi " << link_name() << " pending connection to service "
<< pending_service_->unique_name()
<< " after disconnect";
}
@@ -968,7 +973,7 @@
}
void WiFi::ServiceDisconnected(WiFiServiceRefPtr affected_service) {
- SLOG(WiFi, 2) << __func__ << " service " << affected_service->unique_name();
+ SLOG(this, 2) << __func__ << " service " << affected_service->unique_name();
// Check if service was explicitly disconnected due to failure or
// is explicitly disconnected by user.
@@ -1017,7 +1022,7 @@
return;
}
- SLOG(WiFi, 2) << "WiFi " << link_name()
+ SLOG(this, 2) << "WiFi " << link_name()
<< " roamed to Endpoint " << endpoint->bssid_string()
<< " " << LogSSID(endpoint->ssid_string());
@@ -1035,7 +1040,7 @@
// If it fails, we'll process things in HandleDisconnect.
//
// So we leave |pending_service_| untouched.
- SLOG(WiFi, 2) << "WiFi " << link_name()
+ SLOG(this, 2) << "WiFi " << link_name()
<< " new current Endpoint "
<< endpoint->bssid_string()
<< " is not part of pending service "
@@ -1120,7 +1125,7 @@
link_name().c_str(), service->unique_name().c_str());
// There are contexts where this is not an error, such as when a service
// is clearing whatever cached credentials may not exist.
- SLOG(WiFi, 2) << error_message;
+ SLOG(this, 2) << error_message;
if (error) {
error->Populate(Error::kNotFound, error_message);
}
@@ -1190,7 +1195,7 @@
// lose.
WiFiEndpointRefPtr endpoint(
new WiFiEndpoint(proxy_factory_, this, path, properties));
- SLOG(WiFi, 5) << "Found endpoint. "
+ SLOG(this, 5) << "Found endpoint. "
<< "RPC path: " << path << ", "
<< LogSSID(endpoint->ssid_string()) << ", "
<< "bssid: " << endpoint->bssid_string() << ", "
@@ -1226,7 +1231,7 @@
void WiFi::BSSRemovedTask(const ::DBus::Path &path) {
EndpointMap::iterator i = endpoint_by_rpcid_.find(path);
if (i == endpoint_by_rpcid_.end()) {
- SLOG(WiFi, 1) << "WiFi " << link_name()
+ SLOG(this, 1) << "WiFi " << link_name()
<< " could not find BSS " << path
<< " to remove.";
return;
@@ -1319,7 +1324,7 @@
}
void WiFi::ScanDoneTask() {
- SLOG(WiFi, 2) << __func__ << " need_bss_flush_ " << need_bss_flush_;
+ SLOG(this, 2) << __func__ << " need_bss_flush_ " << need_bss_flush_;
if (scan_session_) {
// Post |ProgressiveScanTask| so it runs after any |BSSAddedTask|s that have
// been posted. This allows connections on new BSSes to be started before
@@ -1367,20 +1372,20 @@
}
void WiFi::ScanTask() {
- SLOG(WiFi, 2) << "WiFi " << link_name() << " scan requested.";
+ SLOG(this, 2) << "WiFi " << link_name() << " scan requested.";
if (!enabled()) {
- SLOG(WiFi, 2) << "Ignoring scan request while device is not enabled.";
+ SLOG(this, 2) << "Ignoring scan request while device is not enabled.";
SetScanState(kScanIdle, kScanMethodNone, __func__); // Probably redundant.
return;
}
if (!supplicant_present_ || !supplicant_interface_proxy_.get()) {
- SLOG(WiFi, 2) << "Ignoring scan request while supplicant is not present.";
+ SLOG(this, 2) << "Ignoring scan request while supplicant is not present.";
SetScanState(kScanIdle, kScanMethodNone, __func__);
return;
}
if ((pending_service_.get() && pending_service_->IsConnecting()) ||
(current_service_.get() && current_service_->IsConnecting())) {
- SLOG(WiFi, 2) << "Ignoring scan request while connecting to an AP.";
+ SLOG(this, 2) << "Ignoring scan request while connecting to an AP.";
return;
}
map<string, DBus::Variant> scan_args;
@@ -1422,14 +1427,14 @@
}
void WiFi::ProgressiveScanTask() {
- SLOG(WiFi, 2) << __func__ << " - scan requested for " << link_name();
+ SLOG(this, 2) << __func__ << " - scan requested for " << link_name();
if (!enabled()) {
LOG(INFO) << "Ignoring scan request while device is not enabled.";
SetScanState(kScanIdle, kScanMethodNone, __func__); // Probably redundant.
return;
}
if (!scan_session_) {
- SLOG(WiFi, 2) << "No scan session -- returning";
+ SLOG(this, 2) << "No scan session -- returning";
SetScanState(kScanIdle, kScanMethodNone, __func__);
return;
}
@@ -1439,12 +1444,12 @@
// when the scan started. Then, this code would only bail out if we didn't
// start with a connection but one exists at this point.
if (!IsIdle()) {
- SLOG(WiFi, 2) << "Ignoring scan request while connecting to an AP.";
+ SLOG(this, 2) << "Ignoring scan request while connecting to an AP.";
scan_session_.reset();
return;
}
if (scan_session_->HasMoreFrequencies()) {
- SLOG(WiFi, 2) << "Initiating a scan -- returning";
+ SLOG(this, 2) << "Initiating a scan -- returning";
SetScanState(kScanScanning, kScanMethodProgressive, __func__);
// After us initiating a scan, supplicant will gather the scan results and
// send us zero or more |BSSAdded| events followed by a |ScanDone|.
@@ -1503,7 +1508,7 @@
WiFiService *affected_service =
pending_service_.get() ? pending_service_.get() : current_service_.get();
if (!affected_service) {
- SLOG(WiFi, 2) << "WiFi " << link_name() << " " << __func__
+ SLOG(this, 2) << "WiFi " << link_name() << " " << __func__
<< " with no service";
return;
}
@@ -1676,7 +1681,7 @@
}
void WiFi::DisassociateFromService(const WiFiServiceRefPtr &service) {
- SLOG(WiFi, 2) << "In " << __func__ << " for service: "
+ SLOG(this, 2) << "In " << __func__ << " for service: "
<< service->unique_name();
DisconnectFromIfActive(service);
if (service == selected_service()) {
@@ -1764,7 +1769,7 @@
Scan(kProgressiveScan, nullptr, __func__);
RestartFastScanAttempts();
} else {
- SLOG(WiFi, 1) << __func__
+ SLOG(this, 1) << __func__
<< " skipping scan, already connecting or connected.";
}
@@ -1838,7 +1843,7 @@
}
void WiFi::StartScanTimer() {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (scan_interval_seconds_ == 0) {
StopScanTimer();
return;
@@ -1851,16 +1856,16 @@
kFastScanIntervalSeconds * 1000 : scan_interval_seconds_ * 1000;
dispatcher()->PostDelayedTask(scan_timer_callback_.callback(),
wait_time_milliseconds);
- SLOG(WiFi, 5) << "Next scan scheduled for " << wait_time_milliseconds << "ms";
+ SLOG(this, 5) << "Next scan scheduled for " << wait_time_milliseconds << "ms";
}
void WiFi::StopScanTimer() {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
scan_timer_callback_.Cancel();
}
void WiFi::ScanTimerHandler() {
- SLOG(WiFi, 2) << "WiFi Device " << link_name() << ": " << __func__;
+ SLOG(this, 2) << "WiFi Device " << link_name() << ": " << __func__;
if (scan_state_ == kScanIdle && IsIdle()) {
Scan(kProgressiveScan, nullptr, __func__);
if (fast_scans_remaining_ > 0) {
@@ -1868,14 +1873,14 @@
}
} else {
if (scan_state_ != kScanIdle) {
- SLOG(WiFi, 5) << "Skipping scan: scan_state_ is " << scan_state_;
+ SLOG(this, 5) << "Skipping scan: scan_state_ is " << scan_state_;
}
if (current_service_) {
- SLOG(WiFi, 5) << "Skipping scan: current_service_ is service "
+ SLOG(this, 5) << "Skipping scan: current_service_ is service "
<< current_service_->unique_name();
}
if (pending_service_) {
- SLOG(WiFi, 5) << "Skipping scan: pending_service_ is service"
+ SLOG(this, 5) << "Skipping scan: pending_service_ is service"
<< pending_service_->unique_name();
}
}
@@ -1890,12 +1895,12 @@
}
void WiFi::StopPendingTimer() {
- SLOG(WiFi, 2) << "WiFi Device " << link_name() << ": " << __func__;
+ SLOG(this, 2) << "WiFi Device " << link_name() << ": " << __func__;
pending_timeout_callback_.Cancel();
}
void WiFi::SetPendingService(const WiFiServiceRefPtr &service) {
- SLOG(WiFi, 2) << "WiFi " << link_name() << " setting pending service to "
+ SLOG(this, 2) << "WiFi " << link_name() << " setting pending service to "
<< (service ? service->unique_name(): "NULL");
if (service) {
SetScanState(kScanConnecting, scan_method_, __func__);
@@ -1966,7 +1971,7 @@
}
void WiFi::StopReconnectTimer() {
- SLOG(WiFi, 2) << "WiFi Device " << link_name() << ": " << __func__;
+ SLOG(this, 2) << "WiFi Device " << link_name() << ": " << __func__;
reconnect_timeout_callback_.Cancel();
}
@@ -2006,9 +2011,9 @@
}
void WiFi::OnWiFiDebugScopeChanged(bool enabled) {
- SLOG(WiFi, 2) << "WiFi debug scope changed; enable is now " << enabled;
+ SLOG(this, 2) << "WiFi debug scope changed; enable is now " << enabled;
if (!supplicant_process_proxy_.get()) {
- SLOG(WiFi, 2) << "Supplicant process proxy not present.";
+ SLOG(this, 2) << "Supplicant process proxy not present.";
return;
}
string current_level;
@@ -2021,7 +2026,7 @@
if (current_level != WPASupplicant::kDebugLevelInfo &&
current_level != WPASupplicant::kDebugLevelDebug) {
- SLOG(WiFi, 2) << "WiFi debug level is currently "
+ SLOG(this, 2) << "WiFi debug level is currently "
<< current_level
<< "; assuming that it is being controlled elsewhere.";
return;
@@ -2030,7 +2035,7 @@
WPASupplicant::kDebugLevelInfo;
if (new_level == current_level) {
- SLOG(WiFi, 2) << "WiFi debug level is already the desired level "
+ SLOG(this, 2) << "WiFi debug level is already the desired level "
<< current_level;
return;
}
@@ -2226,7 +2231,7 @@
uint32_t frequency_value = 0;
if (frequency->GetU32AttributeValue(NL80211_FREQUENCY_ATTR_FREQ,
&frequency_value)) {
- SLOG(WiFi, 7) << "Found frequency[" << freq_iter.GetId()
+ SLOG(this, 7) << "Found frequency[" << freq_iter.GetId()
<< "] = " << frequency_value;
all_scan_frequencies_.insert(frequency_value);
}
@@ -2281,7 +2286,7 @@
LOG(ERROR) << "Scan time unreliable";
}
}
- SLOG(WiFi, log_level) << (reason ? reason : "<unknown>")
+ SLOG(this, log_level) << (reason ? reason : "<unknown>")
<< " - " << link_name()
<< ": Scan state: "
<< ScanStateString(scan_state_, scan_method_)
@@ -2644,7 +2649,7 @@
}
void WiFi::StopRequestingStationInfo() {
- SLOG(WiFi, 2) << "WiFi Device " << link_name() << ": " << __func__;
+ SLOG(this, 2) << "WiFi Device " << link_name() << ": " << __func__;
request_station_info_callback_.Cancel();
link_statistics_.Clear();
}
@@ -2693,7 +2698,7 @@
Error *error) {
bool success = false;
- SLOG(WiFi, 2) << "TDLS command received: " << operation
+ SLOG(this, 2) << "TDLS command received: " << operation
<< " for peer " << peer;
string peer_mac_address;
@@ -2707,7 +2712,7 @@
success = TDLSSetup(peer_mac_address);
} else if (operation == kTDLSStatusOperation) {
string supplicant_status = TDLSStatus(peer_mac_address);
- SLOG(WiFi, 2) << "TDLS status returned: " << supplicant_status;
+ SLOG(this, 2) << "TDLS status returned: " << supplicant_status;
if (!supplicant_status.empty()) {
if (supplicant_status == WPASupplicant::kTDLSStateConnected) {
return kTDLSConnectedState;
@@ -2773,7 +2778,7 @@
vector<uint8_t>(mac_address.GetConstData(),
mac_address.GetConstData() +
mac_address.GetLength()));
- SLOG(WiFi, 2) << "ARP cache lookup returned peer: " << *output;
+ SLOG(this, 2) << "ARP cache lookup returned peer: " << *output;
return true;
}
diff --git a/wifi_endpoint.cc b/wifi_endpoint.cc
index 9eeb849..49aa5c6 100644
--- a/wifi_endpoint.cc
+++ b/wifi_endpoint.cc
@@ -29,6 +29,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static string ObjectID(WiFiEndpoint *w) { return "(wifi_endpoint)"; }
+}
+
// static
const size_t WiFiEndpoint::kBSSIDLength = 6U;
@@ -93,13 +98,13 @@
void WiFiEndpoint::PropertiesChanged(
const map<string, ::DBus::Variant> &properties) {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
bool should_notify = false;
map<string, ::DBus::Variant>::const_iterator properties_it =
properties.find(WPASupplicant::kBSSPropertySignal);
if (properties_it != properties.end()) {
signal_strength_ = properties_it->second.reader().get_int16();
- SLOG(WiFi, 2) << "WiFiEndpoint " << bssid_string_ << " signal is now "
+ SLOG(this, 2) << "WiFiEndpoint " << bssid_string_ << " signal is now "
<< signal_strength_;
should_notify = true;
}
@@ -109,7 +114,7 @@
string new_mode = ParseMode(properties_it->second);
if (new_mode != network_mode_) {
network_mode_ = new_mode;
- SLOG(WiFi, 2) << "WiFiEndpoint " << bssid_string_ << " mode is now "
+ SLOG(this, 2) << "WiFiEndpoint " << bssid_string_ << " mode is now "
<< network_mode_;
should_notify = true;
}
@@ -118,7 +123,7 @@
const char *new_security_mode = ParseSecurity(properties, &security_flags_);
if (new_security_mode != security_mode()) {
set_security_mode(new_security_mode);
- SLOG(WiFi, 2) << "WiFiEndpoint " << bssid_string_ << " security is now "
+ SLOG(this, 2) << "WiFiEndpoint " << bssid_string_ << " security is now "
<< security_mode();
should_notify = true;
}
@@ -133,7 +138,7 @@
return;
}
- SLOG(WiFi, 2) << __func__ << ": signal strength "
+ SLOG(this, 2) << __func__ << ": signal strength "
<< signal_strength_ << " -> " << strength;
signal_strength_ = strength;
device_->NotifyEndpointChanged(this);
@@ -420,7 +425,7 @@
map<string, ::DBus::Variant>::const_iterator ies_property =
properties.find(WPASupplicant::kBSSPropertyIEs);
if (ies_property == properties.end()) {
- SLOG(WiFi, 2) << __func__ << ": No IE property in BSS.";
+ SLOG(nullptr, 2) << __func__ << ": No IE property in BSS.";
return false;
}
diff --git a/wifi_provider.cc b/wifi_provider.cc
index cbf3fa3..e87876a 100644
--- a/wifi_provider.cc
+++ b/wifi_provider.cc
@@ -41,6 +41,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiFi;
+static string ObjectID(WiFiProvider *w) { return "(wifi_provider)"; }
+}
+
// Note that WiFiProvider generates some manager-level errors, because it
// implements the WiFi portion of the Manager.GetService flimflam API. The
// API is implemented here, rather than in manager, to keep WiFi-specific
@@ -82,11 +87,11 @@
}
void WiFiProvider::Stop() {
- SLOG(WiFi, 2) << __func__;
+ SLOG(this, 2) << __func__;
while (!services_.empty()) {
WiFiServiceRefPtr service = services_.back();
ForgetService(service);
- SLOG(WiFi, 3) << "WiFiProvider deregistering service "
+ SLOG(this, 3) << "WiFiProvider deregistering service "
<< service->unique_name();
manager_->DeregisterService(service);
}
@@ -104,27 +109,27 @@
vector<uint8_t> ssid_bytes;
if (!storage->GetString(group, WiFiService::kStorageSSID, &ssid_hex) ||
!base::HexStringToBytes(ssid_hex, &ssid_bytes)) {
- SLOG(WiFi, 2) << "Storage group " << group << " is missing valid \""
+ SLOG(this, 2) << "Storage group " << group << " is missing valid \""
<< WiFiService::kStorageSSID << "\" property";
continue;
}
string network_mode;
if (!storage->GetString(group, WiFiService::kStorageMode, &network_mode) ||
network_mode.empty()) {
- SLOG(WiFi, 2) << "Storage group " << group << " is missing \""
+ SLOG(this, 2) << "Storage group " << group << " is missing \""
<< WiFiService::kStorageMode << "\" property";
continue;
}
string security;
if (!storage->GetString(group, WiFiService::kStorageSecurity, &security) ||
!WiFiService::IsValidSecurityMethod(security)) {
- SLOG(WiFi, 2) << "Storage group " << group << " has missing or invalid \""
+ SLOG(this, 2) << "Storage group " << group << " has missing or invalid \""
<< WiFiService::kStorageSecurity << "\" property";
continue;
}
bool is_hidden = false;
if (!storage->GetBool(group, WiFiService::kStorageHiddenSSID, &is_hidden)) {
- SLOG(WiFi, 2) << "Storage group " << group << " is missing \""
+ SLOG(this, 2) << "Storage group " << group << " is missing \""
<< WiFiService::kStorageHiddenSSID << "\" property";
continue;
}
@@ -267,7 +272,7 @@
service->AddEndpoint(endpoint);
service_by_endpoint_[endpoint] = service;
- SLOG(WiFi, 1) << "Assigned endpoint " << endpoint->bssid_string()
+ SLOG(this, 1) << "Assigned endpoint " << endpoint->bssid_string()
<< " to service " << service->unique_name() << ".";
manager_->UpdateService(service);
@@ -283,7 +288,7 @@
CHECK(service) << "Can't find Service for Endpoint "
<< "(with BSSID " << endpoint->bssid_string() << ").";
- SLOG(WiFi, 1) << "Removing endpoint " << endpoint->bssid_string()
+ SLOG(this, 1) << "Removing endpoint " << endpoint->bssid_string()
<< " from Service " << service->unique_name();
service->RemoveEndpoint(endpoint);
service_by_endpoint_.erase(endpoint);
@@ -369,7 +374,7 @@
string freq_string = StringPrintf("%s%d", kStorageFrequencies, freq);
vector<string> frequencies;
if (!storage->GetStringList(kStorageId, freq_string, &frequencies)) {
- SLOG(WiFi, 7) << "Frequency list " << freq_string << " not found";
+ SLOG(this, 7) << "Frequency list " << freq_string << " not found";
break;
}
time_t start_week = StringListToFrequencyMap(frequencies,
@@ -391,7 +396,7 @@
total_frequency_connections_ += freq_count.second;
}
}
- SLOG(WiFi, 7) << __func__ << " - total count="
+ SLOG(this, 7) << __func__ << " - total count="
<< total_frequency_connections_;
}
}
@@ -456,7 +461,7 @@
hidden_ssids_set.insert(service->ssid());
}
}
- SLOG(WiFi, 2) << "Found " << hidden_ssids_set.size() << " hidden services";
+ SLOG(this, 2) << "Found " << hidden_ssids_set.size() << " hidden services";
return ByteArrays(hidden_ssids_set.begin(), hidden_ssids_set.end());
}
@@ -591,7 +596,7 @@
// Extract the start week from the first string.
vector<string>::const_iterator strings_it = strings.begin();
if (strings_it == strings.end()) {
- SLOG(WiFi, 7) << "Empty |strings|.";
+ SLOG(nullptr, 7) << "Empty |strings|.";
return kIllegalStartWeek;
}
time_t start_week = GetStringListStartWeek(*strings_it);
@@ -667,7 +672,7 @@
connect_count_by_frequency_dated_.begin();
time_t oldest_legal_week = this_week - kWeeksToKeepFrequencyCounts;
while (oldest->first < oldest_legal_week) {
- SLOG(WiFi, 6) << "Discarding frequency count info that's "
+ SLOG(this, 6) << "Discarding frequency count info that's "
<< this_week - oldest->first << " weeks old";
for (const auto &freq_count : oldest->second) {
connect_count_by_frequency_[freq_count.first] -= freq_count.second;
diff --git a/wifi_service.cc b/wifi_service.cc
index 71d6a9d..ba1971e 100644
--- a/wifi_service.cc
+++ b/wifi_service.cc
@@ -42,6 +42,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kService;
+static string ObjectID(const WiFiService *w) { return w->GetRpcIdentifier(); }
+}
+
const char WiFiService::kAutoConnNoEndpoint[] = "no endpoints";
const char WiFiService::kAnyDeviceAddress[] = "any";
const int WiFiService::kSuspectedCredentialFailureThreshold = 3;
@@ -334,7 +339,7 @@
string passphrase;
if (storage->GetCryptedString(id, kStoragePassphrase, &passphrase)) {
if (SetPassphraseInternal(passphrase, Service::kReasonCredentialsLoaded)) {
- SLOG(Service, 3) << "Loaded passphrase in WiFiService::Load.";
+ SLOG(this, 3) << "Loaded passphrase in WiFiService::Load.";
}
}
@@ -402,7 +407,7 @@
}
void WiFiService::InitializeCustomMetrics() const {
- SLOG(Metrics, 2) << __func__ << " for " << unique_name();
+ SLOG(Metrics, this, 2) << __func__ << " for " << unique_name();
string histogram = metrics()->GetFullMetricName(
Metrics::kMetricTimeToJoinMillisecondsSuffix,
technology());
diff --git a/wimax.cc b/wimax.cc
index 59fb2c4..1bbb607 100644
--- a/wimax.cc
+++ b/wimax.cc
@@ -23,6 +23,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiMax;
+static string ObjectID(WiMax *w) { return w->GetRpcIdentifier(); }
+}
+
namespace {
const char *DeviceStatusToString(wimax_manager::DeviceStatus status) {
@@ -75,7 +80,7 @@
}
void WiMax::Start(Error *error, const EnabledStateChangedCallback &callback) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
scanning_ = false;
proxy_.reset(proxy_factory_->CreateWiMaxDeviceProxy(path_));
proxy_->set_networks_changed_callback(
@@ -88,7 +93,7 @@
}
void WiMax::Stop(Error *error, const EnabledStateChangedCallback &callback) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
StopConnectTimeout();
if (pending_service_) {
pending_service_->SetState(Service::kStateIdle);
@@ -112,7 +117,7 @@
void WiMax::Scan(ScanType /*scan_type*/, Error *error,
const string &/*reason*/) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (scanning_) {
Error::PopulateAndLog(
error, Error::kInProgress, "Scan already in progress.");
@@ -128,7 +133,7 @@
}
void WiMax::ConnectTo(const WiMaxServiceRefPtr &service, Error *error) {
- SLOG(WiMax, 2) << __func__ << "(" << service->GetStorageIdentifier() << ")";
+ SLOG(this, 2) << __func__ << "(" << service->GetStorageIdentifier() << ")";
if (pending_service_) {
Error::PopulateAndLog(
error, Error::kInProgress,
@@ -162,7 +167,7 @@
}
void WiMax::DisconnectFrom(const ServiceRefPtr &service, Error *error) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (pending_service_) {
Error::PopulateAndLog(
error, Error::kInProgress,
@@ -196,7 +201,7 @@
}
void WiMax::OnServiceStopped(const WiMaxServiceRefPtr &service) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (service == selected_service()) {
DropConnection();
}
@@ -215,13 +220,13 @@
}
void WiMax::OnScanNetworksComplete(const Error &/*error*/) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
scanning_ = false;
// The networks are updated when the NetworksChanged signal is received.
}
void WiMax::OnConnectComplete(const Error &error) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (error.IsSuccess()) {
// Nothing to do -- the connection process is resumed on the StatusChanged
// signal.
@@ -231,12 +236,12 @@
}
void WiMax::OnDisconnectComplete(const Error &/*error*/) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
}
void WiMax::OnEnableComplete(const EnabledStateChangedCallback &callback,
const Error &error) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (error.IsFailure()) {
proxy_.reset();
} else {
@@ -257,15 +262,15 @@
}
void WiMax::OnNetworksChanged(const RpcIdentifiers &networks) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
networks_.clear();
networks_.insert(networks.begin(), networks.end());
manager()->wimax_provider()->OnNetworksChanged();
}
void WiMax::OnStatusChanged(wimax_manager::DeviceStatus status) {
- SLOG(WiMax, 2) << "WiMAX device " << link_name()
- << " status: " << DeviceStatusToString(status);
+ SLOG(this, 2) << "WiMAX device " << link_name()
+ << " status: " << DeviceStatusToString(status);
wimax_manager::DeviceStatus old_status = status_;
status_ = status;
switch (status) {
@@ -309,8 +314,8 @@
}
void WiMax::DropService(Service::ConnectState state) {
- SLOG(WiMax, 2) << __func__
- << "(" << Service::ConnectStateToString(state) << ")";
+ SLOG(this, 2) << __func__
+ << "(" << Service::ConnectStateToString(state) << ")";
StopConnectTimeout();
if (pending_service_) {
LOG(WARNING) << "Unable to initiate connection to: "
@@ -327,7 +332,7 @@
}
void WiMax::StartConnectTimeout() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (IsConnectTimeoutStarted()) {
return;
}
@@ -338,7 +343,7 @@
}
void WiMax::StopConnectTimeout() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
connect_timeout_callback_.Cancel();
}
diff --git a/wimax_device_proxy.cc b/wimax_device_proxy.cc
index 0e072e6..0248965 100644
--- a/wimax_device_proxy.cc
+++ b/wimax_device_proxy.cc
@@ -79,7 +79,7 @@
}
uint8_t WiMaxDeviceProxy::Index(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Index();
} catch (const DBus::Error &e) {
@@ -89,7 +89,7 @@
}
string WiMaxDeviceProxy::Name(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Name();
} catch (const DBus::Error &e) {
@@ -99,7 +99,7 @@
}
RpcIdentifiers WiMaxDeviceProxy::Networks(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
vector<DBus::Path> dbus_paths;
try {
dbus_paths = proxy_.Networks();
@@ -144,7 +144,7 @@
void WiMaxDeviceProxy::Proxy::NetworksChanged(
const vector<DBus::Path> &networks) {
- SLOG(DBus, 2) << __func__ << "(" << networks.size() << ")";
+ SLOG(&path(), 2) << __func__ << "(" << networks.size() << ")";
if (networks_changed_callback_.is_null()) {
return;
}
@@ -154,7 +154,7 @@
}
void WiMaxDeviceProxy::Proxy::StatusChanged(const int32_t &status) {
- SLOG(DBus, 2) << __func__ << "(" << status << ")";
+ SLOG(&path(), 2) << __func__ << "(" << status << ")";
if (status_changed_callback_.is_null()) {
return;
}
@@ -163,31 +163,31 @@
void WiMaxDeviceProxy::Proxy::EnableCallback(const DBus::Error &error,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
HandleCallback(error, data);
}
void WiMaxDeviceProxy::Proxy::DisableCallback(const DBus::Error &error,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
HandleCallback(error, data);
}
void WiMaxDeviceProxy::Proxy::ScanNetworksCallback(const DBus::Error &error,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
HandleCallback(error, data);
}
void WiMaxDeviceProxy::Proxy::ConnectCallback(const DBus::Error &error,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
HandleCallback(error, data);
}
void WiMaxDeviceProxy::Proxy::DisconnectCallback(const DBus::Error &error,
void *data) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&path(), 2) << __func__;
HandleCallback(error, data);
}
diff --git a/wimax_manager_proxy.cc b/wimax_manager_proxy.cc
index bd94611..28ce060 100644
--- a/wimax_manager_proxy.cc
+++ b/wimax_manager_proxy.cc
@@ -4,16 +4,24 @@
#include "shill/wimax_manager_proxy.h"
+#include <string>
+
#include <chromeos/dbus/service_constants.h>
#include "shill/dbus_properties.h"
#include "shill/error.h"
#include "shill/logging.h"
+using std::string;
using std::vector;
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(WiMaxManagerProxy *w) { return "(wimax_manager_proxy)"; }
+}
+
WiMaxManagerProxy::WiMaxManagerProxy(DBus::Connection *connection)
: proxy_(connection) {}
@@ -25,7 +33,7 @@
}
RpcIdentifiers WiMaxManagerProxy::Devices(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(this, 2) << __func__;
vector<DBus::Path> dbus_devices;
try {
dbus_devices = proxy_.Devices();
@@ -51,7 +59,7 @@
void WiMaxManagerProxy::Proxy::DevicesChanged(
const vector<DBus::Path> &devices) {
- SLOG(DBus, 2) << __func__ << "(" << devices.size() << ")";
+ SLOG(DBus, nullptr, 2) << __func__ << "(" << devices.size() << ")";
if (devices_changed_callback_.is_null()) {
return;
}
diff --git a/wimax_network_proxy.cc b/wimax_network_proxy.cc
index 32242a2..f5e97bc 100644
--- a/wimax_network_proxy.cc
+++ b/wimax_network_proxy.cc
@@ -13,6 +13,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kDBus;
+static string ObjectID(const DBus::Path *p) { return *p; }
+}
+
WiMaxNetworkProxy::WiMaxNetworkProxy(DBus::Connection *connection,
const DBus::Path &path)
: proxy_(connection, path) {}
@@ -29,7 +34,7 @@
}
uint32_t WiMaxNetworkProxy::Identifier(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Identifier();
} catch (const DBus::Error &e) {
@@ -39,7 +44,7 @@
}
string WiMaxNetworkProxy::Name(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Name();
} catch (const DBus::Error &e) {
@@ -49,7 +54,7 @@
}
int WiMaxNetworkProxy::Type(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.Type();
} catch (const DBus::Error &e) {
@@ -59,7 +64,7 @@
}
int WiMaxNetworkProxy::CINR(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.CINR();
} catch (const DBus::Error &e) {
@@ -69,7 +74,7 @@
}
int WiMaxNetworkProxy::RSSI(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.RSSI();
} catch (const DBus::Error &e) {
@@ -79,7 +84,7 @@
}
int WiMaxNetworkProxy::SignalStrength(Error *error) {
- SLOG(DBus, 2) << __func__;
+ SLOG(&proxy_.path(), 2) << __func__;
try {
return proxy_.SignalStrength();
} catch (const DBus::Error &e) {
@@ -115,7 +120,7 @@
void WiMaxNetworkProxy::Proxy::SignalStrengthChanged(
const int32_t &signal_strength) {
- SLOG(DBus, 2) << __func__ << "(" << signal_strength << ")";
+ SLOG(&path(), 2) << __func__ << "(" << signal_strength << ")";
if (!signal_strength_changed_callback_.is_null()) {
signal_strength_changed_callback_.Run(signal_strength);
}
diff --git a/wimax_provider.cc b/wimax_provider.cc
index 33ac4e3..4c1c8ac 100644
--- a/wimax_provider.cc
+++ b/wimax_provider.cc
@@ -31,6 +31,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiMax;
+static string ObjectID(const WiMaxProvider *w) { return "(wimax_provider)"; }
+}
+
WiMaxProvider::WiMaxProvider(ControlInterface *control,
EventDispatcher *dispatcher,
Metrics *metrics,
@@ -44,7 +49,7 @@
WiMaxProvider::~WiMaxProvider() {}
void WiMaxProvider::Start() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (wimax_manager_name_watcher_) {
return;
}
@@ -57,7 +62,7 @@
}
void WiMaxProvider::Stop() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
wimax_manager_name_watcher_.reset();
DisconnectFromWiMaxManager();
DestroyAllServices();
@@ -74,7 +79,7 @@
}
void WiMaxProvider::DisconnectFromWiMaxManager() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!wimax_manager_proxy_.get()) {
return;
}
@@ -85,18 +90,18 @@
void WiMaxProvider::OnWiMaxManagerAppear(const string &name,
const string &owner) {
- SLOG(WiMax, 2) << __func__ << "(" << name << ", " << owner << ")";
+ SLOG(this, 2) << __func__ << "(" << name << ", " << owner << ")";
DisconnectFromWiMaxManager();
ConnectToWiMaxManager();
}
void WiMaxProvider::OnWiMaxManagerVanish(const string &name) {
- SLOG(WiMax, 2) << __func__ << "(" << name << ")";
+ SLOG(this, 2) << __func__ << "(" << name << ")";
DisconnectFromWiMaxManager();
}
void WiMaxProvider::OnDeviceInfoAvailable(const string &link_name) {
- SLOG(WiMax, 2) << __func__ << "(" << link_name << ")";
+ SLOG(this, 2) << __func__ << "(" << link_name << ")";
map<string, RpcIdentifier>::const_iterator find_it =
pending_devices_.find(link_name);
if (find_it != pending_devices_.end()) {
@@ -106,7 +111,7 @@
}
void WiMaxProvider::OnNetworksChanged() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
// Collects a set of live networks from all devices.
set<RpcIdentifier> live_networks;
for (const auto &device : devices_) {
@@ -133,7 +138,7 @@
}
bool WiMaxProvider::OnServiceUnloaded(const WiMaxServiceRefPtr &service) {
- SLOG(WiMax, 2) << __func__ << "(" << service->GetStorageIdentifier() << ")";
+ SLOG(this, 2) << __func__ << "(" << service->GetStorageIdentifier() << ")";
if (service->is_default()) {
return false;
}
@@ -169,7 +174,7 @@
ServiceRefPtr WiMaxProvider::GetService(const KeyValueStore &args,
Error *error) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK_EQ(kTypeWimax, args.GetString(kTypeProperty));
WiMaxNetworkId id;
string name;
@@ -185,7 +190,7 @@
ServiceRefPtr WiMaxProvider::FindSimilarService(const KeyValueStore &args,
Error *error) const {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK_EQ(kTypeWimax, args.GetString(kTypeProperty));
WiMaxNetworkId id;
string name;
@@ -202,7 +207,7 @@
ServiceRefPtr WiMaxProvider::CreateTemporaryService(const KeyValueStore &args,
Error *error) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK_EQ(kTypeWimax, args.GetString(kTypeProperty));
WiMaxNetworkId id;
string name;
@@ -213,7 +218,7 @@
}
void WiMaxProvider::CreateServicesFromProfile(const ProfileRefPtr &profile) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
bool created = false;
const StoreInterface *storage = profile->GetConstStorage();
set<string> groups = storage->GetGroupsWithKey(Service::kStorageType);
@@ -252,7 +257,7 @@
WiMaxRefPtr WiMaxProvider::SelectCarrier(
const WiMaxServiceConstRefPtr &service) {
- SLOG(WiMax, 2) << __func__ << "(" << service->GetStorageIdentifier() << ")";
+ SLOG(this, 2) << __func__ << "(" << service->GetStorageIdentifier() << ")";
if (devices_.empty()) {
LOG(ERROR) << "No WiMAX devices available.";
return nullptr;
@@ -263,7 +268,7 @@
}
void WiMaxProvider::OnDevicesChanged(const RpcIdentifiers &devices) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
DestroyDeadDevices(devices);
for (const auto &path : devices) {
string link_name = GetLinkName(path);
@@ -275,9 +280,9 @@
void WiMaxProvider::CreateDevice(const string &link_name,
const RpcIdentifier &path) {
- SLOG(WiMax, 2) << __func__ << "(" << link_name << ", " << path << ")";
+ SLOG(this, 2) << __func__ << "(" << link_name << ", " << path << ")";
if (ContainsKey(devices_, link_name)) {
- SLOG(WiMax, 2) << "Device already exists.";
+ SLOG(this, 2) << "Device already exists.";
CHECK_EQ(path, devices_[link_name]->path());
return;
}
@@ -290,7 +295,7 @@
}
int index = device_info->GetIndex(link_name);
if (index < 0) {
- SLOG(WiMax, 2) << link_name << " pending device info.";
+ SLOG(this, 2) << link_name << " pending device info.";
// Adds the link to the pending device map, waiting for a notification from
// DeviceInfo that it's received information about the device from RTNL.
pending_devices_[link_name] = path;
@@ -311,7 +316,7 @@
}
void WiMaxProvider::DestroyDeadDevices(const RpcIdentifiers &live_devices) {
- SLOG(WiMax, 2) << __func__ << "(" << live_devices.size() << ")";
+ SLOG(this, 2) << __func__ << "(" << live_devices.size() << ")";
for (auto it = pending_devices_.begin(); it != pending_devices_.end(); ) {
if (find(live_devices.begin(), live_devices.end(), it->second) ==
live_devices.end()) {
@@ -366,7 +371,7 @@
}
WiMaxServiceRefPtr WiMaxProvider::FindService(const string &storage_id) const {
- SLOG(WiMax, 2) << __func__ << "(" << storage_id << ")";
+ SLOG(this, 2) << __func__ << "(" << storage_id << ")";
map<string, WiMaxServiceRefPtr>::const_iterator find_it =
services_.find(storage_id);
if (find_it == services_.end()) {
@@ -379,11 +384,11 @@
WiMaxServiceRefPtr WiMaxProvider::GetUniqueService(const WiMaxNetworkId &id,
const string &name) {
- SLOG(WiMax, 2) << __func__ << "(" << id << ", " << name << ")";
+ SLOG(this, 2) << __func__ << "(" << id << ", " << name << ")";
string storage_id = WiMaxService::CreateStorageIdentifier(id, name);
WiMaxServiceRefPtr service = FindService(storage_id);
if (service) {
- SLOG(WiMax, 2) << "Service already exists.";
+ SLOG(this, 2) << "Service already exists.";
return service;
}
service = CreateService(id, name);
@@ -404,7 +409,7 @@
}
void WiMaxProvider::StartLiveServices() {
- SLOG(WiMax, 2) << __func__ << "(" << networks_.size() << ")";
+ SLOG(this, 2) << __func__ << "(" << networks_.size() << ")";
for (const auto &nit : networks_) {
const RpcIdentifier &path = nit.first;
const NetworkInfo &info = nit.second;
@@ -427,7 +432,7 @@
}
void WiMaxProvider::StopDeadServices() {
- SLOG(WiMax, 2) << __func__ << "(" << networks_.size() << ")";
+ SLOG(this, 2) << __func__ << "(" << networks_.size() << ")";
for (map<string, WiMaxServiceRefPtr>::iterator it = services_.begin();
it != services_.end(); ) {
// Keeps a local reference until we're done with this service.
@@ -453,7 +458,7 @@
}
void WiMaxProvider::DestroyAllServices() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
while (!services_.empty()) {
// Keeps a local reference until we're done with this service.
WiMaxServiceRefPtr service = services_.begin()->second;
diff --git a/wimax_service.cc b/wimax_service.cc
index 59b204a..569879e 100644
--- a/wimax_service.cc
+++ b/wimax_service.cc
@@ -25,6 +25,11 @@
namespace shill {
+namespace Logging {
+static auto kModuleLogScope = ScopeLogger::kWiMax;
+static string ObjectID(WiMaxService *w) { return w->GetRpcIdentifier(); }
+}
+
const char WiMaxService::kStorageNetworkId[] = "NetworkId";
const char WiMaxService::kNetworkIdProperty[] = "NetworkId";
@@ -84,7 +89,7 @@
}
bool WiMaxService::Start(WiMaxNetworkProxyInterface *proxy) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
CHECK(proxy);
std::unique_ptr<WiMaxNetworkProxyInterface> local_proxy(proxy);
if (IsStarted()) {
@@ -128,7 +133,7 @@
}
void WiMaxService::Connect(Error *error, const char *reason) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (device_) {
// TODO(benchan): Populate error again after changing the way that
// Chrome handles Error::kAlreadyConnected situation.
@@ -159,7 +164,7 @@
}
void WiMaxService::Disconnect(Error *error, const char *reason) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!device_) {
Error::PopulateAndLog(
error, Error::kNotConnected, "Not connected.");
@@ -214,13 +219,13 @@
}
void WiMaxService::UpdateConnectable() {
- SLOG(WiMax, 2) << __func__ << "(started: " << IsStarted()
- << ", need passphrase: " << need_passphrase_ << ")";
+ SLOG(this, 2) << __func__ << "(started: " << IsStarted()
+ << ", need passphrase: " << need_passphrase_ << ")";
SetConnectableFull(IsStarted() && !need_passphrase_);
}
void WiMaxService::OnSignalStrengthChanged(int strength) {
- SLOG(WiMax, 2) << __func__ << "(" << strength << ")";
+ SLOG(this, 2) << __func__ << "(" << strength << ")";
SetStrength(strength);
}
@@ -238,7 +243,7 @@
}
bool WiMaxService::Save(StoreInterface *storage) {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
if (!Service::Save(storage)) {
return false;
}
@@ -249,7 +254,7 @@
}
bool WiMaxService::Unload() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
// The base method also disconnects the service.
Service::Unload();
ClearPassphrase();
@@ -287,7 +292,7 @@
}
void WiMaxService::ClearPassphrase() {
- SLOG(WiMax, 2) << __func__;
+ SLOG(this, 2) << __func__;
mutable_eap()->set_password("");
OnEapCredentialsChanged(Service::kReasonPropertyUpdate);
}