Last active
November 22, 2016 03:20
-
-
Save cuonghuynh/6a4a4eadc4f39c7231aed4f6dcf3b419 to your computer and use it in GitHub Desktop.
Write logs into seperate files in laravel 5.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogUtil | |
{ | |
/** | |
* Write a content out file log | |
* @param string $file | |
* @param string $content | |
* @return boolean | |
*/ | |
public static function write($file, $content) | |
{ | |
$logDir = config('feedsreader.log.path'); | |
$path = sprintf('%s/%s.log', $logDir, $file); | |
$serialized = sprintf('%s: %s' . "\n", Carbon::now(), $content); | |
if (\File::exists($path)) { | |
return \File::append($path, $serialized); | |
} | |
return \File::put($path, $content); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment