xref: /plugin/smtp/subtree/php-fig/log/Psr/Log/NullLogger.php (revision ae1ee236f55bbd7fd5e41a98f6cc93dbe5a5b903)
1*ae1ee236SAndreas Gohr<?php
2*ae1ee236SAndreas Gohr
3*ae1ee236SAndreas Gohrnamespace Psr\Log;
4*ae1ee236SAndreas Gohr
5*ae1ee236SAndreas Gohr/**
6*ae1ee236SAndreas Gohr * This Logger can be used to avoid conditional log calls.
7*ae1ee236SAndreas Gohr *
8*ae1ee236SAndreas Gohr * Logging should always be optional, and if no logger is provided to your
9*ae1ee236SAndreas Gohr * library creating a NullLogger instance to have something to throw logs at
10*ae1ee236SAndreas Gohr * is a good way to avoid littering your code with `if ($this->logger) { }`
11*ae1ee236SAndreas Gohr * blocks.
12*ae1ee236SAndreas Gohr */
13*ae1ee236SAndreas Gohrclass NullLogger extends AbstractLogger
14*ae1ee236SAndreas Gohr{
15*ae1ee236SAndreas Gohr    /**
16*ae1ee236SAndreas Gohr     * Logs with an arbitrary level.
17*ae1ee236SAndreas Gohr     *
18*ae1ee236SAndreas Gohr     * @param mixed  $level
19*ae1ee236SAndreas Gohr     * @param string $message
20*ae1ee236SAndreas Gohr     * @param array  $context
21*ae1ee236SAndreas Gohr     *
22*ae1ee236SAndreas Gohr     * @return null
23*ae1ee236SAndreas Gohr     */
24*ae1ee236SAndreas Gohr    public function log($level, $message, array $context = array())
25*ae1ee236SAndreas Gohr    {
26*ae1ee236SAndreas Gohr        // noop
27*ae1ee236SAndreas Gohr    }
28*ae1ee236SAndreas Gohr}
29