| 1 | # Copyright 2019, Google LLC | ||||||||||||
| 2 | # | ||||||||||||
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||
| 4 | # you may not use this file except in compliance with the License. | ||||||||||||
| 5 | # You may obtain a copy of the License at | ||||||||||||
| 6 | # | ||||||||||||
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||
| 8 | # | ||||||||||||
| 9 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||
| 12 | # See the License for the specific language governing permissions and | ||||||||||||
| 13 | # limitations under the License. | ||||||||||||
| 14 | |||||||||||||
| 15 | package Google::Ads::GoogleAds::Logging::SummaryStats; | ||||||||||||
| 16 | |||||||||||||
| 17 | 11 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 11 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 11 | ▶ | use version; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | |||||||||||||
| 21 | # The following needs to be on one line because CPAN uses a particularly hacky | ||||||||||||
| 22 | # eval() to determine module versions. | ||||||||||||
| 23 | 11 | ▶ | use Google::Ads::GoogleAds::Constants; our $VERSION = ${Google::Ads::GoogleAds::Constants::VERSION}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | |||||||||||||
| 25 | 11 | ▶ | use Class::Std::Fast; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 26 | 11 | ▶ | use Encode qw( encode_utf8 decode_utf8 ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | |||||||||||||
| 28 | 11 | my %host_of : ATTR(:name<host> :default<>); | |||||||||||
| 29 | 11 | my %customer_id_of : ATTR(:name<customer_id> :default<>); | |||||||||||
| 30 | 11 | my %method_of : ATTR(:name<method> :default<>); | |||||||||||
| 31 | 11 | my %request_id_of : ATTR(:name<request_id> :default<>); | |||||||||||
| 32 | 11 | my %is_fault_of : ATTR(:name<is_fault> :default<0>); | |||||||||||
| 33 | 11 | my %fault_message_of : ATTR(:name<fault_message> :default<>); | |||||||||||
| 34 | |||||||||||||
| 35 | 3 | ▶ | sub as_str : STRINGIFY { | ||||||||||
|
Subroutine
as_str: called CC=8 SCAR=21.2
Pod
undocumented
| |||||||||||||
| 36 | 3 | my $self = shift; | |||||||||||
| 37 | 3 | ▶ | my $host = $self->get_host() || ""; | ||||||||||
|
Condition50%1/2
$self->get_host || ''
MC/DC0%0/1
$self->get_host || ''
$self->get_host
Truth table50%1/2
A
A= $self->get_host
| |||||||||||||
| 38 | 3 | ▶ | my $customer_id = $self->get_customer_id() || ""; | ||||||||||
|
Condition50%1/2
$self->get_customer_id || ''
MC/DC0%0/1
$self->get_customer_id || ''
$self->get_customer_id
Truth table50%1/2
A
A= $self->get_customer_id
| |||||||||||||
| 39 | 3 | ▶ | my $method = $self->get_method() || ""; | ||||||||||
|
Condition50%1/2
$self->get_method || ''
MC/DC0%0/1
$self->get_method || ''
$self->get_method
Truth table50%1/2
A
A= $self->get_method
| |||||||||||||
| 40 | 3 | ▶ | my $request_id = $self->get_request_id() || ""; | ||||||||||
|
Condition50%1/2
$self->get_request_id || ''
MC/DC0%0/1
$self->get_request_id || ''
$self->get_request_id
Truth table50%1/2
A
A= $self->get_request_id
| |||||||||||||
| 41 | 3 | ▶ | my $is_fault = $self->get_is_fault() ? "True" : "False"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 3 | ▶ | my $fault_message = $self->get_fault_message() || ""; | ||||||||||
|
Condition100%2/2
$self->get_fault_message || ''
MC/DC100%1/1
$self->get_fault_message || ''
$self->get_fault_message
Truth table100%2/2
A
A= $self->get_fault_message
| |||||||||||||
| 43 | |||||||||||||
| 44 | # Convert the fault message to one less than 16K characters. | ||||||||||||
| 45 | 3 | $fault_message =~ s/\r?\n/ /g; | |||||||||||
| 46 | 3 | my $utf8 = encode_utf8($fault_message); | |||||||||||
| 47 | 3 | my @utf8_chunks = $utf8 =~ /\G(.{1,16000})(?![\x80-\xBF])/sg; | |||||||||||
| 48 | 3 | $fault_message = decode_utf8($_) for @utf8_chunks; | |||||||||||
| 49 | |||||||||||||
| 50 | 3 | return " Host=${host}" . " ClientCustomerId=${customer_id}" . | |||||||||||
| 51 | " Method=${method}" . " RequestId=${request_id}" . | ||||||||||||
| 52 | " IsFault=${is_fault}" . " FaultMessage=${fault_message}"; | ||||||||||||
| 53 | 11 | ▶ | } | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 54 | |||||||||||||
| 55 | 11 | return 1; | |||||||||||
| 56 | |||||||||||||
| 57 | =pod | ||||||||||||
| 58 | |||||||||||||
| 59 | =head1 NAME | ||||||||||||
| 60 | |||||||||||||
| 61 | Google::Ads::GoogleAds::Logging::SummaryStats | ||||||||||||
| 62 | |||||||||||||
| 63 | =head1 DESCRIPTION | ||||||||||||
| 64 | |||||||||||||
| 65 | Class that wraps API request statistics such as client customer ID, request id, | ||||||||||||
| 66 | API method and others. | ||||||||||||
| 67 | |||||||||||||
| 68 | =head1 ATTRIBUTES | ||||||||||||
| 69 | |||||||||||||
| 70 | =head2 host | ||||||||||||
| 71 | |||||||||||||
| 72 | The Google Ads API server endpoint. | ||||||||||||
| 73 | |||||||||||||
| 74 | =head2 customer_id | ||||||||||||
| 75 | |||||||||||||
| 76 | The client customer id against which the API call was made. | ||||||||||||
| 77 | |||||||||||||
| 78 | =head2 method | ||||||||||||
| 79 | |||||||||||||
| 80 | The name of the service method that was called. | ||||||||||||
| 81 | |||||||||||||
| 82 | =head2 request_id | ||||||||||||
| 83 | |||||||||||||
| 84 | Request id of the call. | ||||||||||||
| 85 | |||||||||||||
| 86 | =head2 is_fault | ||||||||||||
| 87 | |||||||||||||
| 88 | Whether the request returned as a fault or not. | ||||||||||||
| 89 | |||||||||||||
| 90 | =head2 fault_message | ||||||||||||
| 91 | |||||||||||||
| 92 | The stack trace of up to 16K characters if a fault occurs. | ||||||||||||
| 93 | |||||||||||||
| 94 | =head1 LICENSE AND COPYRIGHT | ||||||||||||
| 95 | |||||||||||||
| 96 | Copyright 2019 Google LLC | ||||||||||||
| 97 | |||||||||||||
| 98 | Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||
| 99 | you may not use this file except in compliance with the License. | ||||||||||||
| 100 | You may obtain a copy of the License at | ||||||||||||
| 101 | |||||||||||||
| 102 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||
| 103 | |||||||||||||
| 104 | Unless required by applicable law or agreed to in writing, software | ||||||||||||
| 105 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||
| 106 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||
| 107 | See the License for the specific language governing permissions and | ||||||||||||
| 108 | limitations under the License. | ||||||||||||
| 109 | |||||||||||||
| 110 | =head1 REPOSITORY INFORMATION | ||||||||||||
| 111 | |||||||||||||
| 112 | $Rev: $ | ||||||||||||
| 113 | $LastChangedBy: $ | ||||||||||||
| 114 | $Id: $ | ||||||||||||
| 115 | |||||||||||||
| 116 | =cut | ||||||||||||