https://github.com/effectra/log
Effectra\Log is a logging library that provides a simple and flexible way to handle logging in your PHP applications. It implements the PSR-3 LoggerInterface and includes additional features for log handling.
https://github.com/effectra/log
log logging php psr psr-3
Last synced: 10 months ago
JSON representation
Effectra\Log is a logging library that provides a simple and flexible way to handle logging in your PHP applications. It implements the PSR-3 LoggerInterface and includes additional features for log handling.
- Host: GitHub
- URL: https://github.com/effectra/log
- Owner: effectra
- Created: 2023-05-28T14:12:38.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-20T14:45:33.000Z (almost 3 years ago)
- Last Synced: 2025-05-21T16:13:05.949Z (about 1 year ago)
- Topics: log, logging, php, psr, psr-3
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Effectra\Log
Effectra\Log is a logging library that provides a simple and flexible way to handle logging in your PHP applications. It implements the [PSR-3 LoggerInterface](https://www.php-fig.org/psr/psr-3/) and includes additional features for log handling.
## Installation
You can install the Effectra\Log library via Composer. Run the following command in your project directory:
```
composer require effectra/log
```
## Usage
To use the Effectra\Log library in your project, follow these steps:
1. Create an instance of the `Logger` class:
```php
use Effectra\Log\Logger;
$logger = new Logger('/path/to/log/file.log');
```
2. Start logging messages:
```php
$logger->info('This is an informational message.');
$logger->error('An error occurred.', ['context' => 'additional data']);
// ...
```
3. Customize log levels:
```php
use Effectra\Log\LogLevel;
$logger->log(LogLevel::DEBUG, 'Debug message');
$logger->log(LogLevel::WARNING, 'Warning message');
// ...
```
4. Set the logger instance on other classes (optional):
```php
use Effectra\Log\LoggerAware;
use Psr\Log\LoggerInterface;
class MyClass implements LoggerAware
{
public function __construct(LoggerInterface $logger)
{
$this->setLogger($logger);
}
// ...
}
```
For more detailed information on the available methods and features, refer to the code documentation and the [PSR-3 LoggerInterface](https://www.php-fig.org/psr/psr-3/) documentation.
## Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/effectra/log).
## License
The Effectra\Log library is open-source software released under the [MIT License](https://opensource.org/licenses/MIT).