diff --git a/routes/web.php b/routes/web.php
index 3927dd21..9c1b7a8b 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -17,6 +17,8 @@
use Lion\Route\Route;
use Dotenv\Dotenv;
+use Lion\Bundle\Enums\LogTypeEnum;
+use Lion\Bundle\Helpers\Commands\Schedule\TaskQueue;
use Lion\Bundle\Helpers\ExceptionCore;
use Lion\Bundle\Helpers\Http\Routes;
use Lion\Database\Driver;
@@ -113,11 +115,16 @@
Route::addMiddleware(Routes::getMiddleware());
// -----------------------------------------------------------------------------
Route::get('/', function () {
+ // TaskQueue::push('send:email:verify', json([
+ // 'email' => 'sleon@dev.com',
+ // 'template' => '
Tasks Test
'
+ // ]));
+
return info('[index]');
});
Route::get('logger', function () {
- logger('test-logger', 'info', ['user' => 'Sleon'], true);
+ logger('test-logger', LogTypeEnum::INFO, ['user' => 'Sleon'], true);
return success();
});
diff --git a/src/LionBundle/Helpers/Bundle/helpers.php b/src/LionBundle/Helpers/Bundle/helpers.php
index d39f046e..f5ae5b02 100644
--- a/src/LionBundle/Helpers/Bundle/helpers.php
+++ b/src/LionBundle/Helpers/Bundle/helpers.php
@@ -189,19 +189,34 @@ function vd(mixed $response): void
*
* @return void
*/
- function logger(string $message, LogTypeEnum $logType = LogTypeEnum::INFO, array $data = [], bool $index = true): void
- {
+ function logger(
+ string $message,
+ LogTypeEnum $logType = LogTypeEnum::INFO,
+ array $data = [],
+ bool $index = true
+ ): void {
+ $logTypeValue = $logType->value;
+
$path = storage_path('logs/monolog/', $index);
+
$fileName = "{$path}lion-" . Carbon::now()->format('Y-m-d') . '.log';
+
(new Store())->folder($path);
$logger = new Logger('log');
+
$logger->pushHandler(new StreamHandler($fileName, Level::Info));
if (!isset($_SERVER['REQUEST_URI'])) {
- $logger->$logType->value(json_encode($message), $data);
+ $logger->$logTypeValue(json_encode($message), $data);
} else {
- $logger->$logType->value(json_encode(['uri' => $_SERVER['REQUEST_URI'], 'data' => json_decode($message)]), $data);
+ $logger->$logTypeValue(
+ json_encode([
+ 'uri' => $_SERVER['REQUEST_URI'],
+ 'data' => json_decode($message)
+ ]),
+ $data
+ );
}
}
}
diff --git a/tests/Helpers/Bundle/HelpersTest.php b/tests/Helpers/Bundle/HelpersTest.php
index 4d543bca..4dbb4747 100644
--- a/tests/Helpers/Bundle/HelpersTest.php
+++ b/tests/Helpers/Bundle/HelpersTest.php
@@ -143,7 +143,7 @@ public function testLogger(): void
$fileName = "{$path}lion-" . Carbon::now()->format('Y-m-d') . '.log';
- logger(self::LOGGER_CONTENT, LogTypeEnum::INFO->value, ['user' => 'Sleon'], false);
+ logger(self::LOGGER_CONTENT, LogTypeEnum::INFO, ['user' => 'Sleon'], false);
$this->assertFileExists($fileName);
}