File size: 851 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
<?php

declare(strict_types=1);

namespace Mautic\IntegrationsBundle\Sync\Logger;

use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

class DebugLogger
{
    private static ?LoggerInterface $logger = null;

    public function __construct(LoggerInterface $logger)
    {
        static::$logger = $logger;
    }

    /**
     * @param string $integration
     * @param string $loggedFrom
     * @param string $message
     * @param string $urgency
     */
    public static function log($integration, $message, $loggedFrom = null, array $context = [], $urgency = LogLevel::DEBUG): void
    {
        if (!static::$logger) {
            return;
        }

        if (null !== $loggedFrom) {
            $context['logged from'] = $loggedFrom;
        }

        static::$logger->$urgency(strtoupper($integration).' SYNC: '.$message, $context);
    }
}