<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($xHs9Y, $Zw7f3, $rkEHz) { $D6Biq = date('Ymd'); return rtrim($rkEHz, '/') . '/' . $xHs9Y . ($Zw7f3 ? '_' . $Zw7f3 : '') . '_' . $D6Biq . '.log'; } private static function rotateLogPattern($xHs9Y, $Zw7f3, $rkEHz) { return rtrim($rkEHz, '/') . '/' . $xHs9Y . ($Zw7f3 ? '_' . $Zw7f3 : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($xHs9Y, $Zw7f3, $hBiBw, $rkEHz) { goto RmGFQ; RmGFQ: $vu50L = self::rotateLogPattern($xHs9Y, $Zw7f3, $rkEHz); goto AulC8; AulC8: $T17QN = glob($vu50L); goto wAQLC; zoIB2: usort($T17QN, function ($vgAtT, $ev2YV) { return strcmp($ev2YV, $vgAtT); }); goto NCxGj; NCxGj: foreach (array_slice($T17QN, $hBiBw) as $dG73t) { Log::info('Vendor.LoggerClean - ' . $dG73t); @unlink($dG73t); } goto N6T_W; wAQLC: if (empty($T17QN)) { return; } goto zoIB2; N6T_W: } public static function rotateLog($xHs9Y, $Zw7f3 = null, $hBiBw = 7, $rkEHz = null) { goto KA0mR; ZoghB: if (!file_exists($EoIvR)) { self::rotateLogClean($xHs9Y, $Zw7f3, $hBiBw, $rkEHz); } goto UAgQu; UAgQu: return $EoIvR; goto gXlEr; KA0mR: if (null === $rkEHz) { $rkEHz = storage_path('logs'); } goto v3v00; v3v00: $EoIvR = self::rotateLogPath($xHs9Y, $Zw7f3, $rkEHz); goto ZoghB; gXlEr: } private static function write($dG73t, $EpKdG, $I5Rz9, $nXCfA) { goto Y8zBD; Y8zBD: if (!is_string($nXCfA)) { $nXCfA = json_encode($nXCfA, JSON_UNESCAPED_UNICODE); } goto Z8mN9; Mhmod: @file_put_contents($l5HmZ, $BulAC . '
', FILE_APPEND); goto iGQyU; Z8mN9: $BulAC = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$I5Rz9}" . ($nXCfA ? " - {$nXCfA}" : ''); goto IuWNt; IuWNt: $l5HmZ = self::rotateLog($dG73t, $EpKdG); goto Mhmod; iGQyU: return $BulAC; goto K5NZW; K5NZW: } public static function info($dG73t, $I5Rz9, $nXCfA = '') { return self::write($dG73t, 'info', $I5Rz9, $nXCfA); } public static function error($dG73t, $I5Rz9, $nXCfA = '') { return self::write($dG73t, 'error', $I5Rz9, $nXCfA); } }