Skip to content

Commit

Permalink
Pass an empty value to -l to disabled logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Sep 1, 2024
1 parent 14d766f commit f408a9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Web change log

## ?.?.? / ????-??-??

* Make passing an empty value for logging like such: `xp web -l "" [...]`
disable logging.
(@thekid)

## 4.4.2 / 2024-08-26

* Fixed accessing params from a request with content-type, but without
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/web/logging/Sink.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function target() { return nameof($this); }
public static function of($arg) {
if ('-' === $arg) {
return new ToConsole();
} else if (null === $arg) {
} else if (null === $arg || '' === $arg) {
return null;
} else if (is_callable($arg)) {
return new ToFunction($arg);
Expand Down
5 changes: 5 additions & 0 deletions src/test/php/web/unittest/LoggingTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public function no_logging_target() {
Assert::equals('(no logging)', (new Logging(null))->target());
}

#[Test, Values([null, ''])]
public function no_logging_target_of($target) {
Assert::equals('(no logging)', Logging::of($target)->target());
}

#[Test, Values(from: 'arguments')]
public function log($expected, $error) {
$req= new Request(new TestInput('GET', '/'));
Expand Down

0 comments on commit f408a9e

Please sign in to comment.