leafsphp / logger

📂 Logging for leaf php
https://leafphp.dev/modules/logger/
2 stars 2 forks source link

Logger error: Attempt to read property "logWriter" on array #3

Closed jeijei4 closed 1 month ago

jeijei4 commented 2 months ago

I am upgrading my application to Leaf v3.6 and when trying the following:

app()->logger()->error("Save any error");

The following error appears:

Call to a member function error() on null

If in the configuration I change to 'log.enabled' => false,, the error changes to: Attempt to read property "logWriter" on array

Here: https://github.com/leafsphp/logger/blob/aee2379f484148dcff2e64e50807a2b55713b720/src/scripts.php#L13

Temporary solution

I temporarily changed it to the following and it works:

$log = new \Leaf\Log(\Leaf\Config::get("logWriter"));
ProxiBlue commented 2 months ago

Hello, just ran into issue, and this also fixes the logger (which seems completely broken after an update to leaf 3.6) Different error:

Warning: Undefined property: Leaf\App::$log in /var/www/html/vendor/leafs/leaf/src/App.php on line <i>232</i>

applying the above noted change also fixes this for me

Might need a new release with composer restrictions to "leafs/leaf">3.5

Unsure what the releae cycle is here, so if in a pinch, and ned to go on, use composer patches to resolve until update is available

composer require "vaimo/composer-patches"

Patch section in composer.json

"extra": {
    "patches": {
      "leafs/logger": {
        "Fix fail on leafs 3.6": "https://patch-diff.githubusercontent.com/raw/leafsphp/logger/pull/4.diff"
      }
    }
  }
mychidarko commented 1 month ago

I'm so sorry I just saw the issue and the PR. Can you pls tag me next time to make sure I see whatever issue it is. Thanks