@tassoman opened this Issue on November 29th 2017 Contributor

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

@simivar commented on February 15th 2018

@sgiehl @mattab @tsteur any suggestions?

@mattab commented on February 16th 2018 Owner

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?

@tsteur commented on February 16th 2018 Owner

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 :)

@simivar commented on February 16th 2018

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?

@tsteur commented on February 16th 2018 Owner

yep

@tassoman commented on February 16th 2018 Contributor

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 ^ç^

@simivar commented on February 16th 2018

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

Powered by GitHub Issue Mirror