Simple API to write logs for Laravel.
composer require edujugon/laravel-log
'providers' => array(
...
Edujugon\Log\Providers\LogServiceProvider::class
)
php artisan vendor:publish --provider="Edujugon\Log\Providers\LogServiceProvider" --tag="config"
The above command will generate a new file under your laravel app config folder called log.php
Update the log.php
file with your data.
path
method sets the path where create / storage the log file.
Syntax
Edujugon\Log\Log object path($path)
level
method sets the logging level.
Available levels: emergency, alert, critical, error, warning, notice, info and debug.
Syntax
Edujugon\Log\Log object level($level)
title
method sets the title or main message to be written.
Syntax
Edujugon\Log\Log object title($title)
line
method sets a line below the title.
Notice that you can call this method as many time as lines you need to be written.
Syntax
Edujugon\Log\Log object line($line)
name
method sets the logger name.
By default this name is "my-logger"
Syntax
Edujugon\Log\Log object name($loggerName)
fileName
method sets the file name.
Remember to put the name without any extension.
Syntax
Edujugon\Log\Log object fileName($name)
days
method sets amount of files to be kept in server.
Syntax
Edujugon\Log\Log object days($days)
write
method writes in log file.
Syntax
boolean write()
$log = new Log();
$log->fileName('my-personal-log')
->title('Stored new record')
->line('the record id is 3')
->line('Stored by John')
->line('This is antoher line')
->days(3)
->write();
Also can do it by its Facade:
Log::fileName('my-personal-log')
->title('Stored new record')
->line('the record id is 3')
->line('Stored by John')
->line('This is antoher line')
->write();