In his latest post Stephan Hochdörfer shares a library he's created to hopefully make it easier for developers to integrate PSR-3 compatible logging libraries into their code, a "logging facade" based on an idea from the Java world.
Lately I have seen more and more libraries picking up PSR-3 when it comes to logging. What a lot of libaries do wrong is that they depend on a concrete implementation of PSR-3, e.g. Mongolog instead of relying on the PSR-3 interface. From what I have seen this is because loggers get instantiated directly within the class. This is not a bad thing but it couples your code to a concrete implementation of PSR-3 which in turn means that there`s no interoperability.
The Java community solved the problem by creating a Simple Logging Facade library (SLF4) which I "ported" to PHP last week.
The library makes provides a simple static interface to setting the PSR-3 logger of your choice and fetching it from anywhere in your application. He includes an example of what the code would look like for a basic Monolog instance. He ends the post talking about this method for getting/setting the logger instance and how it compares to using other options like a dependency injection container or even just a manual call to a setter.
Link: https://blog.bitexpert.de/blog/simple-logging-facade-for-psr-3-loggers/
Python program to check prime number
回复删除PHP Secure User Registration with Login/logout
Python Matplotlib 3D Plot
How to display image from database in Django
PHP Encrypt Password
PHP File Upload MIME Type Validation with Error Handling
Detect Mobile Devices in PHP