Skip to content

Commit ccd554f

Browse files
szaimenmiaulalala
andcommitted
fixup! fix(CapabilitiesManager): only log execution time if debug mode is enabled
Signed-off-by: Simon L. <szaimen@e.mail.de> Co-Authored-By: Anna <anna@nextcloud.com>
1 parent 89aa1ed commit ccd554f

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

lib/private/CapabilitiesManager.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,23 @@ public function getCapabilities(bool $public = false, bool $initialState = false
6464

6565
// Only check execution time if debug mode is enabled
6666
$debugMode = \OCP\Server::get(IConfig::class)->getSystemValueBool('debug', false);
67-
if ($debugMode) {
68-
$timeSpent = $endTime - $startTime;
69-
if ($timeSpent > self::ACCEPTABLE_LOADING_TIME) {
70-
$logLevel = match (true) {
71-
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 16 => ILogger::FATAL,
72-
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 8 => ILogger::ERROR,
73-
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 4 => ILogger::WARN,
74-
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 2 => ILogger::INFO,
75-
default => ILogger::DEBUG,
76-
};
77-
$this->logger->log(
78-
$logLevel,
79-
'Capabilities of {className} took {duration} seconds to generate.',
80-
[
81-
'className' => get_class($c),
82-
'duration' => round($timeSpent, 2),
83-
]
84-
);
85-
}
67+
$timeSpent = $endTime - $startTime;
68+
if ($debugMode && $timeSpent > self::ACCEPTABLE_LOADING_TIME) {
69+
$logLevel = match (true) {
70+
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 16 => ILogger::FATAL,
71+
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 8 => ILogger::ERROR,
72+
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 4 => ILogger::WARN,
73+
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 2 => ILogger::INFO,
74+
default => ILogger::DEBUG,
75+
};
76+
$this->logger->log(
77+
$logLevel,
78+
'Capabilities of {className} took {duration} seconds to generate.',
79+
[
80+
'className' => get_class($c),
81+
'duration' => round($timeSpent, 2),
82+
]
83+
);
8684
}
8785
}
8886
} else {

0 commit comments

Comments
 (0)