common components

v2.1.14 2020-06-18 12:14 UTC


Linter Status Tester Status Latest Stable Version Total Downloads Latest Unstable Version License

handle with array/config/log/guzzle etc.

About log


Method 1

A application logger can extends Yansongda\Supports\Log and modify createLogger method, the method must return instance of Monolog\Logger.

use Yansongda\Supports\Log;
use Monolog\Logger;

class APPLICATIONLOG extends Log
     * Make a default log instance.
     * @author yansongda <me@yansongda.cn>
     * @return Logger
    public static function createLogger()
        $handler = new StreamHandler('./log.log');
        $handler->setFormatter(new LineFormatter("%datetime% > %level_name% > %message% %context% %extra%\n\n"));

        $logger = new Logger('yansongda.private_number');

        return $logger;

Method 2

Or, just init the log service with:

use Yansongda\Supports\Log;

protected function registerLog()
    $logger = Log::createLogger($file, $identify, $level);



After registerLog, you can use Log service:

use Yansongda\Supports\Log;

Log::debug('test', ['test log']);