blob: 4bb0e9d80f6b89f02e49803b3a0fd5fa14155549 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php
use Psr\Log\LoggerInterface;
/**
* @method static void alert(string $message, array $context = [])
* @method static void critical(string $message, array $context = [])
* @method static void debug(string $message, array $context = [])
* @method static void emergency(string $message, array $context = [])
* @method static void error(string $message, array $context = [])
* @method static void info(string $message, array $context = [])
* @method static void log($level, string $message, array $context = [])
* @method static void notice(string $message, array $context = [])
* @method static void warning(string $message, array $context = [])
*/
class Log
{
/**
* The underlying logger.
*
* @var LoggerInterface
*/
protected static $instance;
/**
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$instance = static::getInstance();
return $instance->$method(...$args);
}
public static function getInstance(): LoggerInterface
{
if (!isset(static::$instance)) {
static::$instance = app(LoggerInterface::class);
}
return static::$instance;
}
public static function setInstance(LoggerInterface $instance): void
{
static::$instance = $instance;
}
}
|