Passed
Push — master ( 6e9496...0e6475 )
by Pauli
04:14
created

Logger::warning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * ownCloud
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @author Pauli Järvinen <[email protected]>
11
 * @copyright Alessandro Cosentino 2012
12
 * @copyright Bernhard Posselt 2012, 2014
13
 * @copyright Pauli Järvinen 2018 - 2025
14
 */
15
16
namespace OCA\Music\AppFramework\Core;
17
18
use OCP\IServerContainer;
19
20
class Logger {
21
22
	protected string $appName;
23
	/** @var \OCP\ILogger|\Psr\Log\LoggerInterface $logger */
24
	protected $logger;
25
26
	public function __construct(string $appName, IServerContainer $container) {
27
		$this->appName = $appName;
28
29
		// NC 31 removed the getLogger method but the Psr alternative is not available on OC
30
		if (\method_exists($container, 'getLogger')) { // @phpstan-ignore function.alreadyNarrowedType
31
			$this->logger = $container->getLogger();
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IServerContainer::getLogger() has been deprecated: 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

31
			$this->logger = /** @scrutinizer ignore-deprecated */ $container->getLogger();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
32
		} else {
33
			$this->logger = $container->get(\Psr\Log\LoggerInterface::class);
34
		}
35
	}
36
37
	public function emergency(string $message) : void
38
	{
39
		$this->logger->emergency($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::emergency() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::emergency ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

39
		/** @scrutinizer ignore-deprecated */ $this->logger->emergency($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
40
	}
41
42
	/**
43
	 * Action must be taken immediately.
44
	 */
45
	public function alert(string $message) : void
46
	{
47
		$this->logger->alert($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::alert() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::alert ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
		/** @scrutinizer ignore-deprecated */ $this->logger->alert($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
48
	}
49
50
	/**
51
	 * Critical conditions.
52
	 */
53
	public function critical(string $message) : void
54
	{
55
		$this->logger->critical($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::critical() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::critical ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
		/** @scrutinizer ignore-deprecated */ $this->logger->critical($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
	}
57
58
	/**
59
	 * Runtime errors that do not require immediate action but should typically
60
	 * be logged and monitored.
61
	 */
62
	public function error(string $message) : void
63
	{
64
		$this->logger->error($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::error() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::error ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

64
		/** @scrutinizer ignore-deprecated */ $this->logger->error($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
65
	}
66
67
	/**
68
	 * Exceptional occurrences that are not errors.
69
	 */
70
	public function warning(string $message) : void
71
	{
72
		$this->logger->warning($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::warning() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::warning ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

72
		/** @scrutinizer ignore-deprecated */ $this->logger->warning($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
73
	}
74
75
	/**
76
	 * Normal but significant events.
77
	 */
78
	public function notice(string $message) : void
79
	{
80
		$this->logger->notice($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::notice() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::notice ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

80
		/** @scrutinizer ignore-deprecated */ $this->logger->notice($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
81
	}
82
83
	/**
84
	 * Interesting events.
85
	 */
86
	public function info(string $message) : void
87
	{
88
		$this->logger->info($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::info() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::info ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

88
		/** @scrutinizer ignore-deprecated */ $this->logger->info($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
89
	}
90
91
	/**
92
	 * Detailed debug information.
93
	 */
94
	public function debug(string $message) : void
95
	{
96
		$this->logger->debug($message, ['app' => $this->appName]);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\ILogger::debug() has been deprecated: 20.0.0 use \Psr\Log\LoggerInterface::debug ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

96
		/** @scrutinizer ignore-deprecated */ $this->logger->debug($message, ['app' => $this->appName]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
97
	}
98
99
}
100