日志格式调整

This commit is contained in:
dongwei 2019-01-10 15:05:11 +08:00
parent 2fe16ea344
commit c61443cb69

View File

@ -4,6 +4,7 @@ namespace JsonRpc\Providers;
use Illuminate\Support\ServiceProvider;
use JsonRpc\Client;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
@ -19,8 +20,13 @@ class ClientServiceProvider extends ServiceProvider
$this->app->configure('rpc');
$config = config('rpc.client');
$logger = new Logger('rpc-client-logger');
$logger->pushHandler(new StreamHandler($this->app->storagePath()."/logs/rpc_monitor_".date("Ymd").".log"));
$dateFormat = "Y n j, g:i a";
$output = "%datetime% > %level_name% > %message% %context% %extra%\n";
$formatter = new LineFormatter($output, $dateFormat);
$stream = new StreamHandler($this->app->storagePath()."/logs/rpc_monitor_".date("Ymd").".log");
$stream->setFormatter($formatter);
$logger = new Logger('RPC.LOGGER');
$logger->pushHandler($stream);
$this->app->singleton('rpc', function () use ($config, $logger) {
return new Client($config, $logger);
});