|
function my_log($data = [], $type = 'type') { $logFile = date('Y-m-d'); $logPath = "./logs/{$type}/"; if( ! file_exists($logPath) ) { mkdir($logPath,0777,true); chmod($logPath,0777); } $fileName = $logPath.$logFile.'.log'; if( filesize($fileName) > 2097152*4 ) { rename($fileName, $logPath.$logFile.'_'.time().'.log'); } file_put_contents($fileName, print_r($data, true), FILE_APPEND); } |
|