<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($bwhwE, $xb1Wm, $sTTOv) { $gueAd = date('Ymd'); return rtrim($sTTOv, '/') . '/' . $bwhwE . ($xb1Wm ? '_' . $xb1Wm : '') . '_' . $gueAd . '.log'; } private static function rotateLogPattern($bwhwE, $xb1Wm, $sTTOv) { return rtrim($sTTOv, '/') . '/' . $bwhwE . ($xb1Wm ? '_' . $xb1Wm : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($bwhwE, $xb1Wm, $XJtOk, $sTTOv) { goto wISGp; vRR0B: foreach (array_slice($iC_Nu, $XJtOk) as $Jm77a) { Log::info('Vendor.LoggerClean - ' . $Jm77a); @unlink($Jm77a); } goto FW13T; Dx5ZV: if (empty($iC_Nu)) { return; } goto Svg2v; Svg2v: usort($iC_Nu, function ($CMJ6j, $Ct6yy) { return strcmp($Ct6yy, $CMJ6j); }); goto vRR0B; oRRXc: $iC_Nu = glob($FqESj); goto Dx5ZV; wISGp: $FqESj = self::rotateLogPattern($bwhwE, $xb1Wm, $sTTOv); goto oRRXc; FW13T: } public static function rotateLog($bwhwE, $xb1Wm = null, $XJtOk = 7, $sTTOv = null) { goto ROog7; gq4Y3: $SCMtv = self::rotateLogPath($bwhwE, $xb1Wm, $sTTOv); goto esl7b; ROog7: if (null === $sTTOv) { $sTTOv = storage_path('logs'); } goto gq4Y3; Jt5kH: return $SCMtv; goto ZeQgb; esl7b: if (!file_exists($SCMtv)) { self::rotateLogClean($bwhwE, $xb1Wm, $XJtOk, $sTTOv); } goto Jt5kH; ZeQgb: } private static function write($Jm77a, $g_4iP, $k71qT, $JGWZb) { goto qNk0H; g3OAn: $HhR57 = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$k71qT}" . ($JGWZb ? " - {$JGWZb}" : ''); goto m3Fnq; WRX9R: @file_put_contents($VvzkK, $HhR57 . '
', FILE_APPEND); goto fcoNq; qNk0H: if (!is_string($JGWZb)) { $JGWZb = json_encode($JGWZb, JSON_UNESCAPED_UNICODE); } goto g3OAn; m3Fnq: $VvzkK = self::rotateLog($Jm77a, $g_4iP); goto WRX9R; fcoNq: return $HhR57; goto GzOTm; GzOTm: } public static function info($Jm77a, $k71qT, $JGWZb = '') { return self::write($Jm77a, 'info', $k71qT, $JGWZb); } public static function error($Jm77a, $k71qT, $JGWZb = '') { return self::write($Jm77a, 'error', $k71qT, $JGWZb); } }