modifs.mineures sans commentaires
This commit is contained in:
parent
903014e997
commit
54de648f10
@ -28,7 +28,7 @@ class UserException extends RuntimeException {
|
||||
}
|
||||
|
||||
function setTechMessage($techMessage): self {
|
||||
$techMessage ??= c::resolve($techMessage);
|
||||
if ($techMessage !== null) $techMessage = c::resolve($techMessage);
|
||||
$this->techMessage = $techMessage;
|
||||
return $this;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use nulib\ext\yaml;
|
||||
use nulib\output\console;
|
||||
use nulib\output\log;
|
||||
use nulib\output\msg;
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
use nulib\ref\ref_profiles;
|
||||
|
||||
/**
|
||||
@ -192,7 +192,7 @@ EOT);
|
||||
protected static function _initialize_app(): void {
|
||||
app::init(static::class);
|
||||
app::set_fact(app::FACT_CLI_APP);
|
||||
msg::set_messenger(new StdMessenger([
|
||||
msg::set_messenger(new ConsoleMessenger([
|
||||
"min_level" => msg::DEBUG,
|
||||
]));
|
||||
}
|
||||
@ -201,11 +201,11 @@ EOT);
|
||||
config::configure(config::CONFIGURE_INITIAL_ONLY);
|
||||
|
||||
$msgs = null;
|
||||
$msgs["console"] = new StdMessenger([
|
||||
$msgs["console"] = new ConsoleMessenger([
|
||||
"min_level" => msg::NORMAL,
|
||||
]);
|
||||
if (static::USE_LOGFILE) {
|
||||
$msgs["log"] = new StdMessenger([
|
||||
$msgs["log"] = new ConsoleMessenger([
|
||||
"output" => app::get()->getLogfile(),
|
||||
"min_level" => msg::MINOR,
|
||||
"add_date" => true,
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace nulib\output;
|
||||
|
||||
use nulib\output\std\ProxyMessenger;
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
|
||||
/**
|
||||
* Class log: inscrire un message dans les logs uniquement
|
||||
@ -30,7 +30,7 @@ class log extends _messenger {
|
||||
static function set_output(string $logfile): void {
|
||||
self::create_or_reset_params([
|
||||
"output" => $logfile,
|
||||
], StdMessenger::class, [
|
||||
], ConsoleMessenger::class, [
|
||||
"add_date" => true,
|
||||
"min_level" => self::MINOR,
|
||||
]);
|
||||
|
@ -8,7 +8,7 @@ use nulib\exceptions;
|
||||
use nulib\ExceptionShadow;
|
||||
use Throwable;
|
||||
|
||||
trait _TMessenger {
|
||||
abstract class AbstractMessenger implements _IMessenger {
|
||||
protected static function verifix_level($level, int $max_level=self::MAX_LEVEL): int {
|
||||
if (!in_array($level, self::VALID_LEVELS, true)) {
|
||||
$level = cl::get(self::LEVEL_MAP, $level, $level);
|
||||
@ -22,6 +22,24 @@ trait _TMessenger {
|
||||
return $level;
|
||||
}
|
||||
|
||||
/** @var StdOutput la sortie standard */
|
||||
protected StdOutput $out;
|
||||
|
||||
/** @var int level par défaut dans lequel les messages sont affichés */
|
||||
protected int $defaultLevel;
|
||||
|
||||
/** @var int level minimum que doivent avoir les messages pour être affichés */
|
||||
protected int $minLevel;
|
||||
|
||||
/** @var bool faut-il ajouter la date à chaque ligne? */
|
||||
protected bool $addDate;
|
||||
|
||||
/** @var string format de la date */
|
||||
protected string $dateFormat;
|
||||
|
||||
/** @var ?string identifiant de ce messenger, à ajouter à chaque ligne */
|
||||
protected ?string $id;
|
||||
|
||||
protected function getLinePrefix(): ?string {
|
||||
$linePrefix = null;
|
||||
if ($this->addDate) {
|
||||
@ -46,18 +64,6 @@ trait _TMessenger {
|
||||
return $level >= $this->minLevel;
|
||||
}
|
||||
|
||||
protected function getIndentLevel(bool $withActions=true): int {
|
||||
$indentLevel = count($this->titles) - 1;
|
||||
if ($indentLevel < 0) $indentLevel = 0;
|
||||
if ($withActions) {
|
||||
foreach ($this->actions as $action) {
|
||||
if ($action["level"] < $this->minLevel) continue;
|
||||
$indentLevel++;
|
||||
}
|
||||
}
|
||||
return $indentLevel;
|
||||
}
|
||||
|
||||
protected function _printTitle(
|
||||
?string $linePrefix, int $level,
|
||||
string $type, $content,
|
||||
@ -108,6 +114,8 @@ trait _TMessenger {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract function flushActions(bool $endAction=false, ?int $overrideLevel=null): void;
|
||||
|
||||
protected function _printAction(
|
||||
?string $linePrefix, int $level,
|
||||
bool $printContent, $content,
|
||||
@ -243,10 +251,10 @@ trait _TMessenger {
|
||||
$content = null;
|
||||
}
|
||||
|
||||
$printActions = true;
|
||||
$flushActions = true;
|
||||
$showContent = $this->checkLevel($level);
|
||||
if ($content !== null && $showContent) {
|
||||
$this->printActions(); $printActions = false;
|
||||
$this->flushActions(); $flushActions = false;
|
||||
$this->_printGeneric($linePrefix, $level, $type, $content, $indentLevel, $out);
|
||||
}
|
||||
if ($exceptions !== null) {
|
||||
@ -256,12 +264,12 @@ trait _TMessenger {
|
||||
# tout d'abord message
|
||||
$message = exceptions::get_message($exception);
|
||||
if ($showContent) {
|
||||
if ($printActions) { $this->printActions(); $printActions = false; }
|
||||
if ($flushActions) { $this->flushActions(); $flushActions = false; }
|
||||
$this->_printGeneric($linePrefix, $level, $type, $message, $indentLevel, $out);
|
||||
}
|
||||
# puis summary et traceback
|
||||
if ($showTraceback) {
|
||||
if ($printActions) { $this->printActions(); $printActions = false; }
|
||||
if ($flushActions) { $this->flushActions(); $flushActions = false; }
|
||||
$summary = exceptions::get_summary($exception, false);
|
||||
$this->_printGeneric($linePrefix, $level1, $type, $summary, $indentLevel, $out);
|
||||
$traceback = exceptions::get_traceback($exception);
|
||||
@ -270,5 +278,4 @@ trait _TMessenger {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,9 +9,7 @@ use nulib\ExceptionShadow;
|
||||
use nulib\output\IMessenger;
|
||||
use Throwable;
|
||||
|
||||
class StdMessenger implements _IMessenger {
|
||||
use _TMessenger;
|
||||
|
||||
class ConsoleMessenger extends AbstractMessenger {
|
||||
function __construct(?array $params=null) {
|
||||
$output = cl::get($params, "output");
|
||||
$color = cl::get($params, "color");
|
||||
@ -103,27 +101,9 @@ class StdMessenger implements _IMessenger {
|
||||
return $clone;
|
||||
}
|
||||
|
||||
/** @var StdOutput la sortie standard */
|
||||
protected $out;
|
||||
|
||||
/** @var StdOutput la sortie d'erreur */
|
||||
protected $err;
|
||||
|
||||
/** @var int level par défaut dans lequel les messages sont affichés */
|
||||
protected $defaultLevel;
|
||||
|
||||
/** @var int level minimum que doivent avoir les messages pour être affichés */
|
||||
protected $minLevel;
|
||||
|
||||
/** @var bool faut-il ajouter la date à chaque ligne? */
|
||||
protected $addDate;
|
||||
|
||||
/** @var string format de la date */
|
||||
protected $dateFormat;
|
||||
|
||||
/** @var ?string identifiant de ce messenger, à ajouter à chaque ligne */
|
||||
protected $id;
|
||||
|
||||
/** @var bool est-on dans une section? */
|
||||
protected $inSection;
|
||||
|
||||
@ -171,6 +151,24 @@ class StdMessenger implements _IMessenger {
|
||||
/** @var array */
|
||||
protected $title;
|
||||
|
||||
/** @var array */
|
||||
protected $actions;
|
||||
|
||||
/** @var array */
|
||||
protected $action;
|
||||
|
||||
protected function getIndentLevel(bool $withActions=true): int {
|
||||
$indentLevel = count($this->titles) - 1;
|
||||
if ($indentLevel < 0) $indentLevel = 0;
|
||||
if ($withActions) {
|
||||
foreach ($this->actions as $action) {
|
||||
if ($action["level"] < $this->minLevel) continue;
|
||||
$indentLevel++;
|
||||
}
|
||||
}
|
||||
return $indentLevel;
|
||||
}
|
||||
|
||||
function _getTitleMark(): int {
|
||||
return count($this->titles);
|
||||
}
|
||||
@ -246,44 +244,7 @@ class StdMessenger implements _IMessenger {
|
||||
}
|
||||
}
|
||||
|
||||
/** @var array */
|
||||
protected $actions;
|
||||
|
||||
/** @var array */
|
||||
protected $action;
|
||||
|
||||
function _getActionMark(): int {
|
||||
return count($this->actions);
|
||||
}
|
||||
|
||||
function action($content, ?callable $func=null, ?int $level=null): void {
|
||||
$this->checkLevel($level);
|
||||
$until = $this->_getActionMark();
|
||||
$this->actions[] = [
|
||||
"line_prefix" => $this->getLinePrefix(),
|
||||
"level" => $level,
|
||||
"content" => $content,
|
||||
"print_content" => true,
|
||||
"result_success" => null,
|
||||
"result_content" => null,
|
||||
];
|
||||
$this->action =& $this->actions[$until];
|
||||
if ($func !== null) {
|
||||
try {
|
||||
$result = $func($this);
|
||||
if ($this->_getActionMark() > $until) {
|
||||
$this->aresult($result);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->afailure($e);
|
||||
throw $e;
|
||||
} finally {
|
||||
$this->_endAction($until);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function printActions(bool $endAction=false, ?int $overrideLevel=null): void {
|
||||
protected function flushActions(bool $endAction=false, ?int $overrideLevel=null): void {
|
||||
$this->printTitles();
|
||||
$err = $this->err;
|
||||
$indentLevel = $this->getIndentLevel(false);
|
||||
@ -317,6 +278,37 @@ class StdMessenger implements _IMessenger {
|
||||
if ($endAction) $this->_endAction();
|
||||
}
|
||||
|
||||
function _getActionMark(): int {
|
||||
return count($this->actions);
|
||||
}
|
||||
|
||||
function action($content, ?callable $func=null, ?int $level=null): void {
|
||||
$this->checkLevel($level);
|
||||
$until = $this->_getActionMark();
|
||||
$this->actions[] = [
|
||||
"line_prefix" => $this->getLinePrefix(),
|
||||
"level" => $level,
|
||||
"content" => $content,
|
||||
"print_content" => true,
|
||||
"result_success" => null,
|
||||
"result_content" => null,
|
||||
];
|
||||
$this->action =& $this->actions[$until];
|
||||
if ($func !== null) {
|
||||
try {
|
||||
$result = $func($this);
|
||||
if ($this->_getActionMark() > $until) {
|
||||
$this->aresult($result);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->afailure($e);
|
||||
throw $e;
|
||||
} finally {
|
||||
$this->_endAction($until);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function step($content, ?int $level=null): void {
|
||||
$this->_printGenericOrException($level, "step", $content, $this->getIndentLevel(), $this->err);
|
||||
}
|
||||
@ -325,21 +317,21 @@ class StdMessenger implements _IMessenger {
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->action["result_success"] = true;
|
||||
$this->action["result_content"] = $content;
|
||||
$this->printActions(true, $overrideLevel);
|
||||
$this->flushActions(true, $overrideLevel);
|
||||
}
|
||||
|
||||
function afailure($content=null, ?int $overrideLevel=null): void {
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->action["result_success"] = false;
|
||||
$this->action["result_content"] = $content;
|
||||
$this->printActions(true, $overrideLevel);
|
||||
$this->flushActions(true, $overrideLevel);
|
||||
}
|
||||
|
||||
function adone($content=null, ?int $overrideLevel=null): void {
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->action["result_success"] = null;
|
||||
$this->action["result_content"] = $content;
|
||||
$this->printActions(true, $overrideLevel);
|
||||
$this->flushActions(true, $overrideLevel);
|
||||
}
|
||||
|
||||
function aresult($result=null, ?int $overrideLevel=null): void {
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
namespace nulib\output\std;
|
||||
|
||||
class JsonLogMessenger implements _IMessenger {
|
||||
}
|
5
php/src/output/std/JsonMessenger.php
Normal file
5
php/src/output/std/JsonMessenger.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
namespace nulib\output\std;
|
||||
|
||||
class JsonMessenger extends AbstractMessenger {
|
||||
}
|
@ -5,12 +5,10 @@ use Exception;
|
||||
use nulib\cl;
|
||||
use nulib\output\IMessenger;
|
||||
|
||||
class StdLogMessenger implements _IMessenger {
|
||||
use _TMessenger;
|
||||
|
||||
class LogMessenger extends AbstractMessenger {
|
||||
function __construct(?array $params=null) {
|
||||
$output = $params["output"] ?? null;
|
||||
$color = $params["color"] ?? null;
|
||||
$color = $params["color"] ?? false;
|
||||
$indent = $params["indent"] ?? static::INDENT;
|
||||
|
||||
$defaultLevel = $params["default_level"] ?? null;
|
||||
@ -22,7 +20,7 @@ class StdLogMessenger implements _IMessenger {
|
||||
$minLevel ??= $params["verbosity"] ?? null; # alias
|
||||
$minLevel = self::verifix_level($minLevel ?? self::NORMAL, self::NONE);
|
||||
|
||||
$addDate = boolval($params["add_date"] ?? null);
|
||||
$addDate = boolval($params["add_date"] ?? true);
|
||||
$dateFormat = cl::get($params, "date_format", static::DATE_FORMAT);
|
||||
$id = $params["id"] ?? null;
|
||||
|
||||
@ -73,25 +71,6 @@ class StdLogMessenger implements _IMessenger {
|
||||
return $clone;
|
||||
}
|
||||
|
||||
|
||||
/** @var StdOutput la sortie standard */
|
||||
protected StdOutput $out;
|
||||
|
||||
/** @var int level par défaut dans lequel les messages sont affichés */
|
||||
protected int $defaultLevel;
|
||||
|
||||
/** @var int level minimum que doivent avoir les messages pour être affichés */
|
||||
protected int $minLevel;
|
||||
|
||||
/** @var bool faut-il ajouter la date à chaque ligne? */
|
||||
protected bool $addDate;
|
||||
|
||||
/** @var string format de la date */
|
||||
protected string $dateFormat;
|
||||
|
||||
/** @var ?string identifiant de ce messenger, à ajouter à chaque ligne */
|
||||
protected ?string $id;
|
||||
|
||||
function section($content, ?callable $func=null, ?int $level=null): void {
|
||||
$this->_endSection();
|
||||
if (!$this->checkLevel($level)) return;
|
||||
@ -113,7 +92,20 @@ class StdLogMessenger implements _IMessenger {
|
||||
}
|
||||
|
||||
protected int $titleLevel = 0;
|
||||
|
||||
|
||||
protected int $actionLevel = 0;
|
||||
|
||||
protected array $actions = [];
|
||||
|
||||
protected ?array $action;
|
||||
|
||||
protected function getIndentLevel(bool $withActions=true): int {
|
||||
$indentLevel = $this->titleLevel - 1;
|
||||
if ($indentLevel < 0) $indentLevel = 0;
|
||||
if ($withActions) $indentLevel += $this->actionLevel;
|
||||
return $indentLevel;
|
||||
}
|
||||
|
||||
function _getTitleMark(): int {
|
||||
return $this->titleLevel;
|
||||
}
|
||||
@ -135,6 +127,7 @@ class StdLogMessenger implements _IMessenger {
|
||||
}
|
||||
|
||||
function desc($content, ?int $level=null): void {
|
||||
if (!$this->checkLevel($level)) return;
|
||||
$this->_printGeneric(
|
||||
$this->getLinePrefix(), $level,
|
||||
"desc", $content,
|
||||
@ -147,10 +140,6 @@ class StdLogMessenger implements _IMessenger {
|
||||
$this->titleLevel = $until;
|
||||
}
|
||||
|
||||
protected int $actionLevel = 0;
|
||||
|
||||
protected array $actionLevels = [];
|
||||
|
||||
function _getActionMark(): int {
|
||||
return $this->actionLevel;
|
||||
}
|
||||
@ -158,6 +147,8 @@ class StdLogMessenger implements _IMessenger {
|
||||
function action($content, ?callable $func=null, ?int $level=null): void {
|
||||
$this->checkLevel($level);
|
||||
$until = $this->_getActionMark();
|
||||
$this->actions[] = ["level" => $level];
|
||||
$this->action =& $this->actions[array_key_last($this->actions)];
|
||||
$this->_printAction(
|
||||
$this->getLinePrefix(), $level,
|
||||
true, $content,
|
||||
@ -178,12 +169,16 @@ class StdLogMessenger implements _IMessenger {
|
||||
}
|
||||
}
|
||||
|
||||
protected function flushActions(bool $endAction=false, ?int $overrideLevel=null): void {
|
||||
}
|
||||
|
||||
function step($content, ?int $level=null): void {
|
||||
$this->_printGenericOrException($level, "step", $content, $this->getIndentLevel(), $this->out);
|
||||
}
|
||||
|
||||
function asuccess($content=null, ?int $overrideLevel=null): void {
|
||||
if ($this->actionLevel == 0) $this->action(null);
|
||||
$level = $overrideLevel ?? $this->action["level"];
|
||||
$this->_printAction(
|
||||
$this->getLinePrefix(), $level,
|
||||
false, null,
|
||||
@ -194,6 +189,7 @@ class StdLogMessenger implements _IMessenger {
|
||||
|
||||
function afailure($content=null, ?int $overrideLevel=null): void {
|
||||
if ($this->actionLevel == 0) $this->action(null);
|
||||
$level = $overrideLevel ?? $this->action["level"];
|
||||
$this->_printAction(
|
||||
$this->getLinePrefix(), $level,
|
||||
false, null,
|
||||
@ -204,6 +200,7 @@ class StdLogMessenger implements _IMessenger {
|
||||
|
||||
function adone($content=null, ?int $overrideLevel=null): void {
|
||||
if ($this->actionLevel == 0) $this->action(null);
|
||||
$level = $overrideLevel ?? $this->action["level"];
|
||||
$this->_printAction(
|
||||
$this->getLinePrefix(), $level,
|
||||
false, null,
|
||||
@ -222,7 +219,16 @@ class StdLogMessenger implements _IMessenger {
|
||||
|
||||
function _endAction(?int $until=null): void {
|
||||
$until ??= $this->_getActionMark();
|
||||
$this->actionLevel = $until;
|
||||
while ($this->actionLevel > $until) {
|
||||
$this->actionLevel--;
|
||||
array_pop($this->actions);
|
||||
}
|
||||
if ($this->actions) {
|
||||
$this->action =& $this->actions[array_key_last($this->actions)];
|
||||
} else {
|
||||
$this->actions = [];
|
||||
unset($this->action);
|
||||
}
|
||||
}
|
||||
|
||||
function print($content, ?int $level=null): void {
|
||||
@ -230,19 +236,19 @@ class StdLogMessenger implements _IMessenger {
|
||||
}
|
||||
|
||||
function info($content, ?int $level=null): void {
|
||||
$this->_printGenericOrException($level, "info", $content, $this->getIndentLevel(), $this->err);
|
||||
$this->_printGenericOrException($level, "info", $content, $this->getIndentLevel(), $this->out);
|
||||
}
|
||||
|
||||
function note($content, ?int $level=null): void {
|
||||
$this->_printGenericOrException($level, "note", $content, $this->getIndentLevel(), $this->err);
|
||||
$this->_printGenericOrException($level, "note", $content, $this->getIndentLevel(), $this->out);
|
||||
}
|
||||
|
||||
function warning($content, ?int $level=null): void {
|
||||
$this->_printGenericOrException($level, "warning", $content, $this->getIndentLevel(), $this->err);
|
||||
$this->_printGenericOrException($level, "warning", $content, $this->getIndentLevel(), $this->out);
|
||||
}
|
||||
|
||||
function error($content, ?int $level=null): void {
|
||||
$this->_printGenericOrException($level, "error", $content, $this->getIndentLevel(), $this->err);
|
||||
$this->_printGenericOrException($level, "error", $content, $this->getIndentLevel(), $this->out);
|
||||
}
|
||||
|
||||
function end(bool $all=false): void {
|
@ -124,7 +124,7 @@ class StdOutput {
|
||||
protected $outf;
|
||||
|
||||
/** @var bool faut-il masquer les erreurs d'écriture? */
|
||||
protected bool $maskErrors;
|
||||
protected ?bool $maskErrors;
|
||||
|
||||
/** @var bool faut-il autoriser la sortie en couleur? */
|
||||
protected bool $color = false;
|
||||
|
@ -7,9 +7,9 @@ use nulib\db\CapacitorChannel;
|
||||
use nulib\db\mysql\Mysql;
|
||||
use nulib\db\mysql\MysqlStorage;
|
||||
use nulib\output\msg;
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
|
||||
msg::set_messenger_class(StdMessenger::class);
|
||||
msg::set_messenger_class(ConsoleMessenger::class);
|
||||
|
||||
$db = new Mysql([
|
||||
"type" => "mysql",
|
||||
|
@ -3,10 +3,10 @@
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nulib\UserException;
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
use nulib\output\msg;
|
||||
|
||||
msg::set_messenger(new StdMessenger(), new StdMessenger([
|
||||
msg::set_messenger(new ConsoleMessenger(), new ConsoleMessenger([
|
||||
"output" => "output-forever.log",
|
||||
]));
|
||||
|
||||
|
@ -2,13 +2,17 @@
|
||||
<?php
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
use nulib\output\std\LogMessenger;
|
||||
use nulib\UserException;
|
||||
|
||||
$class = ConsoleMessenger::class;
|
||||
$params = [];
|
||||
$count = count($argv) - 1;
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
switch ($argv[$i]) {
|
||||
case "--console": $class = ConsoleMessenger::class; break;
|
||||
case "--log": $class = LogMessenger::class; break;
|
||||
case "-L": $i++; $params["output"] = $argv[$i]; break;
|
||||
case "-i": $i++; $params["id"] = $argv[$i]; break;
|
||||
case "-t": $params["add_date"] = true; break;
|
||||
@ -34,7 +38,7 @@ for ($i = 1; $i <= $count; $i++) {
|
||||
case "--sx": $params["min_level"] = "none"; break;
|
||||
}
|
||||
}
|
||||
$msg = new StdMessenger($params);
|
||||
$msg = new $class($params);
|
||||
|
||||
$msg->title("title0");
|
||||
$msg->title("title1");
|
||||
@ -43,6 +47,8 @@ $msg->end();
|
||||
$msg->print("print under title0");
|
||||
$msg->end();
|
||||
|
||||
exit;
|
||||
|
||||
$msg->desc("action avec step");
|
||||
$msg->action("action avec step");
|
||||
$msg->step("step");
|
||||
@ -264,7 +270,7 @@ $msg->section("multi-line\nsection", function ($msg) {
|
||||
$msg->section("Exceptions", function ($msg) {
|
||||
$e = new Exception("message");
|
||||
$u1 = new UserException("userMessage");
|
||||
$u2 = new UserException("userMessage", "techMessage");
|
||||
$u2 = (new UserException("userMessage"))->setTechMessage("techMessage");
|
||||
$msg->title("avec message", function ($msg) use ($e, $u1, $u2) {
|
||||
$msg->info(["exception", $e]);
|
||||
$msg->info(["userException1", $u1]);
|
4
php/tests/cache/_TestCase.php
vendored
4
php/tests/cache/_TestCase.php
vendored
@ -3,7 +3,7 @@ namespace nulib\cache;
|
||||
|
||||
use nulib\db\sqlite\SqliteStorage;
|
||||
use nulib\output\msg;
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
use nulib\tests\TestCase;
|
||||
|
||||
class _TestCase extends TestCase {
|
||||
@ -11,7 +11,7 @@ class _TestCase extends TestCase {
|
||||
|
||||
static function setUpBeforeClass(): void {
|
||||
parent::setUpBeforeClass();
|
||||
msg::set_messenger_class(StdMessenger::class);
|
||||
msg::set_messenger_class(ConsoleMessenger::class);
|
||||
self::$storage = new SqliteStorage(__DIR__."/cache.db");
|
||||
cache::set_storage(self::$storage);
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ use nulib\db\sqlite\impl\MyChannelV2;
|
||||
use nulib\db\sqlite\impl\MyChannelV3;
|
||||
use nulib\db\sqlite\impl\MyIndexChannel;
|
||||
use nulib\output\msg;
|
||||
use nulib\output\std\StdMessenger;
|
||||
use nulib\output\std\ConsoleMessenger;
|
||||
use nulib\php\time\DateTime;
|
||||
use nulib\tests\TestCase;
|
||||
|
||||
class ChannelMigrationTest extends TestCase {
|
||||
static function setUpBeforeClass(): void {
|
||||
parent::setUpBeforeClass();
|
||||
msg::set_messenger_class(StdMessenger::class);
|
||||
msg::set_messenger_class(ConsoleMessenger::class);
|
||||
}
|
||||
|
||||
protected function addData(MyChannel $channel, array $data): void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user