2014年11月12日星期三

Imagine Easy Solutions Blog: Testing Logging in Silex


On the Imagine Easy Solutions blog Yitzchak Schaffer talks some about logging in Silex by making use of a MonologServiceProvider. You can find the end result of his setup in this GitHub repository.



Silex is a PHP microframework from the same family as Symfony. My shop, Imagine Easy Solutions, uses Silex for some of our most important applications. Modular setup is at the core of Silex's game, by means of Service Providers. The MonologServiceProvider makes it easy to add highly configurable logging to your application. But how to test your logging? It turns out that this Service Provider includes a DebugHandler which you can use to make log entries available in array form.


He walks you through the integration of the service provider via a "debug handler" and configuring it in the setup method. He also includes an "assertLogEntry" method to evaluate the current logs and check to ensure an entry was made. Finally, he puts it to use via a "notOk" method.


Link: http://dev.imagineeasy.com/post/102394035784/testing-logging-in-silex

没有评论:

发表评论