On Sunday, 25 June 2017 19:21:33 UTC+1, Joaquin wrote:
>
> Hello. I was wondering if it was at all possible to have a static logger 
> option. For my purposes I do not need an object for logging and calling 
> non-static methods statically is deprecated in PHP 7.
>

Most platforms tend to avoid static libraries, because of the difficulty of 
injecting configuration details. The way to handle it is to instantiate it 
once at the start, with all the settings you need (e.g. file name and 
location, or some other logging channel). Then you keep using that single 
instantiation throughout the remainder of the application.

You just need to be able to *get at* the instantiation from anywhere, which 
means it will ultimately be in the global scope somewhere. Older 
applications would use a global `$logger` variable. Newer applications a 
locator service of some sort. That may be wrapped with a facade to give it 
some static availability. But the idea is, there is one instantiation, and 
the point of use - where messages are logged - should be simple and easy to 
use.

The PSR interface to all this is around the instantiated class, and that 
will be hidden from your main application code under the 
locator/global/facade/other layers you put on top.

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/7ea0f259-cf23-40d3-b92c-427f96af1ca7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to