Skip to content

Commit

Permalink
Add log functions
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed May 24, 2024
1 parent 7d62336 commit 60e25f5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"phpstan/phpstan": "^1.10.0",
"friendsofphp/php-cs-fixer": "^3.21",
"phpat/phpat": "^0.10.14",
"spaze/phpstan-disallowed-calls": "^3.1"
"spaze/phpstan-disallowed-calls": "^3.1",
"symfony/var-dumper": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
27 changes: 27 additions & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

use ReflectionType;
use Reflector;
use Stringable;
use Symfony\Component\VarDumper\VarDumper;
use Tempest\Container\GenericContainer;
use Tempest\Events\EventBus;
use Tempest\Log\Logger;
use Tempest\Mapper\ObjectFactory;
use Tempest\Support\Reflection\Attributes;
use Tempest\Support\Reflection\TypeName;
Expand Down Expand Up @@ -64,4 +67,28 @@ function type(Reflector|ReflectionType $reflector): string
{
return (new TypeName())->resolve($reflector);
}

function lw(mixed ...$input): void
{
/** @var Logger $logger */
$logger = get(Logger::class);

foreach ($input as $key => $item) {
if ($item instanceof Stringable) {
$message = (string)$item;
} else {
$message = var_export($item, true);
}

$logger->debug("[{$key}] {$message}");
}

VarDumper::dump(...$input);
}

function ld(mixed ...$input): void
{
lw(...$input);
die();
}
}

0 comments on commit 60e25f5

Please sign in to comment.