Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | n/a |
0 / 0 |
|
0.00% |
0 / 1 |
CRAP | |
55.56% |
5 / 9 |
|
| logFileNamePath | |
0.00% |
0 / 1 |
7.19 | |
55.56% |
5 / 9 |
|||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Define log file name in terms of service name |
| 5 | * |
| 6 | * Return new path or default storage path if it cannot create directory |
| 7 | * |
| 8 | * @param string $filename |
| 9 | * @return string |
| 10 | */ |
| 11 | if (!function_exists('logFileNamePath')) { |
| 12 | function logFileNamePath($filename = 'laravel.log') { |
| 13 | $envLogPath = env('LOG_PATH', '/var/log/laravel/'); |
| 14 | $path = $envLogPath . (!empty((getenv('SERVICE_NAME'))) ? getenv('SERVICE_NAME') : 'global'); |
| 15 | if (!is_dir($path)) { |
| 16 | if (!mkdir($path, 0777, true)) { |
| 17 | return storage_path('logs/' . $filename); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | if (!file_exists($path . '/' . $filename)) { |
| 22 | touch($path . '/' . $filename); |
| 23 | chmod($path . '/' . $filename, 0777); |
| 24 | } |
| 25 | |
| 26 | return $path . '/' . $filename; |
| 27 | } |
| 28 | } |