<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; use ModStart\Core\Util\SerializeUtil; class Logger { private static function rotateLogPath($nLtfI, $e9y4d, $kYRoG) { $CImqM = date('Ymd'); return rtrim($kYRoG, '/') . '/' . $nLtfI . ($e9y4d ? '_' . $e9y4d : '') . '_' . $CImqM . '.log'; } private static function rotateLogPattern($nLtfI, $e9y4d, $kYRoG) { return rtrim($kYRoG, '/') . '/' . $nLtfI . ($e9y4d ? '_' . $e9y4d : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($nLtfI, $e9y4d, $yUv5S, $kYRoG) { goto KlfrS; KlfrS: $gSl5H = self::rotateLogPattern($nLtfI, $e9y4d, $kYRoG); goto lsCpX; Smdq1: if (empty($NMKJQ)) { return; } goto Sb9pf; Sb9pf: usort($NMKJQ, function ($aVDlj, $jyPL0) { return strcmp($jyPL0, $aVDlj); }); goto P21aa; lsCpX: $NMKJQ = glob($gSl5H); goto Smdq1; P21aa: foreach (array_slice($NMKJQ, $yUv5S) as $bHKYd) { Log::info('Vendor.LoggerClean - ' . $bHKYd); @unlink($bHKYd); } goto Db37u; Db37u: } public static function rotateLog($nLtfI, $e9y4d = null, $yUv5S = 7, $kYRoG = null) { goto C9WkY; C9WkY: if (null === $kYRoG) { $kYRoG = storage_path('logs'); } goto MDaw2; jcK5T: if (!file_exists($REzBr)) { self::rotateLogClean($nLtfI, $e9y4d, $yUv5S, $kYRoG); } goto GK5pg; MDaw2: $REzBr = self::rotateLogPath($nLtfI, $e9y4d, $kYRoG); goto jcK5T; GK5pg: return $REzBr; goto fRUwJ; fRUwJ: } private static function write($bHKYd, $HWA34, $kEEi9, $Qs3bw) { goto tkMUl; Q2U27: $BpyyA = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$kEEi9}" . ($Qs3bw ? " - {$Qs3bw}" : ''); goto SoY1K; tkMUl: if (!is_string($Qs3bw)) { $Qs3bw = SerializeUtil::jsonEncode($Qs3bw); } goto Q2U27; C8XO6: @file_put_contents($naxi5, $BpyyA . '
', FILE_APPEND); goto EW5Mi; EW5Mi: return $BpyyA; goto uNMDr; SoY1K: $naxi5 = self::rotateLog($bHKYd, $HWA34); goto C8XO6; uNMDr: } public static function info($bHKYd, $kEEi9, $Qs3bw = '') { return self::write($bHKYd, 'info', $kEEi9, $Qs3bw); } public static function error($bHKYd, $kEEi9, $Qs3bw = '') { return self::write($bHKYd, 'error', $kEEi9, $Qs3bw); } }