modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-05-02 23:29:18 +04:00
parent 58f561a4e2
commit 7e7069e23f
2 changed files with 19 additions and 14 deletions

View File

@ -228,16 +228,11 @@ abstract class Application {
static function set_application_log_output(string $logfile): void {
msg::get()->setParametrableParams(["log_output" => $logfile]);
if (!nlog::have_log()) {
nlog::set_messenger_class(nStdMessenger::class, [
nlog::create_or_reset_params([
"output" => $logfile,
], nStdMessenger::class, [
"add_date" => true,
]);
} else {
nlog::reset_params([
"output" => $logfile,
]);
}
}
static function set_application_color(bool $color): void {
msg::get()->setParametrableParams(["color" => $color]);

View File

@ -1,6 +1,7 @@
<?php
namespace nur\sery\output;
use nur\sery\cl;
use nur\sery\ValueException;
use nur\sery\output\std\ProxyMessenger;
@ -11,10 +12,6 @@ use nur\sery\output\std\ProxyMessenger;
* d'être utilisée
*/
class log extends _messenger {
static function have_log(): bool {
return self::$log !== null;
}
static function set_messenger(IMessenger $log=null) {
self::$log = $log;
// forcer la recréation de l'instance partagée $msg
@ -36,4 +33,17 @@ class log extends _messenger {
}
return self::$msg;
}
static function have_log(): bool {
return self::$log !== null;
}
static function create_or_reset_params(?array $params=null, string $log_class=null, ?array $create_params=null) {
if (self::$log === null) {
$params = cl::merge($params, $create_params);
self::set_messenger_class($log_class, $params);
} else {
self::reset_params($params);
}
}
}