Created
March 31, 2018 22:29
-
-
Save finagin/1b203c80163c5375ef9aa8e12f1d75af to your computer and use it in GitHub Desktop.
Laravel logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Support; | |
use \Illuminate\Support\Facades\Log as Logger; | |
/** | |
* Class Log | |
* | |
* @method static emergency($message, array $context = []) | |
* @method static alert($message, array $context = []) | |
* @method static critical($message, array $context = []) | |
* @method static error($message, array $context = []) | |
* @method static warning($message, array $context = []) | |
* @method static notice($message, array $context = []) | |
* @method static info($message, array $context = []) | |
* @method static debug($message, array $context = []) | |
* @method static log($level, $message, array $context = []) | |
* | |
* @package App\Support | |
*/ | |
class Log | |
{ | |
public static function __callStatic($name, $arguments) | |
{ | |
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
array_shift($backtrace); | |
foreach ($backtrace as $item) { | |
$item['args'] = []; | |
unset($item['args']); | |
} | |
$arguments[1] = array_merge($arguments[1] ?? [], compact('backtrace')); | |
call_user_func([Logger::class, $name], ...$arguments); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment