googleads / googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP
Apache License 2.0
655 stars 770 forks source link

Log file location #150

Closed david-navarro closed 8 years ago

david-navarro commented 8 years ago

Hi, I've detected in https://github.com/googleads/googleads-php-lib/blob/master/src/Google/Api/Ads/Common/Lib/AdsUser.php#L142 that $this->logsDirectory don't works for me. I'm using relative paths in my laravel project. I've changed for:

Logger::LogToFile(Logger::$SOAP_XML_LOG, $this->GetLogsDirectory() . "/soap_xml.log"); Logger::LogToFile(Logger::$REQUEST_INFO_LOG, $this->GetLogsDirectory() . "/request_info.log");

and it works so good for me...

david-navarro commented 8 years ago

I've made a pull request with this

vtsao commented 8 years ago

That change is a no-op. Can you clarify what you mean by it doesn't work for you? Does the code run without errors, but nothing gets logged to the logs directory?

Or is it some Laravel-specific issue? We don't officially support this library working in Laravel at this moment.

david-navarro commented 8 years ago

Maybe this change is a no-op in php but sure it fix an error in laravel when I try to find the path of the log file. I undestand that we don't officially support this library in laravel but if this change allow run it in laravel.. it will be better, right?

vtsao commented 8 years ago

Can you help me understand exactly why it doesn't work in Lavarel the way it is currently? Because there are many other occurrences in this library where we access private member variables in the same class directly and not through the getter.

david-navarro commented 8 years ago

I only have detected it doesn't work for laravel when init logs. I call LogDefaults() in AdWordsUser. This is my config file:

'settings' => [
    'LOGGING' => [
        /*
         * Log directory is either an absolute path, or relative path from the AdWordsUser.php file.
         */
        'PATH_RELATIVE' => '1',
        'LIB_LOG_DIR_PATH' => '../../../../../../storage/logs/adwords',
    ],

I don't know the reason.. debugging $this->logsDirectory is empty instead using the getter GetLogsDirectory() that contains just my log directory path.

So if I use the private variable my soap_xml.log and my request_info.log loggically are empty.

vtsao commented 8 years ago

I'm not going to make any changes unless I know the reason why this isn't working. I can't imagine that this is fixed by using a getter instead of the private member in the same class. Are you sure this is the only thing you changed that got it working and not anything else?

david-navarro commented 8 years ago

It doesn't matter, I extended my own class to init the logs and solved it. thank you anyway