php - Using Zend_Log in custom classes -


I am using Zend_Log and other required sections without the MVC framework. I want to add Z's logging capabilities (and other modules in the future) in my custom classes and I am wondering what is the best way to do this.

Now I have a cover for Zend logger, possibly, I can get it globally:

  My_log :: log ('test', 'zend_log' :: Information);   

Should I add this code to each class that I want to log in? Should not I log inside my classes? Dependent injection container sounds like a great solution if your app can integrate all static call environments.

Take care of this doctor around

The worst case I My_Log :: get () -> Error ("message") such as a fixed recipient will make; The only point is that you will now be able to easily correct a test environment so that you can get a fake example. All of your My_Log needs a setLogger ($ logger) which will replace a fake or with a fixed frequency, in any way static calls are bad: / if possible to double the classes Try so that they rely on as few classes as possible. It is a good idea to even manually log the logger into the injection of your class constructor. If you can provide the MVC Action Plugin or the Base Controller lazy loading getLogger () , then your code will be $ this-> getLogger () - & gt; Error ('...' );

Art

Comments