4747use OCP \Log \IFileBased ;
4848use OCP \Log \IWriter ;
4949use OCP \Support \CrashReport \IRegistry ;
50+ use Psr \Log \LoggerInterface ;
51+ use Psr \Log \LogLevel ;
52+
5053use function strtr ;
5154
5255/**
5861 *
5962 * MonoLog is an example implementing this interface.
6063 */
61- class Log implements ILogger , IDataLogger {
64+ class Log implements LoggerInterface , IDataLogger {
6265 private IWriter $ logger ;
6366 private ?SystemConfig $ config ;
6467 private ?bool $ logConditionSatisfied = null ;
@@ -94,8 +97,8 @@ public function __construct(IWriter $logger, SystemConfig $config = null, Normal
9497 * @param array $context
9598 * @return void
9699 */
97- public function emergency (string $ message , array $ context = []) {
98- $ this ->log (ILogger:: FATAL , $ message , $ context );
100+ public function emergency ($ message , array $ context = []) {
101+ $ this ->log (LogLevel:: ERROR , $ message , $ context );
99102 }
100103
101104 /**
@@ -108,8 +111,8 @@ public function emergency(string $message, array $context = []) {
108111 * @param array $context
109112 * @return void
110113 */
111- public function alert (string $ message , array $ context = []) {
112- $ this ->log (ILogger ::ERROR , $ message , $ context );
114+ public function alert ($ message , array $ context = []) {
115+ $ this ->log (LogLevel ::ERROR , $ message , $ context );
113116 }
114117
115118 /**
@@ -121,8 +124,8 @@ public function alert(string $message, array $context = []) {
121124 * @param array $context
122125 * @return void
123126 */
124- public function critical (string $ message , array $ context = []) {
125- $ this ->log (ILogger ::ERROR , $ message , $ context );
127+ public function critical ($ message , array $ context = []) {
128+ $ this ->log (LogLevel ::ERROR , $ message , $ context );
126129 }
127130
128131 /**
@@ -133,8 +136,8 @@ public function critical(string $message, array $context = []) {
133136 * @param array $context
134137 * @return void
135138 */
136- public function error (string $ message , array $ context = []) {
137- $ this ->log (ILogger ::ERROR , $ message , $ context );
139+ public function error ($ message , array $ context = []) {
140+ $ this ->log (LogLevel ::ERROR , $ message , $ context );
138141 }
139142
140143 /**
@@ -147,8 +150,8 @@ public function error(string $message, array $context = []) {
147150 * @param array $context
148151 * @return void
149152 */
150- public function warning (string $ message , array $ context = []) {
151- $ this ->log (ILogger ::WARN , $ message , $ context );
153+ public function warning ($ message , array $ context = []) {
154+ $ this ->log (LogLevel ::WARN , $ message , $ context );
152155 }
153156
154157 /**
@@ -158,8 +161,8 @@ public function warning(string $message, array $context = []) {
158161 * @param array $context
159162 * @return void
160163 */
161- public function notice (string $ message , array $ context = []) {
162- $ this ->log (ILogger ::INFO , $ message , $ context );
164+ public function notice ($ message , array $ context = []) {
165+ $ this ->log (LogLevel ::INFO , $ message , $ context );
163166 }
164167
165168 /**
@@ -171,8 +174,8 @@ public function notice(string $message, array $context = []) {
171174 * @param array $context
172175 * @return void
173176 */
174- public function info (string $ message , array $ context = []) {
175- $ this ->log (ILogger ::INFO , $ message , $ context );
177+ public function info ($ message , array $ context = []) {
178+ $ this ->log (LogLevel ::INFO , $ message , $ context );
176179 }
177180
178181 /**
@@ -182,8 +185,8 @@ public function info(string $message, array $context = []) {
182185 * @param array $context
183186 * @return void
184187 */
185- public function debug (string $ message , array $ context = []) {
186- $ this ->log (ILogger ::DEBUG , $ message , $ context );
188+ public function debug ($ message , array $ context = []) {
189+ $ this ->log (LogLevel ::DEBUG , $ message , $ context );
187190 }
188191
189192
@@ -195,7 +198,7 @@ public function debug(string $message, array $context = []) {
195198 * @param array $context
196199 * @return void
197200 */
198- public function log (int $ level , string $ message , array $ context = []) {
201+ public function log ($ level , $ message , array $ context = []) {
199202 $ minLevel = $ this ->getLogLevel ($ context );
200203
201204 array_walk ($ context , [$ this ->normalizer , 'format ' ]);
@@ -269,7 +272,7 @@ public function getLogLevel($context) {
269272
270273 // if log condition is satisfied change the required log level to DEBUG
271274 if ($ this ->logConditionSatisfied ) {
272- return ILogger ::DEBUG ;
275+ return LogLevel ::DEBUG ;
273276 }
274277
275278 if (isset ($ context ['app ' ])) {
@@ -282,11 +285,11 @@ public function getLogLevel($context) {
282285 if (!empty ($ logCondition )
283286 && isset ($ logCondition ['apps ' ])
284287 && in_array ($ app , $ logCondition ['apps ' ], true )) {
285- return ILogger ::DEBUG ;
288+ return LogLevel ::DEBUG ;
286289 }
287290 }
288291
289- return min ($ this ->config ->getValue ('loglevel ' , ILogger:: WARN ), ILogger:: FATAL );
292+ return min ($ this ->config ->getValue ('loglevel ' , LogLevel:: WARNING ), LogLevel:: ERROR );
290293 }
291294
292295 /**
@@ -299,7 +302,7 @@ public function getLogLevel($context) {
299302 */
300303 public function logException (Throwable $ exception , array $ context = []) {
301304 $ app = $ context ['app ' ] ?? 'no app in context ' ;
302- $ level = $ context ['level ' ] ?? ILogger ::ERROR ;
305+ $ level = $ context ['level ' ] ?? LogLevel ::ERROR ;
303306
304307 $ minLevel = $ this ->getLogLevel ($ context );
305308 if ($ level < $ minLevel && ($ this ->crashReporters === null || !$ this ->crashReporters ->hasReporters ())) {
0 commit comments