• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..23-Nov-2020-

Psr/Log/H23-Nov-2020-630220

LICENSEH A D22-Nov-20201.1 KiB2016

README.mdH A D22-Nov-20201.1 KiB4633

composer.jsonH A D22-Nov-2020511 2625

README.md

1PSR Log
2=======
3
4This 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
7Note that this is not a logger of its own. It is merely an interface that
8describes a logger. See the specification for more details.
9
10Usage
11-----
12
13If you need a logger, you can use the interface like this:
14
15```php
16<?php
17
18use Psr\Log\LoggerInterface;
19
20class 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
40You can then pick one of the implementations of the interface to get a logger.
41
42If you want to implement the interface, you can require this package and
43implement `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)
45for details.
46