Logger.php
846 字节
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
<?php
namespace Lackoxygen\ShowDocGeneration;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
class Logger
{
public const NONE = 0;
public const DISPLAY = 1;
/**
* @var int
*/
private static int $mode;
/**
* @var OutputInterface $outputInterface
*/
private static OutputInterface $outputInterface;
/**
* @return void
*/
public static function setMode(int $mode)
{
self::$mode = $mode;
}
public static function setOutput(OutputInterface $output)
{
self::$outputInterface = $output;
}
public static function writeln(string $message)
{
if (self::$mode) {
self::$outputInterface->writeln(sprintf("[%s]: %s", now()->toString(), $message));
}
}
}