Passed
Push — develop ( c69915...84bf5c )
by Nikolay
04:00
created

LoggerAuthProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 15
rs 9.9332
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Copyright (C) MIKO LLC - All Rights Reserved
4
 * Unauthorized copying of this file, via any medium is strictly prohibited
5
 * Proprietary and confidential
6
 * Written by Nikolay Beketov, 4 2020
7
 *
8
 */
9
10
declare(strict_types=1);
11
12
namespace MikoPBX\Common\Providers;
13
14
use Phalcon\Di\DiInterface;
15
use Phalcon\Di\ServiceProviderInterface;
16
use Phalcon\Logger;
17
use Phalcon\Logger\Adapter\Syslog;
18
19
/**
20
 * LoggerAuth provider writes messages to main log file
21
 */
22
class LoggerAuthProvider implements ServiceProviderInterface
23
{
24
    public const SERVICE_NAME = 'loggerAuth';
25
26
    /**
27
     * Register syslog auth service provider
28
     *
29
     * @param \Phalcon\Di\DiInterface $di
30
     */
31
    public function register(DiInterface $di): void
32
    {
33
        $di->setShared(
34
            self::SERVICE_NAME,
35
            function () {
36
                $adapter = new Syslog(
37
                    'web_auth',
38
                    [
39
                        'option'   => LOG_PID | LOG_PERROR,
40
                        'facility' => LOG_AUTH,
41
                    ]
42
                );
43
                $logger =  new Logger('messages');
44
                $logger->addAdapter('main', $adapter);
45
                return $logger;
46
            }
47
        );
48
    }
49
}