Matomo: Wrong documentation abt Logging in Piwik 3.x

Created on 29 Nov 2017  路  7Comments  路  Source: matomo-org/matomo

Ciao!
I'm updating an old plugin born while Piwik was 1.x. It flawless worked inside Piwik 2.x but now must be updated.

I've started from scratch generating plugin's parts using console generator. Now I have a custom Dimension, I'm on its development and I'm trying to log things inside plugins/ThePlugin/Columns/ColumnName.php onNewVisit method.

Piwik 3.x Logging documentation suggests to log using StaticContainer::getContainer()->get('Psr\Log\LoggerInterface') (as 2.X docs said before) but inside PHPStorm that stuff pops up as deprecated.
While I was reading StaticContainer source code I found a note: in 3.X release will be removed.

  • looks like isn't removed yet
  • there's no indication how to use DI instead
  • 3.X documentation seems inconsistent

Any help and suggestion how to get rid of StaticContainer and using real DI is appreciated 馃樃
Best regards, thank you

Most helpful comment

It won't be removed any time soon and feel free to use it. Won't even b removed in Matomo 4.0.

In case you want to log eg in a dimension, this should work best without needing to use StaticContainer:

    public function __construct(\Psr\Log\LoggerInterface $log)
    {
        $this->log = $log;
    }

There is no doc to be updated as StaticContainer is still deprecated and avoided to be used. Although the message "that it will be removed in 3.0" could be actually removed :)

All 7 comments

@sgiehl @mattab @tsteur any suggestions?

not sure myself what to answer - @sgiehl @tsteur maybe we could remove the note that it is deprecated or so, or what would you suggest as next step?

It won't be removed any time soon and feel free to use it. Won't even b removed in Matomo 4.0.

In case you want to log eg in a dimension, this should work best without needing to use StaticContainer:

    public function __construct(\Psr\Log\LoggerInterface $log)
    {
        $this->log = $log;
    }

There is no doc to be updated as StaticContainer is still deprecated and avoided to be used. Although the message "that it will be removed in 3.0" could be actually removed :)

Okay, thanks. As far as I understand is that StaticContainer will be deleted in future (a distant one) and replaced with Dependency Injection but that's not happening now because of more presssing issues and lack of hands, is that correct?

yep

For me is enough to know and I think if someone will find help about it will find this post.
The only thing stills open is this:

I found a note: in 3.X release will be removed.

Maybe should be updated _芦in 4.x release will be removed禄_ ?

Thank you all for supporting ^莽^

I would propose removing "that it will be removed in 3.0" and instead link to this issue as it makes everything clear.

Was this page helpful?
0 / 5 - 0 ratings