Re: static Logging class?
| From: | Ravi Gehlot | Date: | Mon, 04 Mar 2013 02:40:01 +0000 |
| Subject: | Re: static Logging class? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320375@lists.php.net to get a copy of this message | ||
Hello Larry,
Thanks for sharing!
-------------------------------------------------
[image: logo]
*Ravi Gehlot
*
Mobile: 407-283-5282
Orlando, FL 32765-8085
http://www.RaviGehlot.Net/
https://github.com/ravigehlot
*"First, solve the problem. Then, write the code."*
[image: Twitter] <http://www.twitter.com/ravigehlot> [image:
LinkedIn]<http://www.linkedin.com/in/ravigehlot> [image:
Amazon]<https://www.amazon.com/gp/pdp/profile/A35NGY72YZSFR7?ie=UTF8&ref_=ya_56>
[image:
Meetup] <http://www.meetup.com/members/12029903/>
[image:
pinterest]<http://pinterest.com/ravigehlot/>
[image:
reddit] <http://www.reddit.com/user/ravigehlot/>
Contact me: [image: Google Talk] ravigehlot [image: Skype] ravigehlot [image:
Y! Messenger] ravigehlot
On Sun, Mar 3, 2013 at 1:48 PM, Larry Garfield <larry@garfieldtech.com>wrote:
> Make a real classed object that you pass to various objects that need it.
> Otherwise you make your life way harder for unit testing. Don't have a
> class that self-enforces that it's a singleton. That way lies pain.
>
> In particular, I recommend using or writing a class based on the PSR-3
> recommendation:
>
> https://github.com/php-fig/**fig-standards/blob/master/**
>
> accepted/PSR-3-logger-**interface.md<https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md>
>
> There's even stock code for the interface and some useful base classes
> available:
>
>
> https://packagist.org/**packages/psr/log<https://packagist.org/packages/psr/log>
>
> And for added fun, there are already publicly available open source
> libraries that implement PSR-3 that you can just drop in and use, such as:
>
>
> https://packagist.org/**packages/monolog/monolog<https://packagist.org/packages/monolog/monolog>
>
> (If that's too heavy for you, writing your own PSR-3 compatible logger is
> dead-simple.)
>
>
> I'm sure you're about to say "zOMG this is just a hobby project, I don't
> need something that fancy and all injected and shit!" If it's a simple
> project, use a simple container to do all the hard work for you:
>
>
> https://packagist.org/**packages/pimple/pimple<https://packagist.org/packages/pimple/pimple>
>
> (That's < 100 lines of executable code. Quite powerful, dead simple to
> use.)
>
> Cheers.
>
> --Larry Garfield, FIG member
>
>
>
> On 03/03/2013 07:26 AM, Lars Nielsen wrote:
>
>> Hi,
>>
>> I work on a little hobby-project, and i want to make a oo logging
>> facility. (php5.3 oop)
>>
>> Is it best to make a class with static functions that i can call from my
>> other classes? Or is it more appropriate to make a real logging-class i
>> should instantiate every time i need to log something? (I just want to
>> log to a file)
>>
>> Best regards
>> Lars Nielsen
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>