Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmedash95/laravel-log-writer
Custom Log files for Laravel
https://github.com/ahmedash95/laravel-log-writer
laravel laravel-log
Last synced: about 2 months ago
JSON representation
Custom Log files for Laravel
- Host: GitHub
- URL: https://github.com/ahmedash95/laravel-log-writer
- Owner: ahmedash95
- License: mit
- Created: 2017-04-21T20:43:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-21T22:57:59.000Z (over 7 years ago)
- Last Synced: 2024-04-29T08:42:05.738Z (8 months ago)
- Topics: laravel, laravel-log
- Language: PHP
- Size: 8.79 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Custom Log Writer
customize your laravel log into seperated files## Installation
You can install the package via composer:
``` bash
composer require ahmedash95/logwriter
```Next up, the service provider must be registered:
```php
// config/app.php
'providers' => [
...
Ahmedash95\LogWriter\Providers\LogWriterServiceProvider::class,];
// Register alias
'aliases' => [
...
'LogWriter' => Ahmedash95\LogWriter\Facades\LogWriterFacade::class,
];
```you must publish the config file for customize log files:
```
php artisan vendor:publish --provider="Ahmedash95\LogWriter\Providers\LogWriterServiceProvider"
```This is the contents of the published file: ```config/logwriter.php```
```php
storage_path(),/*
* The Log channels.
*/
'channels' => [
'event' => [
'path' => 'logs/event.log',
'level' => Logger::INFO,
],
'audit' => [
'path' => 'logs/audit.log',
'level' => Logger::INFO,
],
],/*
* The Log levels.
*/
'levels' => [
'debug' => Logger::DEBUG,
'info' => Logger::INFO,
'notice' => Logger::NOTICE,
'warning' => Logger::WARNING,
'error' => Logger::ERROR,
'critical' => Logger::CRITICAL,
'alert' => Logger::ALERT,
'emergency' => Logger::EMERGENCY,
],];
```### Available methods
#### Log to file
The easiest way to log info in the file is to use write method```php
LogWriter::write('event','This is log line into event file');
```#### log levels
Also you can use defferent types that definted in levels list
```php
LogWriter::alert('event','Using log levels');
// or
LogWriter::warning('event','Using log levels');
```## Credits
- [Ahmed Ashraf](https://github.com/ahmedash95)
- [All Contributors](../../contributors) not yet :)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.