Commit a32dc902 authored by Sean Kau's avatar Sean Kau Committed by Commit Bot

Expand CrOS Printer logging in device logs.

Move some existing logging to device logs.  Expand on existing logs
to help with diagnostics.

Bug: 836434
Change-Id: I8516930f36aeecffd33fe96b044650903536a9d2
Reviewed-on: https://chromium-review.googlesource.com/1036231Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Sean Kau <skau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556091}
parent 82471404
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "chromeos/dbus/debug_daemon_client.h" #include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/printing/ppd_provider.h" #include "chromeos/printing/ppd_provider.h"
#include "chromeos/printing/printer_configuration.h" #include "chromeos/printing/printer_configuration.h"
#include "components/device_event_log/device_event_log.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "net/base/host_port_pair.h" #include "net/base/host_port_pair.h"
#include "net/base/ip_endpoint.h" #include "net/base/ip_endpoint.h"
...@@ -66,12 +67,14 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -66,12 +67,14 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!printer.id().empty()); DCHECK(!printer.id().empty());
DCHECK(!printer.uri().empty()); DCHECK(!printer.uri().empty());
PRINTER_LOG(USER) << printer.make_and_model() << " Printer setup requested";
if (!printer.RequiresIpResolution()) { if (!printer.RequiresIpResolution()) {
StartConfiguration(printer, std::move(callback)); StartConfiguration(printer, std::move(callback));
return; return;
} }
PRINTER_LOG(DEBUG) << printer.make_and_model() << " Resolving IP";
// Resolve the uri to an ip with a mutable copy of the printer. // Resolve the uri to an ip with a mutable copy of the printer.
endpoint_resolver_->Start( endpoint_resolver_->Start(
printer.GetHostAndPort(), printer.GetHostAndPort(),
...@@ -86,6 +89,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -86,6 +89,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
void StartConfiguration(const Printer& printer, void StartConfiguration(const Printer& printer,
PrinterSetupCallback callback) { PrinterSetupCallback callback) {
if (!printer.IsIppEverywhere()) { if (!printer.IsIppEverywhere()) {
PRINTER_LOG(DEBUG) << printer.make_and_model() << " Lookup PPD";
ppd_provider_->ResolvePpd( ppd_provider_->ResolvePpd(
printer.ppd_reference(), printer.ppd_reference(),
base::BindOnce(&PrinterConfigurerImpl::ResolvePpdDone, base::BindOnce(&PrinterConfigurerImpl::ResolvePpdDone,
...@@ -94,6 +98,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -94,6 +98,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
return; return;
} }
PRINTER_LOG(DEBUG) << printer.make_and_model()
<< " Attempting autoconf setup";
auto* client = DBusThreadManager::Get()->GetDebugDaemonClient(); auto* client = DBusThreadManager::Get()->GetDebugDaemonClient();
client->CupsAddAutoConfiguredPrinter( client->CupsAddAutoConfiguredPrinter(
printer.id(), printer.UriForCups(), printer.id(), printer.UriForCups(),
...@@ -110,11 +116,15 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -110,11 +116,15 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
PrinterSetupCallback cb, PrinterSetupCallback cb,
const net::IPEndPoint& endpoint) { const net::IPEndPoint& endpoint) {
if (!endpoint.address().IsValid()) { if (!endpoint.address().IsValid()) {
PRINTER_LOG(ERROR) << printer->make_and_model()
<< " IP Resolution failed";
// |endpoint| does not have a valid address. Address was not resolved. // |endpoint| does not have a valid address. Address was not resolved.
std::move(cb).Run(kPrinterUnreachable); std::move(cb).Run(kPrinterUnreachable);
return; return;
} }
PRINTER_LOG(EVENT) << printer->make_and_model()
<< " IP Resolution succeeded";
std::string effective_uri = printer->ReplaceHostAndPort(endpoint); std::string effective_uri = printer->ReplaceHostAndPort(endpoint);
printer->set_effective_uri(effective_uri); printer->set_effective_uri(effective_uri);
...@@ -128,7 +138,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -128,7 +138,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!result_code.has_value()) { if (!result_code.has_value()) {
LOG(WARNING) << "Could not contact debugd"; PRINTER_LOG(ERROR) << printer.make_and_model()
<< " Could not contact debugd";
std::move(cb).Run(PrinterSetupResult::kDbusError); std::move(cb).Run(PrinterSetupResult::kDbusError);
return; return;
} }
...@@ -136,12 +147,16 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -136,12 +147,16 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
PrinterSetupResult result; PrinterSetupResult result;
switch (result_code.value()) { switch (result_code.value()) {
case debugd::CupsResult::CUPS_SUCCESS: case debugd::CupsResult::CUPS_SUCCESS:
PRINTER_LOG(DEBUG) << printer.make_and_model()
<< " Printer setup successful";
result = PrinterSetupResult::kSuccess; result = PrinterSetupResult::kSuccess;
break; break;
case debugd::CupsResult::CUPS_INVALID_PPD: case debugd::CupsResult::CUPS_INVALID_PPD:
PRINTER_LOG(EVENT) << printer.make_and_model() << " PPD Invalid";
result = PrinterSetupResult::kInvalidPpd; result = PrinterSetupResult::kInvalidPpd;
break; break;
case debugd::CupsResult::CUPS_AUTOCONF_FAILURE: case debugd::CupsResult::CUPS_AUTOCONF_FAILURE:
PRINTER_LOG(EVENT) << printer.make_and_model() << " Autoconf failed";
// There are other reasons autoconf fails but this is the most likely. // There are other reasons autoconf fails but this is the most likely.
result = PrinterSetupResult::kPrinterUnreachable; result = PrinterSetupResult::kPrinterUnreachable;
break; break;
...@@ -153,8 +168,9 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -153,8 +168,9 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
case debugd::CupsResult::CUPS_FATAL: case debugd::CupsResult::CUPS_FATAL:
default: default:
// We have no idea. It must be fatal. // We have no idea. It must be fatal.
LOG(ERROR) << "Unrecognized printer setup error: " PRINTER_LOG(ERROR) << printer.make_and_model()
<< result_code.value(); << " Unrecognized printer setup error: "
<< result_code.value();
result = PrinterSetupResult::kFatalError; result = PrinterSetupResult::kFatalError;
break; break;
} }
...@@ -167,6 +183,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -167,6 +183,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
PrinterSetupCallback cb) { PrinterSetupCallback cb) {
auto* client = DBusThreadManager::Get()->GetDebugDaemonClient(); auto* client = DBusThreadManager::Get()->GetDebugDaemonClient();
PRINTER_LOG(EVENT) << printer.make_and_model() << " Manual printer setup";
client->CupsAddManuallyConfiguredPrinter( client->CupsAddManuallyConfiguredPrinter(
printer.id(), printer.UriForCups(), ppd_contents, printer.id(), printer.UriForCups(), ppd_contents,
base::BindOnce(&PrinterConfigurerImpl::OnAddedPrinter, base::BindOnce(&PrinterConfigurerImpl::OnAddedPrinter,
...@@ -183,7 +200,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -183,7 +200,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
// Result is the component mount point, or empty // Result is the component mount point, or empty
// if the component couldn't be loaded // if the component couldn't be loaded
if (result.empty()) { if (result.empty()) {
LOG(ERROR) << "Filter component installation fails."; PRINTER_LOG(ERROR) << printer.make_and_model()
<< " Filter component installation fails.";
std::move(cb).Run(PrinterSetupResult::kFatalError); std::move(cb).Run(PrinterSetupResult::kFatalError);
} else { } else {
AddPrinter(printer, ppd_contents, std::move(cb)); AddPrinter(printer, ppd_contents, std::move(cb));
...@@ -215,7 +233,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -215,7 +233,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
return; return;
} }
if (components_requested.size() > 1) { if (components_requested.size() > 1) {
LOG(ERROR) << "More than one filter component is requested."; PRINTER_LOG(ERROR) << printer.make_and_model()
<< " More than one filter component is requested.";
std::move(cb).Run(PrinterSetupResult::kFatalError); std::move(cb).Run(PrinterSetupResult::kFatalError);
return; return;
} }
...@@ -229,6 +248,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -229,6 +248,8 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
const std::string& ppd_contents, const std::string& ppd_contents,
const std::vector<std::string>& ppd_filters) { const std::vector<std::string>& ppd_filters) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
PRINTER_LOG(EVENT) << printer.make_and_model()
<< " PPD Resolution Result: " << result;
switch (result) { switch (result) {
case PpdProvider::SUCCESS: case PpdProvider::SUCCESS:
DCHECK(!ppd_contents.empty()); DCHECK(!ppd_contents.empty());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment