本文整理汇总了PHP中Illuminate\Log\Writer::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Writer::log方法的具体用法?PHP Writer::log怎么用?PHP Writer::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Log\Writer
的用法示例。
在下文中一共展示了Writer::log方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupListener
/**
* setting up listener
*
* @param Dispatcher $events
* @param Writer $log
*/
private function setupListener(Dispatcher $events, Writer $log)
{
$environments = config('slow-query-logger.environments', []);
if (!$this->app->environment($environments)) {
return;
}
$events->listen(QueryExecuted::class, function (QueryExecuted $queryExecuted) use($log) {
$sql = $queryExecuted->sql;
$bindings = $queryExecuted->bindings;
$time = $queryExecuted->time;
$logSqlQueriesSlowerThan = config('slow-query-logger.time-to-log');
if ($logSqlQueriesSlowerThan < 0 || $time < $logSqlQueriesSlowerThan) {
return;
}
$level = config('slow-query-logger.log-level', 'debug');
try {
foreach ($bindings as $val) {
$sql = preg_replace('/\\?/', "'{$val}'", $sql, 1);
}
$log->log($level, $time . ' ' . $sql);
} catch (\Exception $e) {
// be quiet on error
}
});
}
示例2: log
/**
* Log a message to the logs.
*
* @param string $level
* @param string $message
* @param array $context
* @return void
* @static
*/
public static function log($level, $message, $context = array())
{
\Illuminate\Log\Writer::log($level, $message, $context);
}