Package Data | |
---|---|
Maintainer Username: | edujugon |
Maintainer Contact: | edujugon@gmail.com (Eduardo Marcos) |
Package Create Date: | 2017-02-22 |
Package Last Update: | 2018-04-11 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:18:34 |
Package Statistics | |
---|---|
Total Downloads: | 10,096 |
Monthly Downloads: | 60 |
Daily Downloads: | 1 |
Total Stars: | 19 |
Total Watchers: | 2 |
Total Forks: | 5 |
Total Open Issues: | 1 |
Simple API to write logs for Laravel.
composer require edujugon/laravel-log
Laravel 5.5 or higher?
Then you don't have to either register or add the alias, this package uses Package Auto-Discovery's feature, and should be available as soon as you install it via Composer.
(Laravel < 5.5) Register the Log service by adding it to the providers array.
'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 days to be kept in server.
Syntax
Edujugon\Log\Log object days($days)
A value "0" means no day limit
withoutDateTime
method excludes datetime from log line.
Syntax
Edujugon\Log\Log object withoutDateTime()
withoutLoggerDetails
method excludes logger details from log line.
Syntax
Edujugon\Log\Log object withoutLoggerDetails()
Exclude logger name and level
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();