定制 glen/console-logger-serviceprovider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

glen/console-logger-serviceprovider

Composer 安装命令:

composer require glen/console-logger-serviceprovider

包简介

Pimple ConsoleLogger ServiceProvider

README 文档

README

This service provider makes it easy to show log messages from services in the console, without having to inject an instance of OutputInterface into the services. This requires version >=2.4 of Symfony Components. More info about the change is at the Symfony Blog.

In your console application, you can now do something like this:

use Symfony\Component\Console\Application;

$app = require 'app.php';
$console = new Application('My Console Application', '1.0');
// You should only register this service provider when running commands
$app->register(new \glen\ConsoleLoggerServiceProvider());

$console->addCommands(
    array(
    //...
    )
);

$console->run($app['console.input'], $app['console.output']);

You will still use the normal OutputInterface instance for command feedback in your commands, but you will now also get output from anything your services are logging.

The minimum logging level at which this handler will be triggered depends on the verbosity setting of the console output. The default mapping is:

  • OutputInterface::VERBOSITY_NORMAL will show all WARNING and higher logs
  • OutputInterface::VERBOSITY_VERBOSE (-v) will show all NOTICE and higher logs
  • OutputInterface::VERBOSITY_VERY_VERBOSE (-vv) will show all INFO and higher logs
  • OutputInterface::VERBOSITY_DEBUG (-vvv) will show all DEBUG and higher logs, i.e. all logs

This mapping can be customized with the logger.console_logger.handler.verbosity_level_map constructor parameter:

$app->register(new ConsoleLoggerServiceProvider(), [
    'logger.console_logger.handler.verbosity_level_map' => array(
        OutputInterface::VERBOSITY_QUIET => Logger::ERROR,
        OutputInterface::VERBOSITY_NORMAL => Logger::INFO,
        OutputInterface::VERBOSITY_VERBOSE => Logger::NOTICE,
        OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO,
        OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG,
    ),
]);

统计信息

  • 总下载量: 761
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固