Beispiel #1
0
 public static function loggerFileName($domain, $ext = 'log')
 {
     $date = date('Y-m-d');
     $hour = date('H');
     $filePath = WZhaopinEnv::getLogDir() . '/' . $date . '/';
     ensureFilePath($filePath, true);
     if (strlen($domain) > 0) {
         $filePath = sprintf('%s%s-%02d.%s', $filePath, $domain, $hour, $ext);
     } else {
         $filePath = sprintf('%s%d.%s', $filePath, $hour, $ext);
     }
     return $filePath;
 }
Beispiel #2
0
 private static function write(&$info, $level, $file = '', $line = '')
 {
     if (strlen($file) > 0) {
         $file = substr($file, strlen($_SERVER['DOCUMENT_ROOT']));
     }
     $levelMsg = 'DEBUG';
     if ($level == YAF_LOG_LEVEL_ERROR) {
         $levelMsg = 'ERROR';
     }
     $time = date('H:i:s');
     $info = print_r($info, true);
     $message = sprintf("%s - [%s] - %s:%s%s\r\n", $time, $levelMsg, $file, $line, $info);
     $date = date('Y-m-d');
     $hour = date('H');
     $path = sprintf('%s/%s', self::$LOG_BASE_DIR, $date);
     ensureFilePath($path, true);
     $path = sprintf('%s/%d.log', $path, $hour);
     //        var_dump($path);
     file_put_contents($path, $message, FILE_APPEND);
 }