mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-04 15:26:43 +02:00
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Plugins\Commands;
|
|
|
|
use Castopod\PluginsManager\Logger\FormatterInterface;
|
|
use Castopod\PluginsManager\Logger\LogLevel;
|
|
use CodeIgniter\CLI\CLI;
|
|
|
|
class CpmFormatterDebug implements FormatterInterface
|
|
{
|
|
public function format(LogLevel $level, array $log): void
|
|
{
|
|
match ($level) {
|
|
LogLevel::Success => CLI::write(
|
|
sprintf('%s %s', CLI::color($level->name, 'white', 'green'), json_encode(
|
|
$log,
|
|
JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT,
|
|
)),
|
|
),
|
|
LogLevel::Warning => CLI::write(
|
|
sprintf('%s %s', CLI::color($level->name, 'white', 'yellow'), json_encode(
|
|
$log,
|
|
JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT,
|
|
)),
|
|
),
|
|
LogLevel::Error => CLI::write(
|
|
sprintf('%s %s', CLI::color($level->name, 'white', 'red'), json_encode(
|
|
$log,
|
|
JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT,
|
|
)),
|
|
),
|
|
default => CLI::write(
|
|
sprintf('%s %s', CLI::color($level->name, 'white', 'blue'), json_encode(
|
|
$log,
|
|
JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT,
|
|
)),
|
|
),
|
|
};
|
|
}
|
|
}
|