|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (c) 2018, Roeland Jago Douma <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU AGPL version 3 or any later version |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
13
|
|
|
* License, or (at your option) any later version. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU Affero General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace OC\AppFramework; |
|
26
|
|
|
|
|
27
|
|
|
use OCP\ILogger; |
|
28
|
|
|
|
|
29
|
|
|
class Logger implements ILogger { |
|
30
|
|
|
|
|
31
|
|
|
/** @var ILogger */ |
|
32
|
|
|
private $logger; |
|
33
|
|
|
|
|
34
|
|
|
/** @var string */ |
|
35
|
|
|
private $appName; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct(ILogger $logger, string $appName) { |
|
38
|
|
|
$this->logger = $logger; |
|
39
|
|
|
$this->appName = $appName; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
private function extendContext(array $context): array { |
|
43
|
|
|
if (!isset($context['app'])) { |
|
44
|
|
|
$context['app'] = $this->appName; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return $context; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function emergency(string $message, array $context = []) { |
|
51
|
|
|
$this->logger->emergency($message, $this->extendContext($context)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function alert(string $message, array $context = []) { |
|
55
|
|
|
$this->logger->alert($message, $this->extendContext($context)); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function critical(string $message, array $context = []) { |
|
59
|
|
|
$this->logger->critical($message, $this->extendContext($context)); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function error(string $message, array $context = []) { |
|
63
|
|
|
$this->logger->emergency($message, $this->extendContext($context)); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function warning(string $message, array $context = []) { |
|
67
|
|
|
$this->logger->warning($message, $this->extendContext($context)); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function notice(string $message, array $context = []) { |
|
71
|
|
|
$this->logger->notice($message, $this->extendContext($context)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function info(string $message, array $context = []) { |
|
75
|
|
|
$this->logger->info($message, $this->extendContext($context)); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function debug(string $message, array $context = []) { |
|
79
|
|
|
$this->logger->debug($message, $this->extendContext($context)); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function log(int $level, string $message, array $context = []) { |
|
83
|
|
|
$this->logger->log($level, $message, $this->extendContext($context)); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function logException(\Throwable $exception, array $context = []) { |
|
87
|
|
|
$this->logger->logException($exception, $this->extendContext($context)); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|