Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thiagodp/logger
A very simple logger for PHP. No magic configuration required. Just the basic features you need most.
https://github.com/thiagodp/logger
log logger php phputil
Last synced: 1 day ago
JSON representation
A very simple logger for PHP. No magic configuration required. Just the basic features you need most.
- Host: GitHub
- URL: https://github.com/thiagodp/logger
- Owner: thiagodp
- License: lgpl-3.0
- Created: 2016-07-10T19:44:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-12T23:59:54.000Z (over 6 years ago)
- Last Synced: 2024-08-24T05:23:43.588Z (3 months ago)
- Topics: log, logger, php, phputil
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logger
A very simple logger for PHP. No magic configuration required. Just the basic features you need most.
Provided interfaces and classes:
* [phputil\Logger](https://github.com/thiagodp/logger/blob/master/lib/Logger.php) interface
* [phputil\BaseLogger](https://github.com/thiagodp/logger/blob/master/lib/BaseLogger.php) abstract class
* [phputil\TextFileLogger](https://github.com/thiagodp/logger/blob/master/lib/TextFileLogger.php) class
* [phputil\FakeLogger](https://github.com/thiagodp/logger/blob/master/lib/FakeLogger.php) class (v1.1+)
* [phputil\EchoLogger](https://github.com/thiagodp/logger/blob/master/lib/EchoLogger.php) class (v1.3+)Available log methods:
* `bool debug( string $message, Exception $e = null, array $context = array() );`
* `bool info( string $message, Exception $e = null, array $context = array() );`
* `bool warn( string $message, Exception $e = null, array $context = array() );`
* `bool error( string $message, Exception $e = null, array $context = array() );`
* `bool log( string $logType, string $message, Exception $e = null, array $context = array() );`### Installation
```command
composer require phputil/logger
```### Example 1
```php
info( 'Something will happen' );
$logger->debug( 'Something happened.' );
$logger->warn( 'Wait!' );
$logger->error( 'Ouch.' );$logger->log( Logger::DEBUG, "That's awesome!" );
?>
```### Example 2
```php
info( 'Something will happen' );
try {
throw new \Exception( 'Hummm... something bad happened.' );
} catch ( \Exception $e ) {
// Logs message and trace
$logger->error( 'Ouch, I did not expect that!', $e );
}$logger->log( Logger::DEBUG, "That's awesome!" );
?>
```### Example 3
```php
info( 'It can log to the console too!' );
?>
```