Php laravel 5.2用于不同任务的自定义日志文件
我们可以在laravel 5.2中为不同目的创建自定义日志文件吗 与order.log中的订单相关日志条目和payment相关的内容类似,该条目应登录payments.log 我想找到最好的拉维路Php laravel 5.2用于不同任务的自定义日志文件,php,laravel,laravel-5,logging,laravel-5.2,Php,Laravel,Laravel 5,Logging,Laravel 5.2,我们可以在laravel 5.2中为不同目的创建自定义日志文件吗 与order.log中的订单相关日志条目和payment相关的内容类似,该条目应登录payments.log 我想找到最好的拉维路 目前,我们只能更改日志文件频率(如每日、单个),也可以更改日志文件的名称,而不是默认名称,即laravel.log您可以尝试重新调整日志函数的用途,将不同类型的日志写入不同的文件。这可以通过编辑bootstrap/app.php文件来完成: $app->configureMonologUsing
目前,我们只能更改日志文件频率(如每日、单个),也可以更改日志文件的名称,而不是默认名称,即laravel.log您可以尝试重新调整日志函数的用途,将不同类型的日志写入不同的文件。这可以通过编辑
bootstrap/app.php
文件来完成:
$app->configureMonologUsing(function($monolog) {
$bubble = false;
$infoStreamHandler = new Monolog\Handler\StreamHandler( storage_path("/logs/orders.log"), Monolog\Logger::INFO, $bubble);
$monolog->pushHandler($infoStreamHandler);
$warningStreamHandler = new Monolog\Handler\StreamHandler( storage_path("/logs/logins.log"), Monolog\Logger::WARNING, $bubble);
$monolog->pushHandler($warningStreamHandler);
});
然后在代码中,您可以执行以下操作:
Log::info('Order was created', ['ORDER-123']);
Log::warning('User login', ['USER-1']);
您可以使用此方法编辑所有可用的日志函数:
- 调试
- 信息
- 通知
- 警告
- 错误
- 关键的
- 警觉的
- 紧急情况
- 给你。。。我花了很多时间在Monolog中添加自定义功能,这些功能能够以适当的方式实现。我尝试了很多不同的方法,但都有点不对劲。最后我找到了一个让这个功能正常工作的好方法
由于应用程序很大,我需要单独的日志文件,并尽可能维护现有的Laravel日志界面。我需要这样的东西:
Log::write('audit','用户登录到应用程序')代码>
Log::info('事件','用户发送了2封电子邮件')代码>
解决方案:
App\Providers\AppServiceProvider.php(添加到注册函数)
config\app.php(添加到别名)
App\Contracts\Facades\ChannelLog.php
<?php
namespace App\Contracts\Facades;
use Illuminate\Support\Facades\Facade;
/**
* @see \Illuminate\Log\Writer
*/
class ChannelLog extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'chanellog';
}
}
<?php
namespace App\Helpers;
use Monolog\Logger;
use App\Helpers\ChannelStreamHandler;
class ChannelWriter
{
/**
* The Log channels.
*
* @var array
*/
protected $channels = [
'event' => [
'path' => 'logs/audit.log',
'level' => Logger::INFO
],
'audit' => [
'path' => 'logs/audit.log',
'level' => Logger::INFO
]
];
/**
* The Log levels.
*
* @var array
*/
protected $levels = [
'debug' => Logger::DEBUG,
'info' => Logger::INFO,
'notice' => Logger::NOTICE,
'warning' => Logger::WARNING,
'error' => Logger::ERROR,
'critical' => Logger::CRITICAL,
'alert' => Logger::ALERT,
'emergency' => Logger::EMERGENCY,
];
public function __construct() {}
/**
* Write to log based on the given channel and log level set
*
* @param type $channel
* @param type $message
* @param array $context
* @throws InvalidArgumentException
*/
public function writeLog($channel, $level, $message, array $context = [])
{
//check channel exist
if( !in_array($channel, array_keys($this->channels)) ){
throw new InvalidArgumentException('Invalid channel used.');
}
//lazy load logger
if( !isset($this->channels[$channel]['_instance']) ){
//create instance
$this->channels[$channel]['_instance'] = new Logger($channel);
//add custom handler
$this->channels[$channel]['_instance']->pushHandler(
new ChannelStreamHandler(
$channel,
storage_path() .'/'. $this->channels[$channel]['path'],
$this->channels[$channel]['level']
)
);
}
//write out record
$this->channels[$channel]['_instance']->{$level}($message, $context);
}
public function write($channel, $message, array $context = []){
//get method name for the associated level
$level = array_flip( $this->levels )[$this->channels[$channel]['level']];
//write to log
$this->writeLog($channel, $level, $message, $context);
}
//alert('event','Message');
function __call($func, $params){
if(in_array($func, array_keys($this->levels))){
return $this->writeLog($params[0], $func, $params[1]);
}
}
}
<?php
namespace App\Helpers;
use Monolog\Handler\StreamHandler;
/**
* Use channels to log into separate files
*
* @author Peter Feher
*/
class ChannelStreamHandler extends StreamHandler
{
/**
* Channel name
*
* @var String
*/
protected $channel;
/**
* @param String $channel Channel name to write
* @see parent __construct for params
*/
public function __construct($channel, $stream, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false)
{
$this->channel = $channel;
parent::__construct($stream, $level, $bubble);
}
/**
* When to handle the log record.
*
* @param array $record
* @return type
*/
public function isHandling(array $record)
{
//Handle if Level high enough to be handled (default mechanism)
//AND CHANNELS MATCHING!
if( isset($record['channel']) ){
return (
$record['level'] >= $this->level &&
$record['channel'] == $this->channel
);
} else {
return (
$record['level'] >= $this->level
);
}
}
}
对我来说,在Laravel5.3中,我不确定它是否是我以前安装的,但我发现bootstrap/app.php不适合我
我需要把它放在app/Providers/AppServiceProvider.php中
n、 这是我之前在config中设置日志级别的地方,因此我最终使用了3个日志处理程序
public function register()
{
$monolog = Log::getMonolog();
foreach ($monolog->getHandlers() as $handler) {
$handler->setLevel(Config::get('app.log_level'));
}
$bubble = false;
$infoStreamHandler = new \Monolog\Handler\StreamHandler( storage_path("logs/info.log"), \Monolog\Logger::INFO, $bubble);
$monolog->pushHandler($infoStreamHandler);
$warningStreamHandler = new \Monolog\Handler\StreamHandler( storage_path("logs/warning.log"), \Monolog\Logger::WARNING, $bubble);
$monolog->pushHandler($warningStreamHandler);
}
要扩展ShQ的答案:
我注意到的一个问题是日志将附加[]]
,这是LineFormatter.format()中$context
和$extra
的空数组值代码>
例如,vendor/monolog/monolog/src/monolog/Formatter/LineFormatter.php
有两种方法可以解决此问题,一种是为LineFormatter
的构造函数提供不包含额外或上下文的格式,另一种是提供第四个参数$ignoreEmptyContextAndExtra
=true
ShQ答案中的所有文件保持不变,但必须更改ChannelStreamHandler
ChannelStreamHandler:
<?php
namespace App\Helpers;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
/**
* Use channels to log into separate files
*
*/
class ChannelStreamHandler extends StreamHandler
{
/**
* Channel name
*
* @var String
*/
protected $channel;
/**
* @param String $channel Channel name to write
* @param bool|int $stream
* @param bool|int $level
* @param bool $bubble
* @param null $filePermission
* @param bool $useLocking
* @see parent __construct for params
*/
public function __construct(
$channel,
$stream,
$level = Logger::DEBUG,
$bubble = true,
$filePermission = null,
$useLocking = false
) {
$this->channel = $channel;
$formatter = new LineFormatter(null, null, false, true);
$this->setFormatter($formatter);
parent::__construct($stream, $level, $bubble);
}
/**
* When to handle the log record.
*
* @param array $record
* @return bool
*/
public function isHandling(array $record)
{
//Handle if Level high enough to be handled (default mechanism)
//AND CHANNELS MATCHING!
if (isset($record['channel'])) {
return ($record['level'] >= $this->level && $record['channel'] == $this->channel);
} else {
return ($record['level'] >= $this->level);
}
}
}
您还必须确保运行monolog 1.22,因为它包含了一个关于ignoreEmptyContextAndExtra
的错误修复
我还向channelwriter
类添加了对info()的覆盖:
public function info($channel, $message, array $context = [])
{
$level = array_flip($this->levels)[$this->channels[$channel]['level']];
$this->writeLog($channel, $level, $message, $context);
}
此外,我对ShQ解决方案中的“惰性负载记录器”不满意,因为它被修改为使用服务提供商/IoC
替换ChannelWriter.writeLog()
:
在您的AppServiceProvider
中:
$this->app->bind('eventlog', function () {
return new Logger('event');
});
$this->app->bind('auditlog', function () {
return new Logger('audit');
});
我将尝试将其打包成一个包。有一个简单的方法:
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$log = ['orderId' => 10,
'description' => 'Some description'];
//first parameter passed to Monolog\Logger sets the logging channel name
$orderLog = new Logger('order');
$orderLog->pushHandler(new StreamHandler(storage_path('logs/order.log')), Logger::INFO);
$orderLog->info('OrderLog', $log);
日志/order.log中的输出:
[2017-04-30 00:00:00] order.INFO: OrderLog {"orderId":10, "description":"Some description"} []
基于ShQ答案,这是一个更短、更简单的记录器帮助程序,允许您动态地登录到自定义文件。您还可以添加自定义处理程序并设置文件路径
App\Helper
<?php
/**
* Logger helper to log into different files
*
* @package App\Helpers
* @author Romain Laneuville <romain.laneuville@hotmail.fr>
*/
namespace App\Helpers;
use Monolog\Logger;
use Monolog\Handler\HandlerInterface;
use Monolog\Handler\StreamHandler;
/**
* Class LogToChannels
*
* @package App\Helpers
*/
class LogToChannels
{
/**
* The LogToChannels channels.
*
* @var Logger[]
*/
protected $channels = [];
/**
* LogToChannels constructor.
*/
public function __construct()
{
}
/**
* @param string $channel The channel to log the record in
* @param int $level The error level
* @param string $message The error message
* @param array $context Optional context arguments
*
* @return bool Whether the record has been processed
*/
public function log(string $channel, int $level, string $message, array $context = []): bool
{
// Add the logger if it doesn't exist
if (!isset($this->channels[$channel])) {
$handler = new StreamHandler(
storage_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . $channel . '.log'
);
$this->addChannel($channel, $handler);
}
// LogToChannels the record
return $this->channels[$channel]->{Logger::getLevelName($level)}($message, $context);
}
/**
* Add a channel to log in
*
* @param string $channelName The channel name
* @param HandlerInterface $handler The channel handler
* @param string|null $path The path of the channel file, DEFAULT storage_path()/logs
*
* @throws \Exception When the channel already exists
*/
public function addChannel(string $channelName, HandlerInterface $handler, string $path = null)
{
if (isset($this->channels[$channelName])) {
throw new \Exception('This channel already exists');
}
$this->channels[$channelName] = new Logger($channelName);
$this->channels[$channelName]->pushHandler(
new $handler(
$path === null ?
storage_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . $channelName . '.log' :
$path . DIRECTORY_SEPARATOR . $channelName . '.log'
)
);
}
/**
* Adds a log record at the DEBUG level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function debug(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::DEBUG, $message, $context);
}
/**
* Adds a log record at the INFO level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function info(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::INFO, $message, $context);
}
/**
* Adds a log record at the NOTICE level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function notice(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::NOTICE, $message, $context);
}
/**
* Adds a log record at the WARNING level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function warn(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::WARNING, $message, $context);
}
/**
* Adds a log record at the WARNING level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function warning(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::WARNING, $message, $context);
}
/**
* Adds a log record at the ERROR level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function err(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::ERROR, $message, $context);
}
/**
* Adds a log record at the ERROR level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function error(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::ERROR, $message, $context);
}
/**
* Adds a log record at the CRITICAL level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function crit(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::CRITICAL, $message, $context);
}
/**
* Adds a log record at the CRITICAL level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return Boolean Whether the record has been processed
*/
public function critical(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::CRITICAL, $message, $context);
}
/**
* Adds a log record at the ALERT level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function alert(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::ALERT, $message, $context);
}
/**
* Adds a log record at the EMERGENCY level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function emerg(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::EMERGENCY, $message, $context);
}
/**
* Adds a log record at the EMERGENCY level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function emergency(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::EMERGENCY, $message, $context);
}
}
config\app.php(添加到别名)
然后你可以在应用程序中的任何地方调用
Log::info('logger_name', 'Log message');
Log::error('other_logger_name', 'Log message', $someContext);
您甚至可以通过调用
Log::addChannel('channel_name', $customHandler);
当您在应用程序中的任何位置调用它的名称时,它都可以访问。将日志输出到不同文件的最快方式
Log::useFiles('path/to/file.log');
Log::info('Info');
现在以更简单的方式支持这一点
创建一个频道
转到:root/config/logging.php
,在channels
数组下添加自定义频道,即
“付款”=>[
“驱动程序”=>“单个”,
'path'=>存储路径('logs/payments.log'),
“级别”=>“信息”,
],
在路由或控制器中写入此日志
Log::channel('payments')->info('A transaction haved!');
付款日志可在/storage/logs/payments.log
注意:可扩展以进一步增强您的需求
Laravel 5.6版我管理了自己的日志函数,它可以放在app dir的helper.php文件中
if ( ! function_exists( 'write_log' ) ) {
/**
* Write log to log file
*
* @param string|array|object $log
*/
function write_log( $log ) {
if ( env('APP_LOG_LEVEL', 'debug') == 'debug' ) {
if ( is_array( $log ) || is_object( $log ) ) {
file_put_contents(laravelInstallDir().'../debug.log', print_r( $log, true ), FILE_APPEND);
} else {
file_put_contents(laravelInstallDir().'../debug.log', $log, FILE_APPEND);
}
}
}
}
请根据需要调整路径laravelInstallDir()。../debug.log这是在Laracast上发布的一条注释,用于相同的问题:是否可以在记录消息之前使用log::useFiles()
并指定文件名?如果是这样的话,Laravel来谈谈吧。按错误级别对单独的日志进行处理非常好,谢谢。我们可以使用env()在外部设置日志路径而不是使用此存储路径(“/logs/orders.log”),是的,您可以将存储路径(“/logs/orders.log”)
行更改为env(“/logs/orders.log”)
,因此,如果没有定义env,日志可以返回到存储路径。我已经对这个答案进行了更新,但如果它链接到文档,则会更有帮助:另外,通过将这些行添加到u构造方法:$this->channels['event']['path']='logs/audit-'中,可以拥有每日日志文件。日期(“Y-m-d”)。对数'$此->通道['audit']['path']='logs/audit-'。日期(“Y-m-d”)。对数';这段代码在日志消息中创建了额外的[],有什么想法吗?@codebob请参阅下面我关于[]]
问题的答案。这是因为它使用默认的LineFormatter.php
实例和默认的格式化程序。我有同样的[][]问题,我如何删除它们?请注意。它不会删除log_max_文件中指定的旧文件。这是一种添加额外日志记录的非常简洁和简单的方法,只是一个问题,这会继续向单个日志文件或wi添加条目吗
<?php
/**
* Logger helper to log into different files
*
* @package App\Helpers
* @author Romain Laneuville <romain.laneuville@hotmail.fr>
*/
namespace App\Helpers;
use Monolog\Logger;
use Monolog\Handler\HandlerInterface;
use Monolog\Handler\StreamHandler;
/**
* Class LogToChannels
*
* @package App\Helpers
*/
class LogToChannels
{
/**
* The LogToChannels channels.
*
* @var Logger[]
*/
protected $channels = [];
/**
* LogToChannels constructor.
*/
public function __construct()
{
}
/**
* @param string $channel The channel to log the record in
* @param int $level The error level
* @param string $message The error message
* @param array $context Optional context arguments
*
* @return bool Whether the record has been processed
*/
public function log(string $channel, int $level, string $message, array $context = []): bool
{
// Add the logger if it doesn't exist
if (!isset($this->channels[$channel])) {
$handler = new StreamHandler(
storage_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . $channel . '.log'
);
$this->addChannel($channel, $handler);
}
// LogToChannels the record
return $this->channels[$channel]->{Logger::getLevelName($level)}($message, $context);
}
/**
* Add a channel to log in
*
* @param string $channelName The channel name
* @param HandlerInterface $handler The channel handler
* @param string|null $path The path of the channel file, DEFAULT storage_path()/logs
*
* @throws \Exception When the channel already exists
*/
public function addChannel(string $channelName, HandlerInterface $handler, string $path = null)
{
if (isset($this->channels[$channelName])) {
throw new \Exception('This channel already exists');
}
$this->channels[$channelName] = new Logger($channelName);
$this->channels[$channelName]->pushHandler(
new $handler(
$path === null ?
storage_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . $channelName . '.log' :
$path . DIRECTORY_SEPARATOR . $channelName . '.log'
)
);
}
/**
* Adds a log record at the DEBUG level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function debug(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::DEBUG, $message, $context);
}
/**
* Adds a log record at the INFO level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function info(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::INFO, $message, $context);
}
/**
* Adds a log record at the NOTICE level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function notice(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::NOTICE, $message, $context);
}
/**
* Adds a log record at the WARNING level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function warn(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::WARNING, $message, $context);
}
/**
* Adds a log record at the WARNING level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function warning(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::WARNING, $message, $context);
}
/**
* Adds a log record at the ERROR level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function err(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::ERROR, $message, $context);
}
/**
* Adds a log record at the ERROR level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function error(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::ERROR, $message, $context);
}
/**
* Adds a log record at the CRITICAL level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function crit(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::CRITICAL, $message, $context);
}
/**
* Adds a log record at the CRITICAL level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return Boolean Whether the record has been processed
*/
public function critical(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::CRITICAL, $message, $context);
}
/**
* Adds a log record at the ALERT level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function alert(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::ALERT, $message, $context);
}
/**
* Adds a log record at the EMERGENCY level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function emerg(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::EMERGENCY, $message, $context);
}
/**
* Adds a log record at the EMERGENCY level.
*
* @param string $channel The channel name
* @param string $message The log message
* @param array $context The log context
*
* @return bool Whether the record has been processed
*/
public function emergency(string $channel, string $message, array $context = []): bool
{
return $this->log($channel, Logger::EMERGENCY, $message, $context);
}
}
//Facade to Object binding
$this->app->bind('LogToChannels', 'App\Helpers\LogToChannels');
// Custom Alias Class
'Log' => App\Contracts\Facades\LogToChannels::class
Log::info('logger_name', 'Log message');
Log::error('other_logger_name', 'Log message', $someContext);
Log::addChannel('channel_name', $customHandler);
Log::useFiles('path/to/file.log');
Log::info('Info');
Solution:
step1: create a channel inside config/logging.php file
example :
'channels' => [
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'web' => [
'driver' => 'single',
'path' => storage_path('logs/web/web.log'),
],
]
Step2: Now set dynamic path from the controller like this
config(['logging.channels.web.path' => storage_path('logs/web/'.time().'.log')]);
Step3 : now generate your log
Log::channel('web')->info("your message goes here");
Enjoy :)
if ( ! function_exists( 'write_log' ) ) {
/**
* Write log to log file
*
* @param string|array|object $log
*/
function write_log( $log ) {
if ( env('APP_LOG_LEVEL', 'debug') == 'debug' ) {
if ( is_array( $log ) || is_object( $log ) ) {
file_put_contents(laravelInstallDir().'../debug.log', print_r( $log, true ), FILE_APPEND);
} else {
file_put_contents(laravelInstallDir().'../debug.log', $log, FILE_APPEND);
}
}
}
}