1779752420
markdown-b8a96a94b203ef2bf029b909f8bf6f1eb713bdb2
s:1488:"<h1>PSR Log</h1>
<p>This repository holds all interfaces/classes/traits related to
<a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md">PSR-3</a>.</p>
<p>Note that this is not a logger of its own. It is merely an interface that
describes a logger. See the specification for more details.</p>
<h2>Installation</h2>
<pre><code class="language-bash">composer require psr/log</code></pre>
<h2>Usage</h2>
<p>If you need a logger, you can use the interface like this:</p>
<pre><code class="language-php">&lt;?php

use Psr\Log\LoggerInterface;

class Foo
{
    private $logger;

    public function __construct(LoggerInterface $logger = null)
    {
        $this-&gt;logger = $logger;
    }

    public function doSomething()
    {
        if ($this-&gt;logger) {
            $this-&gt;logger-&gt;info('Doing work');
        }

        try {
            $this-&gt;doSomethingElse();
        } catch (Exception $exception) {
            $this-&gt;logger-&gt;error('Oh no!', array('exception' =&gt; $exception));
        }

        // do something useful
    }
}</code></pre>
<p>You can then pick one of the implementations of the interface to get a logger.</p>
<p>If you want to implement the interface, you can require this package and
implement <code>Psr\Log\LoggerInterface</code> in your code. Please read the
<a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md">specification text</a>
for details.</p>";