imponeer/log-data-output-decorator
Composer 安装命令:
composer require imponeer/log-data-output-decorator
包简介
Small decorator that extends Symfony OutputInterface delivered class with few options for easier to log data
README 文档
README
Log Data Output Decorator
A decorator that extends Symfony OutputInterface with:
- Multiple message types: info, success, error, fatal, and plain messages
- Automatic indentation with indent control methods
- Parameter substitution using sprintf formatting
- Full Symfony OutputInterface compatibility
Installation
Install via Composer:
composer require imponeer/log-data-output-decorator
Usage
Basic Usage
use Imponeer\Decorators\LogDataOutput\OutputDecorator; use Symfony\Component\Console\Output\ConsoleOutput; $output = new OutputDecorator(new ConsoleOutput()); // Different message types $output->info('This is an info message'); $output->success('Operation completed successfully'); $output->error('An error occurred'); $output->fatal('Critical error - application stopping'); $output->msg('Plain message without formatting');
Indentation Support
$output->info('Main process started'); $output->incrIndent(); $output->info('Sub-process 1'); $output->info('Sub-process 2'); $output->incrIndent(); $output->info('Nested sub-process'); $output->decrIndent(); $output->info('Back to sub-process level'); $output->resetIndent(); $output->info('Back to main level');
Output:
Main process started
Sub-process 1
Sub-process 2
Nested sub-process
Back to sub-process level
Back to main level
Parameter Substitution
$output->info('Processing file: %s', 'example.txt'); $output->success('Processed %d files in %s seconds', 42, '1.23'); $output->error('Failed to process %s: %s', 'file.txt', 'Permission denied');
Advanced Example
use Imponeer\Decorators\LogDataOutput\OutputDecorator; use Symfony\Component\Console\Output\BufferedOutput; $bufferedOutput = new BufferedOutput(); $output = new OutputDecorator($bufferedOutput); $output->info('Starting batch process'); $output->incrIndent(); foreach (['file1.txt', 'file2.txt', 'file3.txt'] as $index => $file) { $output->info('Processing file %d: %s', $index + 1, $file); $output->incrIndent(); if ($file === 'file2.txt') { $output->error('Failed to process %s', $file); } else { $output->success('Successfully processed %s', $file); } $output->decrIndent(); } $output->resetIndent(); $output->info('Batch process completed'); // Get the formatted output echo $bufferedOutput->fetch();
API Documentation
Complete API documentation with all methods and examples is available in the project wiki, which is automatically generated from the source code.
Testing
Run the test suite:
composer test
Check code style compliance:
composer phpcs
Fix code style issues automatically:
composer phpcbf
Run static analysis:
composer phpstan
Contributing
We welcome contributions! Here's how you can help:
- Fork the repository on GitHub
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests if applicable
- Run the test suite to ensure everything works
- Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
Development Guidelines
- Follow PSR-12 coding standards
- Add tests for new functionality
- Update documentation for API changes
- Ensure all tests pass before submitting PR
Reporting Issues
Found a bug or have a suggestion? Please open an issue with:
- Clear description of the problem or suggestion
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- PHP and Symfony Console versions
imponeer/log-data-output-decorator 适用场景与选型建议
imponeer/log-data-output-decorator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 262 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「console」 「output」 「decorator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 imponeer/log-data-output-decorator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imponeer/log-data-output-decorator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 imponeer/log-data-output-decorator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This class provides you with an easy-to-use interface to progress bars.
A Laravel package to retrieve data from Google Search Console
Additional artisan commands for Laravel
The bundle for easy using json-rpc api on your project
Article CSS-ID Frontend Output Optimization
A table generator class for the PHP CLI.
统计信息
- 总下载量: 262
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-08