Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 - 1
PSR Log
2
=======
3
 
4
This repository holds all interfaces/classes/traits related to
5
[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).
6
 
7
Note that this is not a logger of its own. It is merely an interface that
8
describes a logger. See the specification for more details.
9
 
10
Usage
11
-----
12
 
13
If you need a logger, you can use the interface like this:
14
 
15
```php
16
<?php
17
 
18
use Psr\Log\LoggerInterface;
19
 
20
class Foo
21
{
22
    private $logger;
23
 
24
    public function __construct(LoggerInterface $logger = null)
25
    {
26
        $this->logger = $logger;
27
    }
28
 
29
    public function doSomething()
30
    {
31
        if ($this->logger) {
32
            $this->logger->info('Doing work');
33
        }
34
 
35
        // do something useful
36
    }
37
}
38
```
39
 
40
You can then pick one of the implementations of the interface to get a logger.
41
 
42
If you want to implement the interface, you can require this package and
43
implement `Psr\Log\LoggerInterface` in your code. Please read the
44
[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
45
for details.