aboutsummaryrefslogtreecommitdiff
path: root/src/Log.php
blob: fce455fe32232eb99a7d66101ff5ea7afdd3a979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php


namespace Micropoly;


use Monolog\Handler\ErrorLogHandler;
use Monolog\Logger;
use Psr\Log\LoggerInterface;

class Log
{
    public static function logger(): LoggerInterface
    {
        static $logger = null;
        if ($logger === null)
            $logger = self::initLogger();
        return $logger;
    }

    private static function initLogger(): Logger
    {
        $logger = new Logger("logger");
        $logger->pushHandler(new ErrorLogHandler());
        return $logger;
    }
}