summaryrefslogtreecommitdiff
path: root/app/ServiceProvider/LoggingProvider.php
blob: 68c074f01831961bf7148f05191d6eea6a8b5ec3 (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
28
29
30
31
32
<?php

namespace Kanboard\ServiceProvider;

use Psr\Log\LogLevel;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use SimpleLogger\Logger;
use SimpleLogger\Syslog;
use SimpleLogger\File;

class LoggingProvider implements ServiceProviderInterface
{
    public function register(Container $container)
    {
        $logger = new Logger;

        if (ENABLE_SYSLOG) {
            $syslog = new Syslog('kanboard');
            $syslog->setLevel(LogLevel::ERROR);
            $logger->setLogger($syslog);
        }

        if (DEBUG) {
            $logger->setLogger(new File(DEBUG_FILE));
        }

        $container['logger'] = $logger;

        return $container;
    }
}