nextcloud/lib/private/OpenMetrics/Exporters/LogLevel.php
Benjamin Gaussorgues a7281ad36e feat(openmetrics): add log level
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
2026-01-25 16:12:17 +00:00

44 lines
859 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\OpenMetrics\Exporters;
use Generator;
use OCP\IConfig;
use OCP\ILogger;
use OCP\OpenMetrics\IMetricFamily;
use OCP\OpenMetrics\Metric;
use OCP\OpenMetrics\MetricType;
class LogLevel implements IMetricFamily {
public function __construct(
private IConfig $config,
) {
}
public function name(): string {
return 'log_level';
}
public function type(): MetricType {
return MetricType::gauge;
}
public function unit(): string {
return '';
}
public function help(): string {
return 'Current log level (lower level means more logs)';
}
public function metrics(): Generator {
yield new Metric((int)$this->config->getSystemValue('loglevel', ILogger::WARN));
}
}