niels-nijens/enhances-console-logging
Composer 安装命令:
composer require niels-nijens/enhances-console-logging
包简介
Components to enhance Symfony console & stdout logging.
README 文档
README
Components to enhance Symfony console & stdout logging.
Installation using Composer
Run the following command to add the package to the composer.json of your project:
composer require niels-nijens/enhances-console-logging
Usage
ProgressBarConsoleLogger
The ProgressBarConsoleLogger allows you to log and show progress in a console without directly injecting a
ProgressBar into your domain components handling the progression. Instead, you are able to inject logging into those
components. This allows you to not only log to the console/stdout, but also to other logging mechanisms (eg. a file).
Logging to both a progress bar and another logging mechanism can be achieved by injecting/decorating an existing PSR-3 logger, like Monolog.
The ProgressBarConsoleLogger adheres to the PSR-3 logging specification and as such implements the Psr\Log\LoggerInterface.
<?php declare(strict_types=1); use Nijens\EnhancesConsoleLogging\ProgressBar\LogContext; use Nijens\EnhancesConsoleLogging\ProgressBar\ProgressBarConsoleLogger; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\OutputInterface; /** @var $monolog LoggerInterface */ /** @var $output OutputInterface */ $progressBar = new ProgressBar($output); $logger = new ProgressBarConsoleLogger($monolog); $logger->registerProgressBar( 'test', // A unique identifier to reference the progress bar through the log context. $progressBar ); $logger->info( 'This message will be set on the progress bar.', [ LogContext::PROGRESS_IDENTIFIER_KEY => 'test', // The unique identifier. LogContext::PROGRESS_INCREMENT_KEY => 0, // Allows incrementing the max steps. (optional) LogContext::PROGRESS_ADVANCE_KEY => 0, // Allows advancing the steps. (optional) ] );
Testing and code standards
Unit tests can be executed by running the following command:
composer test
Code style can be fixed or validated by running one of the following commands:
composer cs-fixer || composer cs-validate
Security
If you discover any security related issues, please email nijens.niels+security [at] gmail.com instead of using the issue tracker.
Credits
License
This package is licensed under the MIT License. Please see the LICENSE file for more information.
niels-nijens/enhances-console-logging 适用场景与选型建议
niels-nijens/enhances-console-logging 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.16k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 niels-nijens/enhances-console-logging 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 niels-nijens/enhances-console-logging 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-23