Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging withLogger usage #818

Closed
LuisCabr opened this issue Jun 21, 2022 · 12 comments
Closed

Logging withLogger usage #818

LuisCabr opened this issue Jun 21, 2022 · 12 comments
Assignees
Labels
works as intended This will not be worked on because the feature works as intended

Comments

@LuisCabr
Copy link

LuisCabr commented Jun 21, 2022

Hi all,

I'm trying to configure the library to output DEBUG logging when doing API calls. To do so, i tried the following:


$logPath = '/tmp/google-ads.log';
$adsLoggerFactory = new LoggerFactory();
$logLevel = LogLevel::NOTICE;
$logger = $adsLoggerFactory->createLogger('google-ads', $logPath, $logLevel);

return (new GoogleAdsClientBuilder())
            ->withOAuth2Credential($oAuth2Credential)
            ->withDeveloperToken($this->developerToken)
            ->withLoginCustomerId($this->getCustomerId($this->loginCustomerId))
            ->withLogger($logger)
            ->build();

Its not working, or I'm doing something wrong because this is not producIng any output when I execute API calls.

Thanks in advance

@LuisCabr LuisCabr added question Further information is requested triage Need triage labels Jun 21, 2022
@PierrickVoulet
Copy link
Collaborator

PierrickVoulet commented Jun 21, 2022

Hi @LuisCabr - The following code works as expected on my side:

use Google\Ads\GoogleAds\Lib\V11\LoggerFactory;

//...

(new GoogleAdsClientBuilder())
   ->fromFile()
   ->withOAuth2Credential($oAuth2Credential)
   ->withLogger((new LoggerFactory())->createLogger(
      'google-ads',
      '/path/to/google-ads.log',
      'DEBUG'
   ))
   ->build();

Could you give it a try?

@PierrickVoulet PierrickVoulet added works as intended This will not be worked on because the feature works as intended and removed triage Need triage question Further information is requested labels Jun 21, 2022
@PierrickVoulet PierrickVoulet self-assigned this Jun 21, 2022
@LuisCabr
Copy link
Author

I'm using the V10 namespace, does it have any known issue?

use Google\Ads\GoogleAds\Lib\V10\LoggerFactory;

@LuisCabr
Copy link
Author

LuisCabr commented Jun 22, 2022

If I do the following:

$logPath = '/tmp/google-ads.log';
$adsLoggerFactory = new LoggerFactory();
$logLevel = 'DEBUG';
$logger = $adsLoggerFactory->createLogger('google-ads', $logPath, 'DEBUG');

$logger->debug('foo');

return (new GoogleAdsClientBuilder())
            ->withOAuth2Credential($oAuth2Credential)
            ->withDeveloperToken($this->developerToken)
            ->withLoginCustomerId($this->getCustomerId($this->loginCustomerId))
            ->withLogger($logger)
            ->withLogLevel($logLevel)
            ->build();

And If I run my code, it outputs the following on /tmp/google-ads.log:

[2022-06-22T07:27:02.299324+00:00] google-ads.DEBUG: foo

But no more log messages are written.

@PierrickVoulet
Copy link
Collaborator

I'm using the V10 namespace, does it have any known issue?

use Google\Ads\GoogleAds\Lib\V10\LoggerFactory;

As far as I know, no.

Could you confirm the transport that you are using (gRPC or REST)?

@LuisCabr
Copy link
Author

I'm using default option, gRPC

@PierrickVoulet
Copy link
Collaborator

I just tried again with V10 and it works as expected on my side.

I am using the version v15.1.0 of this library, could you confirm yours?

@LuisCabr
Copy link
Author

I have this one installed:

googleads/google-ads-php v15.0.0 Google Ads API client for PHP

@PierrickVoulet
Copy link
Collaborator

I'm using default option, gRPC

Could you provide the output generated by our complementary script: https://github.com/googleads/google-ads-php/blob/master/scripts/print_php_information.php. This will give us more information about your environment.

@LuisCabr
Copy link
Author

sure!

================= PHP GENERAL INFORMATION
phpinfo()
PHP Version => 7.4.29

System => Linux b52235b433c5 5.13.0-51-generic #58~20.04.1-Ubuntu SMP Tue Jun 14 11:29:12 UTC 2022 x86_64
Build Date => May 28 2022 09:28:28
Configure Command =>  './configure'  '--build=x86_64-linux-gnu' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--with-pic' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2' '--with-sodium=shared' '--with-pdo-sqlite=/usr' '--with-sqlite3=/usr' '--with-curl' '--with-iconv' '--with-openssl' '--with-readline' '--with-zlib' '--enable-phpdbg' '--enable-phpdbg-readline' '--with-pear' '--with-libdir=lib/x86_64-linux-gnu' '--enable-embed' 'build_alias=x86_64-linux-gnu'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => (none)
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini

PHP API => 20190902
PHP Extension => 20190902
Zend Extension => 320190902
Zend Extension Build => API320190902,NTS
PHP Extension Build => API20190902,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
================= PHP EXTENSION INFORMATION
The PHP Extension grpc is not installed
The PHP Extension protobuf is not installed

@PierrickVoulet
Copy link
Collaborator

Thanks. Looks like the PHP Extension grpc is not installed which means that the library falls back to the REST transport because requirements are not met. Logging is not currently supported with REST (see opened issue).

Installing and configuring the grpc PHP Extension as described in the Requirements section should fix your issue.

@LuisCabr
Copy link
Author

Thanks, gonna try it now and get back to you so you can close the issue.

@LuisCabr
Copy link
Author

Hi again,

I installed gRPC php extension and I was able to run the code perfectly without issues and get the expected logging output.

You can close the issue, thanks a lot for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
works as intended This will not be worked on because the feature works as intended
Projects
None yet
Development

No branches or pull requests

2 participants