intuit / QuickBooks-V3-PHP-SDK

Official PHP SDK for QuickBooks REST API v3.0: https://developer.intuit.com/
Apache License 2.0
241 stars 240 forks source link

executionlog.txt is not written #498

Open billynoah opened 12 months ago

billynoah commented 12 months ago

In src/Diagnostics/LoggerBase.php you have this code for logging diagnostics as described in your documentation:

    public function Log($idsTraceLevel, $messageToWrite)
    {
        $fileToWrite = CoreConstants::DEFAULT_LOGGINGLOCATION . '/executionlog.txt';
        if(file_exists($fileToWrite) && is_writable($fileToWrite))
        {
           file_put_contents($fileToWrite, $messageToWrite."\n", FILE_APPEND);
        }
    }

However without manual intervention, the log will never be written:

  1. There is no attempt in the codebase to actually create the directory specified by the path constant CoreConstants::DEFAULT_LOGGINGLOCATION which currently refers to "/tmp/IdsLogs".
  2. There is no attempt to actually create the file executionlog.txt.

Since neither the directory nor the file exist and are not created, the log will never be written.

I did this from a shell to get this log working:

mkdir /tmp/IdsLogs
touch /tmp/IdsLogs/executionlog.txt

The Log() method should either create the needed directory and file, or it should be documented that this file needs to be manually generated in order to be written.