国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

日志

webman使用 monolog/monolog 處理日志。

使用

<?php
namespace app\controller;

use support\Request;
use support\Log;

class FooController
{
    public function index(Request $request)
    {
        Log::info('log test');
        return response('hello index');
    }
}

提供的方法

Log::log($level, $message, array $context = [])
Log::debug($message, array $context = [])
Log::info($message, array $context = [])
Log::notice($message, array $context = [])
Log::warning($message, array $context = [])
Log::error($message, array $context = [])
Log::critical($message, array $context = [])
Log::alert($message, array $context = [])
Log::emergency($message, array $context = [])

等價于

$log = Log::channel('default');
$log->log($level, $message, array $context = [])
$log->debug($message, array $context = [])
$log->info($message, array $context = [])
$log->notice($message, array $context = [])
$log->warning($message, array $context = [])
$log->error($message, array $context = [])
$log->critical($message, array $context = [])
$log->alert($message, array $context = [])
$log->emergency($message, array $context = [])

配置

return [
    // 默認(rèn)日志通道
    'default' => [
        // 處理默認(rèn)通道的handler,可以設(shè)置多個
        'handlers' => [
            [   
                // handler類的名字
                'class' => Monolog\Handler\RotatingFileHandler::class,
                // handler類的構(gòu)造函數(shù)參數(shù)
                'constructor' => [
                    runtime_path() . '/logs/webman.log',
                    Monolog\Logger::DEBUG,
                ],
                // 格式相關(guān)
                'formatter' => [
                    // 格式化處理類的名字
                    'class' => Monolog\Formatter\LineFormatter::class,
                    // 格式化處理類的構(gòu)造函數(shù)參數(shù)
                    'constructor' => [ null, 'Y-m-d H:i:s', true],
                ],
            ]
        ],
    ],
];

多通道

monolog支持多通道,默認(rèn)使用default通道。如果想增加一個log2通道,配置類似如下:

return [
    // 默認(rèn)日志通道
    'default' => [
        // 處理默認(rèn)通道的handler,可以設(shè)置多個
        'handlers' => [
            [   
                // handler類的名字
                'class' => Monolog\Handler\RotatingFileHandler::class,
                // handler類的構(gòu)造函數(shù)參數(shù)
                'constructor' => [
                    runtime_path() . '/logs/webman.log',
                    Monolog\Logger::DEBUG,
                ],
                // 格式相關(guān)
                'formatter' => [
                    // 格式化處理類的名字
                    'class' => Monolog\Formatter\LineFormatter::class,
                    // 格式化處理類的構(gòu)造函數(shù)參數(shù)
                    'constructor' => [ null, 'Y-m-d H:i:s', true],
                ],
            ]
        ],
    ],
    // log2通道
    'log2' => [
        // 處理默認(rèn)通道的handler,可以設(shè)置多個
        'handlers' => [
            [   
                // handler類的名字
                'class' => Monolog\Handler\RotatingFileHandler::class,
                // handler類的構(gòu)造函數(shù)參數(shù)
                'constructor' => [
                    runtime_path() . '/logs/log2.log',
                    Monolog\Logger::DEBUG,
                ],
                // 格式相關(guān)
                'formatter' => [
                    // 格式化處理類的名字
                    'class' => Monolog\Formatter\LineFormatter::class,
                    // 格式化處理類的構(gòu)造函數(shù)參數(shù)
                    'constructor' => [ null, 'Y-m-d H:i:s', true],
                ],
            ]
        ],
    ],
];

使用log2通道時用法如下:

<?php
namespace app\controller;

use support\Request;
use support\Log;

class FooController
{
    public function index(Request $request)
    {
        $log = Log::channel('log2');
        $log->info('log2 test');
        return response('hello index');
    }
}
編輯于2024-03-13 17:42:49 完善本頁 +發(fā)起討論
贊助商