summaryrefslogtreecommitdiff
path: root/vendor/psr/log/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/psr/log/README.md')
-rw-r--r--vendor/psr/log/README.md58
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/psr/log/README.md b/vendor/psr/log/README.md
new file mode 100644
index 0000000..a9f20c4
--- /dev/null
+++ b/vendor/psr/log/README.md
@@ -0,0 +1,58 @@
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
10Installation
11------------
12
13```bash
14composer require psr/log
15```
16
17Usage
18-----
19
20If you need a logger, you can use the interface like this:
21
22```php
23<?php
24
25use Psr\Log\LoggerInterface;
26
27class Foo
28{
29 private $logger;
30
31 public function __construct(LoggerInterface $logger = null)
32 {
33 $this->logger = $logger;
34 }
35
36 public function doSomething()
37 {
38 if ($this->logger) {
39 $this->logger->info('Doing work');
40 }
41
42 try {
43 $this->doSomethingElse();
44 } catch (Exception $exception) {
45 $this->logger->error('Oh no!', array('exception' => $exception));
46 }
47
48 // do something useful
49 }
50}
51```
52
53You can then pick one of the implementations of the interface to get a logger.
54
55If you want to implement the interface, you can require this package and
56implement `Psr\Log\LoggerInterface` in your code. Please read the
57[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
58for details.