Skip to content

Commit 4f7aa6c

Browse files
authored
Merge pull request #39 from MekDrop/improve-readme
Improved README.md
2 parents 86af29b + 932dc69 commit 4f7aa6c

File tree

1 file changed

+141
-17
lines changed

1 file changed

+141
-17
lines changed

README.md

Lines changed: 141 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,159 @@
1-
[![License](https://img.shields.io/github/license/imponeer/log-data-output-decorator.svg)](LICENSE)
2-
[![GitHub release](https://img.shields.io/github/release/imponeer/log-data-output-decorator.svg)](https://github.com/imponeer/log-data-output-decorator/releases) [![Maintainability](https://api.codeclimate.com/v1/badges/3e11a2969204f2abc7cf/maintainability)](https://codeclimate.com/github/imponeer/log-data-output-decorator/maintainability) [![PHP](https://img.shields.io/packagist/php-v/imponeer/log-data-output-decorator.svg)](http://php.net)
3-
[![Packagist](https://img.shields.io/packagist/dm/imponeer/log-data-output-decorator.svg)](https://packagist.org/packages/imponeer/log-data-output-decorator)
1+
[![License](https://img.shields.io/github/license/imponeer/log-data-output-decorator.svg)](LICENSE) [![GitHub release](https://img.shields.io/github/release/imponeer/log-data-output-decorator.svg)](https://github.com/imponeer/log-data-output-decorator/releases) [![PHP](https://img.shields.io/packagist/php-v/imponeer/log-data-output-decorator.svg)](http://php.net) [![Packagist](https://img.shields.io/packagist/dm/imponeer/log-data-output-decorator.svg)](https://packagist.org/packages/imponeer/log-data-output-decorator)
42

5-
# Log data output decorator
3+
# Log Data Output Decorator
64

7-
Small decorator that extends [Symfony OutputInterface](https://github.com/symfony/console/blob/5.x/Output/OutputInterface.php) delivered class with few options for easier to log data.
5+
A decorator that extends [Symfony OutputInterface](https://github.com/symfony/console/blob/7.x/Output/OutputInterface.php) with:
6+
7+
- Multiple message types: info, success, error, fatal, and plain messages
8+
- Automatic indentation with indent control methods
9+
- Parameter substitution using sprintf formatting
10+
- Full Symfony OutputInterface compatibility
811

912
## Installation
1013

11-
To install and use this package, we recommend to use [Composer](https://getcomposer.org):
14+
Install via [Composer](https://getcomposer.org):
1215

1316
```bash
1417
composer require imponeer/log-data-output-decorator
1518
```
1619

17-
Otherwise, you need to include manually files from `src/` directory.
20+
## Usage
21+
22+
### Basic Usage
23+
24+
```php
25+
use Imponeer\Decorators\LogDataOutput\OutputDecorator;
26+
use Symfony\Component\Console\Output\ConsoleOutput;
27+
28+
$output = new OutputDecorator(new ConsoleOutput());
29+
30+
// Different message types
31+
$output->info('This is an info message');
32+
$output->success('Operation completed successfully');
33+
$output->error('An error occurred');
34+
$output->fatal('Critical error - application stopping');
35+
$output->msg('Plain message without formatting');
36+
```
1837

19-
## Usage example
38+
### Indentation Support
2039

2140
```php
22-
$output = new \Imponeer\Decorators\LogDataOutput\OutputDecorator(
23-
new \Symfony\Component\Console\Output\BufferedOutput();
24-
);
25-
$output->info('test');
41+
$output->info('Main process started');
2642
$output->incrIndent();
27-
$output->info('#1');
28-
$output->info('#2');
43+
$output->info('Sub-process 1');
44+
$output->info('Sub-process 2');
45+
$output->incrIndent();
46+
$output->info('Nested sub-process');
47+
$output->decrIndent();
48+
$output->info('Back to sub-process level');
49+
$output->resetIndent();
50+
$output->info('Back to main level');
51+
```
52+
53+
Output:
54+
```
55+
Main process started
56+
Sub-process 1
57+
Sub-process 2
58+
Nested sub-process
59+
Back to sub-process level
60+
Back to main level
61+
```
62+
63+
### Parameter Substitution
64+
65+
```php
66+
$output->info('Processing file: %s', 'example.txt');
67+
$output->success('Processed %d files in %s seconds', 42, '1.23');
68+
$output->error('Failed to process %s: %s', 'file.txt', 'Permission denied');
2969
```
3070

31-
## How to contribute?
71+
### Advanced Example
72+
73+
```php
74+
use Imponeer\Decorators\LogDataOutput\OutputDecorator;
75+
use Symfony\Component\Console\Output\BufferedOutput;
76+
77+
$bufferedOutput = new BufferedOutput();
78+
$output = new OutputDecorator($bufferedOutput);
79+
80+
$output->info('Starting batch process');
81+
$output->incrIndent();
82+
83+
foreach (['file1.txt', 'file2.txt', 'file3.txt'] as $index => $file) {
84+
$output->info('Processing file %d: %s', $index + 1, $file);
85+
$output->incrIndent();
86+
87+
if ($file === 'file2.txt') {
88+
$output->error('Failed to process %s', $file);
89+
} else {
90+
$output->success('Successfully processed %s', $file);
91+
}
92+
93+
$output->decrIndent();
94+
}
95+
96+
$output->resetIndent();
97+
$output->info('Batch process completed');
98+
99+
// Get the formatted output
100+
echo $bufferedOutput->fetch();
101+
```
102+
103+
## API Documentation
104+
105+
Complete API documentation with all methods and examples is available in the [project wiki](https://github.com/imponeer/log-data-output-decorator/wiki), which is automatically generated from the source code.
106+
107+
## Testing
108+
109+
Run the test suite:
110+
111+
```bash
112+
composer test
113+
```
114+
115+
Check code style compliance:
116+
117+
```bash
118+
composer phpcs
119+
```
120+
121+
Fix code style issues automatically:
122+
123+
```bash
124+
composer phpcbf
125+
```
126+
127+
Run static analysis:
128+
129+
```bash
130+
composer phpstan
131+
```
132+
133+
## Contributing
134+
135+
We welcome contributions! Here's how you can help:
136+
137+
1. **Fork the repository** on GitHub
138+
2. **Create a feature branch** (`git checkout -b feature/amazing-feature`)
139+
3. **Make your changes** and add tests if applicable
140+
4. **Run the test suite** to ensure everything works
141+
5. **Commit your changes** (`git commit -am 'Add amazing feature'`)
142+
6. **Push to the branch** (`git push origin feature/amazing-feature`)
143+
7. **Create a Pull Request**
144+
145+
### Development Guidelines
146+
147+
- Follow PSR-12 coding standards
148+
- Add tests for new functionality
149+
- Update documentation for API changes
150+
- Ensure all tests pass before submitting PR
151+
152+
### Reporting Issues
32153

33-
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try [interactive GitHub tutorial](https://skills.github.com).
154+
Found a bug or have a suggestion? Please [open an issue](https://github.com/imponeer/log-data-output-decorator/issues) with:
34155

35-
If you found any bug or have some questions, use [issues tab](https://github.com/imponeer/log-data-output-decorator/issues) and write there your questions.
156+
- Clear description of the problem or suggestion
157+
- Steps to reproduce (for bugs)
158+
- Expected vs actual behavior
159+
- PHP and Symfony Console versions

0 commit comments

Comments
 (0)