enkidu/laravel-log

v1.0.0 2020-03-27 01:35 UTC

This package is auto-updated.

Last update: 2024-04-27 11:18:23 UTC


README

Existing Logs

Exception Log

try {
        throw new Exception('Test');
    } catch (Exception $exception) {
        \Enkidu\Log\Facades\ExceptionLogger::logException($exception); // exception.log
    }

Debug Log

\Enkidu\Log\Facades\DebugLogger::info('Test'); // debug.log

Creating custom log

  • Add logging channel in config/logging.php
   'channels' => [
   ...
   'test' => [
        'driver' => 'single',
        'path' => storage_path('logs/test.log'),
        'level' => 'info',
   ],
  ...
]
  • Create custom logging class
class TestLogger extends BaseLogger
{
    /**
     * @inheritDoc
     */
    protected function getLoggingChannel(): string
    {
        return 'test';
    }
}

How to use

$test = new \App\Logger\TestLogger;
 $test->info('Test'); // test.log