Commit 6075da4a authored by alexyu@google.com's avatar alexyu@google.com

Standardize log message style for cloudprint service and display printer id

and job id wherever possible


BUG=138602
TEST=

Review URL: https://chromiumcodereview.appspot.com/10808086

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147987 0039d316-1c4b-4281-b951-d872f2087c98
parent 65fd16aa
...@@ -36,7 +36,8 @@ CloudPrintConnector::CloudPrintConnector( ...@@ -36,7 +36,8 @@ CloudPrintConnector::CloudPrintConnector(
bool CloudPrintConnector::Start() { bool CloudPrintConnector::Start() {
DCHECK(!print_system_.get()); DCHECK(!print_system_.get());
VLOG(1) << "CP_CONNECTOR: Starting connector, id: " << proxy_id_; VLOG(1) << "CP_CONNECTOR: Starting connector"
<< ", proxy id: " << proxy_id_;
pending_tasks_.clear(); pending_tasks_.clear();
...@@ -64,7 +65,8 @@ bool CloudPrintConnector::Start() { ...@@ -64,7 +65,8 @@ bool CloudPrintConnector::Start() {
} }
void CloudPrintConnector::Stop() { void CloudPrintConnector::Stop() {
VLOG(1) << "CP_CONNECTOR: Stopping connector, id: " << proxy_id_; VLOG(1) << "CP_CONNECTOR: Stopping connector"
<< ", proxy id: " << proxy_id_;
DCHECK(print_system_.get()); DCHECK(print_system_.get());
if (print_system_.get()) { if (print_system_.get()) {
// Do uninitialization here. // Do uninitialization here.
...@@ -236,8 +238,9 @@ CloudPrintConnector::HandlePrinterDeleteResponse( ...@@ -236,8 +238,9 @@ CloudPrintConnector::HandlePrinterDeleteResponse(
const GURL& url, const GURL& url,
DictionaryValue* json_data, DictionaryValue* json_data,
bool succeeded) { bool succeeded) {
VLOG(1) << "CP_CONNECTOR: Handler printer delete response, succeeded:" VLOG(1) << "CP_CONNECTOR: Handler printer delete response"
<< succeeded << " url: " << url; << ", succeeded: " << succeeded
<< ", url: " << url;
ContinuePendingTaskProcessing(); // Continue processing background tasks. ContinuePendingTaskProcessing(); // Continue processing background tasks.
return CloudPrintURLFetcher::STOP_PROCESSING; return CloudPrintURLFetcher::STOP_PROCESSING;
} }
...@@ -248,8 +251,9 @@ CloudPrintConnector::HandleRegisterPrinterResponse( ...@@ -248,8 +251,9 @@ CloudPrintConnector::HandleRegisterPrinterResponse(
const GURL& url, const GURL& url,
DictionaryValue* json_data, DictionaryValue* json_data,
bool succeeded) { bool succeeded) {
VLOG(1) << "CP_CONNECTOR: Handler printer register response, succeeded:" VLOG(1) << "CP_CONNECTOR: Handler printer register response"
<< succeeded << " url: " << url; << ", succeeded: " << succeeded
<< ", url: " << url;
if (succeeded) { if (succeeded) {
ListValue* printer_list = NULL; ListValue* printer_list = NULL;
// There should be a "printers" value in the JSON // There should be a "printers" value in the JSON
...@@ -322,8 +326,8 @@ void CloudPrintConnector::InitJobHandlerForPrinter( ...@@ -322,8 +326,8 @@ void CloudPrintConnector::InitJobHandlerForPrinter(
PrinterJobHandler::PrinterInfoFromCloud printer_info_cloud; PrinterJobHandler::PrinterInfoFromCloud printer_info_cloud;
printer_data->GetString(kIdValue, &printer_info_cloud.printer_id); printer_data->GetString(kIdValue, &printer_info_cloud.printer_id);
DCHECK(!printer_info_cloud.printer_id.empty()); DCHECK(!printer_info_cloud.printer_id.empty());
VLOG(1) << "CP_CONNECTOR: Init job handler for printer id: " VLOG(1) << "CP_CONNECTOR: Init job handler"
<< printer_info_cloud.printer_id; << ", printer id: " << printer_info_cloud.printer_id;
JobHandlerMap::iterator index = job_handler_map_.find( JobHandlerMap::iterator index = job_handler_map_.find(
printer_info_cloud.printer_id); printer_info_cloud.printer_id);
if (index != job_handler_map_.end()) if (index != job_handler_map_.end())
...@@ -487,8 +491,8 @@ void CloudPrintConnector::OnReceivePrinterCaps( ...@@ -487,8 +491,8 @@ void CloudPrintConnector::OnReceivePrinterCaps(
pending_tasks_.front().type == PENDING_PRINTER_REGISTER); pending_tasks_.front().type == PENDING_PRINTER_REGISTER);
if (!succeeded) { if (!succeeded) {
LOG(ERROR) << "CP_CONNECTOR: Failed to get printer info for: " << LOG(ERROR) << "CP_CONNECTOR: Failed to get printer info"
printer_name; << ", printer name: " << printer_name;
// This printer failed to register, notify the server of this failure. // This printer failed to register, notify the server of this failure.
string16 printer_name_utf16 = UTF8ToUTF16(printer_name); string16 printer_name_utf16 = UTF8ToUTF16(printer_name);
std::string status_message = l10n_util::GetStringFUTF8( std::string status_message = l10n_util::GetStringFUTF8(
......
...@@ -304,17 +304,20 @@ class PrinterWatcherCUPS ...@@ -304,17 +304,20 @@ class PrinterWatcherCUPS
void PrinterUpdate() { void PrinterUpdate() {
if (delegate_ == NULL) if (delegate_ == NULL)
return; // Orphan call. We have been stopped already. return; // Orphan call. We have been stopped already.
VLOG(1) << "CP_CUPS: Checking for printer updates: " << printer_name_; VLOG(1) << "CP_CUPS: Checking for updates"
<< ", printer name: " << printer_name_;
if (print_system_->NotifyDelete() && if (print_system_->NotifyDelete() &&
!print_system_->IsValidPrinter(printer_name_)) { !print_system_->IsValidPrinter(printer_name_)) {
delegate_->OnPrinterDeleted(); delegate_->OnPrinterDeleted();
VLOG(1) << "CP_CUPS: Printer deleted: " << printer_name_; VLOG(1) << "CP_CUPS: Printer deleted"
<< ", printer name: " << printer_name_;
} else { } else {
std::string new_hash = GetSettingsHash(); std::string new_hash = GetSettingsHash();
if (settings_hash_ != new_hash) { if (settings_hash_ != new_hash) {
settings_hash_ = new_hash; settings_hash_ = new_hash;
delegate_->OnPrinterChanged(); delegate_->OnPrinterChanged();
VLOG(1) << "CP_CUPS: Printer update detected for: " << printer_name_; VLOG(1) << "CP_CUPS: Printer configuration changed"
<< ", printer name: " << printer_name_;
} }
} }
MessageLoop::current()->PostDelayedTask( MessageLoop::current()->PostDelayedTask(
...@@ -487,8 +490,9 @@ void PrintSystemCUPS::UpdatePrinters() { ...@@ -487,8 +490,9 @@ void PrintSystemCUPS::UpdatePrinters() {
printer_it->printer_name = MakeFullPrinterName(it->url, printer_it->printer_name = MakeFullPrinterName(it->url,
printer_it->printer_name); printer_it->printer_name);
} }
VLOG(1) << "CUPS: Updated printer list for url: " << it->url VLOG(1) << "CP_CUPS: Updated printers list"
<< " Number of printers: " << it->printers.size(); << ", server: " << it->url
<< ", # of printers: " << it->printers.size();
} }
// Schedule next update. // Schedule next update.
...@@ -506,7 +510,7 @@ PrintSystem::PrintSystemResult PrintSystemCUPS::EnumeratePrinters( ...@@ -506,7 +510,7 @@ PrintSystem::PrintSystemResult PrintSystemCUPS::EnumeratePrinters(
printer_list->insert(printer_list->end(), printer_list->insert(printer_list->end(),
it->printers.begin(), it->printers.end()); it->printers.begin(), it->printers.end());
} }
VLOG(1) << "CUPS: Total " << printer_list->size() << " printers enumerated."; VLOG(1) << "CP_CUPS: Total printers enumerated: " << printer_list->size();
// TODO(sanjeevr): Maybe some day we want to report the actual server names // TODO(sanjeevr): Maybe some day we want to report the actual server names
// for which the enumeration failed. // for which the enumeration failed.
return PrintSystemResult(printer_enum_succeeded_, std::string()); return PrintSystemResult(printer_enum_succeeded_, std::string());
...@@ -606,10 +610,9 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name, ...@@ -606,10 +610,9 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name,
short_printer_name.c_str(), 1, -1); short_printer_name.c_str(), 1, -1);
bool error = (num_jobs == 0) && (cupsLastError() > IPP_OK_EVENTS_COMPLETE); bool error = (num_jobs == 0) && (cupsLastError() > IPP_OK_EVENTS_COMPLETE);
if (error) { if (error) {
VLOG(1) << "CP_CUPS: Error getting jobs from CUPS server. Printer:" VLOG(1) << "CP_CUPS: Error getting jobs from CUPS server"
<< printer_name << ", printer name:" << printer_name
<< " Error: " << ", error: " << static_cast<int>(cupsLastError());
<< static_cast<int>(cupsLastError());
return false; return false;
} }
...@@ -618,7 +621,8 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name, ...@@ -618,7 +621,8 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name,
// accessible through CUPS. // accessible through CUPS.
if (job_id == kDryRunJobId) { if (job_id == kDryRunJobId) {
job_details->status = PRINT_JOB_STATUS_COMPLETED; job_details->status = PRINT_JOB_STATUS_COMPLETED;
VLOG(1) << "CP_CUPS: Dry run job succeeded for: " << printer_name; VLOG(1) << "CP_CUPS: Dry run job succeeded"
<< ", printer name: " << printer_name;
return true; return true;
} }
...@@ -651,11 +655,14 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name, ...@@ -651,11 +655,14 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name,
} }
if (found) if (found)
VLOG(1) << "CP_CUPS: Job details for: " << printer_name VLOG(1) << "CP_CUPS: Job found"
<< " job_id: " << job_id << " job status: " << job_details->status; << ", printer name: " << printer_name
<< ", cups job id: " << job_id
<< ", cups job status: " << job_details->status;
else else
LOG(WARNING) << "CP_CUPS: Job not found for: " << printer_name LOG(WARNING) << "CP_CUPS: Job not found"
<< " job_id: " << job_id; << ", printer name: " << printer_name
<< ", cups job id: " << job_id;
cupsFreeJobs(num_jobs, jobs); cupsFreeJobs(num_jobs, jobs);
return found; return found;
...@@ -665,7 +672,8 @@ bool PrintSystemCUPS::GetPrinterInfo(const std::string& printer_name, ...@@ -665,7 +672,8 @@ bool PrintSystemCUPS::GetPrinterInfo(const std::string& printer_name,
printing::PrinterBasicInfo* info) { printing::PrinterBasicInfo* info) {
DCHECK(initialized_); DCHECK(initialized_);
if (info) if (info)
VLOG(1) << "CP_CUPS: Getting printer info for: " << printer_name; VLOG(1) << "CP_CUPS: Getting printer info"
<< ", printer name: " << printer_name;
std::string short_printer_name; std::string short_printer_name;
PrintServerInfoCUPS* server_info = PrintServerInfoCUPS* server_info =
...@@ -760,7 +768,7 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob( ...@@ -760,7 +768,7 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob(
const std::vector<std::string>& tags, const std::vector<std::string>& tags,
bool* dry_run) { bool* dry_run) {
DCHECK(initialized_); DCHECK(initialized_);
VLOG(1) << "CP_CUPS: Spooling print job for: " << printer_name; VLOG(1) << "CP_CUPS: Spooling print job, printer name: " << printer_name;
std::string short_printer_name; std::string short_printer_name;
PrintServerInfoCUPS* server_info = PrintServerInfoCUPS* server_info =
...@@ -781,7 +789,7 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob( ...@@ -781,7 +789,7 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob(
// Check if this is a dry run (test) job. // Check if this is a dry run (test) job.
*dry_run = CloudPrintHelpers::IsDryRunJob(tags); *dry_run = CloudPrintHelpers::IsDryRunJob(tags);
if (*dry_run) { if (*dry_run) {
VLOG(1) << "CP_CUPS: Dry run job spooled."; VLOG(1) << "CP_CUPS: Dry run job spooled";
return kDryRunJobId; return kDryRunJobId;
} }
...@@ -803,7 +811,10 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob( ...@@ -803,7 +811,10 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob(
cups_options.size(), cups_options.size(),
&(cups_options[0])); &(cups_options[0]));
VLOG(1) << "CP_CUPS: Job spooled, id: " << job_id; // TODO(alexyu): Output printer id.
VLOG(1) << "CP_CUPS: Job spooled"
<< ", printer name: " << printer_name
<< ", cups job id: " << job_id;
return job_id; return job_id;
} }
...@@ -827,7 +838,8 @@ PrintServerInfoCUPS* PrintSystemCUPS::FindServerByFullName( ...@@ -827,7 +838,8 @@ PrintServerInfoCUPS* PrintSystemCUPS::FindServerByFullName(
size_t front = full_printer_name.find("\\\\"); size_t front = full_printer_name.find("\\\\");
size_t separator = full_printer_name.find("\\", 2); size_t separator = full_printer_name.find("\\", 2);
if (front == std::string::npos || separator == std::string::npos) { if (front == std::string::npos || separator == std::string::npos) {
LOG(WARNING) << "Invalid UNC printer name: " << full_printer_name; LOG(WARNING) << "CP_CUPS: Invalid UNC"
<< ", printer name: " << full_printer_name;
return NULL; return NULL;
} }
std::string server = full_printer_name.substr(2, separator - 2); std::string server = full_printer_name.substr(2, separator - 2);
...@@ -846,7 +858,8 @@ PrintServerInfoCUPS* PrintSystemCUPS::FindServerByFullName( ...@@ -846,7 +858,8 @@ PrintServerInfoCUPS* PrintSystemCUPS::FindServerByFullName(
} }
} }
LOG(WARNING) << "Server not found for printer: " << full_printer_name; LOG(WARNING) << "CP_CUPS: Server not found"
<< ", printer name: " << full_printer_name;
return NULL; return NULL;
} }
......
...@@ -146,10 +146,9 @@ bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) { ...@@ -146,10 +146,9 @@ bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) {
cups_dest_t* destinations = NULL; cups_dest_t* destinations = NULL;
int num_dests = GetDests(&destinations); int num_dests = GetDests(&destinations);
if ((num_dests == 0) && (cupsLastError() > IPP_OK_EVENTS_COMPLETE)) { if ((num_dests == 0) && (cupsLastError() > IPP_OK_EVENTS_COMPLETE)) {
VLOG(1) << "CP_CUPS: Error getting printers from CUPS server. Server: " VLOG(1) << "CUPS: Error getting printers from CUPS server"
<< print_server_url_ << ", server: " << print_server_url_
<< " Error: " << ", error: " << static_cast<int>(cupsLastError());
<< static_cast<int>(cupsLastError());
return false; return false;
} }
...@@ -197,7 +196,9 @@ bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) { ...@@ -197,7 +196,9 @@ bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) {
cupsFreeDests(num_dests, destinations); cupsFreeDests(num_dests, destinations);
VLOG(1) << "CUPS: Enumerated " << printer_list->size() << " printers."; VLOG(1) << "CUPS: Enumerated printers"
<< ", server: " << print_server_url_
<< ", # of printers: " << printer_list->size();
return true; return true;
} }
...@@ -214,12 +215,14 @@ bool PrintBackendCUPS::GetPrinterCapsAndDefaults( ...@@ -214,12 +215,14 @@ bool PrintBackendCUPS::GetPrinterCapsAndDefaults(
PrinterCapsAndDefaults* printer_info) { PrinterCapsAndDefaults* printer_info) {
DCHECK(printer_info); DCHECK(printer_info);
VLOG(1) << "CUPS: Getting Caps and Defaults for: " << printer_name; VLOG(1) << "CUPS: Getting caps and defaults"
<< ", printer name: " << printer_name;
FilePath ppd_path(GetPPD(printer_name.c_str())); FilePath ppd_path(GetPPD(printer_name.c_str()));
// In some cases CUPS failed to get ppd file. // In some cases CUPS failed to get ppd file.
if (ppd_path.empty()) { if (ppd_path.empty()) {
LOG(ERROR) << "CUPS: Failed to get PPD for: " << printer_name; LOG(ERROR) << "CUPS: Failed to get PPD"
<< ", printer name: " << printer_name;
return false; return false;
} }
...@@ -344,7 +347,8 @@ FilePath PrintBackendCUPS::GetPPD(const char* name) { ...@@ -344,7 +347,8 @@ FilePath PrintBackendCUPS::GetPPD(const char* name) {
ipp_status_t error_code = cupsLastError(); ipp_status_t error_code = cupsLastError();
int http_error = httpError(http.http()); int http_error = httpError(http.http());
if (error_code > IPP_OK_EVENTS_COMPLETE || http_error != 0) { if (error_code > IPP_OK_EVENTS_COMPLETE || http_error != 0) {
LOG(ERROR) << "Error downloading PPD file for: " << name LOG(ERROR) << "Error downloading PPD file"
<< ", name: " << name
<< ", CUPS error: " << static_cast<int>(error_code) << ", CUPS error: " << static_cast<int>(error_code)
<< ", HTTP error: " << http_error; << ", HTTP error: " << http_error;
file_util::Delete(ppd_path, false); file_util::Delete(ppd_path, false);
......
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