https://github.com/veronalabs/logger-wp
Logger for WordPress Based on PSR-3
https://github.com/veronalabs/logger-wp
Last synced: about 2 months ago
JSON representation
Logger for WordPress Based on PSR-3
- Host: GitHub
- URL: https://github.com/veronalabs/logger-wp
- Owner: veronalabs
- License: mit
- Created: 2022-06-11T13:25:57.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-13T08:30:57.000Z (over 2 years ago)
- Last Synced: 2025-04-13T08:42:24.662Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LoggerWP - Logger for WordPress Based on PSR-3
[](https://packagist.org/packages/veronalabs/logger-wp)
[](https://packagist.org/packages/veronalabs/logger-wp)
LoggerWP sends your logs to wp-content directory.
This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
interface that you can type-hint against in your own libraries to keep a maximum of interoperability.## Features
* Protect the log files by .htaccess and hash the file name
* Support custom channel name
* Support custom log directory name
* Support admin log viewer
* Support PHP errors handler (TODO)
* Support logger exception handler## Installation
Install the latest version with
```bash
composer require veronalabs/logger-wp
```## Basic Usage
```php
'wpsms-logs', // wp-content/uploads/wpsms-logs/plugin-2022-06-11-37718a3a6b5ee53761291cf86edc9e10.log
'channel' => 'plugin', // default dev
'logs_days' => 30
]);$logger->warning('Foo');
$logger->warning('Foo with context', [
'name' => 'Sarah',
'age' => '23',
]);$logger->setChannel('api'); // wp-content/uploads/wpsms-logs/api-2022-06-11-37718a3a6b5ee53761291cf86edc9e10
$logger->error('Twilio encountered issue!');
```## Logger Exception handler
```php
use LoggerWp\Exception\LogerException;try {
throw new LogerException('API error!');
} catch (Exception $e) {
}
```Or
```php
use LoggerWp\Logger;try {
throw new Exception('API error!');
} catch (Exception $e) {
Logger::getInstance()->warning($e->getMessage());
}
```## About
### Requirements
- LoggerWP `^1.0` works with PHP 7.4 or above.
### Submitting bugs and feature requests
Bugs and feature request are tracked on [GitHub](https://github.com/veronalabs/logger-wp/issues)
### License
LoggerWP is licensed under the MIT License - see the [LICENSE](LICENSE) file for details