承接 vasek-purchart/console-errors-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

vasek-purchart/console-errors-bundle

最新稳定版本:3.0.2

Composer 安装命令:

composer require vasek-purchart/console-errors-bundle

包简介

Logging of exceptions and error codes for Symfony Console

README 文档

README

Logging of exceptions and error codes for Symfony Console.

This bundle ensures all uncaught exceptions and errors are logged in the same way as exceptions from controllers.

It also logs all command executions which ended with non-zero exit code.

Here is an example showing an exception, error and non-zero exit code: Error reports from Console

And these are corresponding log entries:

[2015-05-19 12:41:19] app.ERROR: Exception: Hello Exception! (uncaught exception) at /home/vasek/dev/projects/console-errors-bundle/framework-standard-edition/src/AppBundle/Console/HelloCommand.php line 23 while running console command `hello:world` {"exception":"[object] (Exception(code: 0): Hello Exception! at /home/vasek/dev/projects/console-errors-bundle/framework-standard-edition/src/AppBundle/Console/HelloCommand.php:23)"} [] [2015-05-19 12:41:58] app.ERROR: Symfony\Component\Debug\Exception\ContextErrorException: Notice: Undefined variable: foo (uncaught exception) at /home/vasek/dev/projects/console-errors-bundle/framework-standard-edition/src/AppBundle/Console/HelloCommand.php line 23 while running console command `hello:world` {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Notice: Undefined variable: foo at /home/vasek/dev/projects/console-errors-bundle/framework-standard-edition/src/AppBundle/Console/HelloCommand.php:23)"} [] [2015-05-19 12:42:13] app.ERROR: Command `hello:world` exited with status code 123 [] [] 

Configuration

Configuration structure with listed default values:

# config/packages/console_errors.yaml console_errors: exceptions: # Enable logging for exceptions. enabled: true # Log level with which exceptions should be logged (accepts string or integer values). log_level: 'error' # Priority with which the listener will be registered. listener_priority: 0 exit_code: # Enable logging for non-zero exit codes. enabled: true # Log level with which exit codes should be logged (accepts string or integer values). log_level: 'error' # Priority with which the listener will be registered. listener_priority: 0

Symfony by default always converts errors to PHP exceptions. Warnings and notices are converted by default only in development environment. If you want to configure your application to always convert warnings and notices to exceptions use the debug.error_handler.throw_at parameter (see PHP manual for other available values):

# config/packages/framework.yaml parameters: debug.error_handler.throw_at: -1

You can also override services used internally, for example if you use a non standard logger, you can provide custom instance with an alias:

services: my_logger: class: 'Monolog\Logger' arguments: $name: 'my_channel' vasek_purchart.console_errors.console.logger: '@my_logger'

Installation

Install package vasek-purchart/console-errors-bundle with Composer:

composer require vasek-purchart/console-errors-bundle

Register the bundle in your application:

// config/bundles.php return [ // ... VasekPurchart\ConsoleErrorsBundle\ConsoleErrorsBundle::class => ['all' => true], ];

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04