<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($v3nkx, $d8IEK, $l0FHz) { $agAyA = date('Ymd'); return rtrim($l0FHz, '/') . '/' . $v3nkx . ($d8IEK ? '_' . $d8IEK : '') . '_' . $agAyA . '.log'; } private static function rotateLogPattern($v3nkx, $d8IEK, $l0FHz) { return rtrim($l0FHz, '/') . '/' . $v3nkx . ($d8IEK ? '_' . $d8IEK : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($v3nkx, $d8IEK, $PNxJE, $l0FHz) { goto KcJKv; eN6rf: usort($PKeQw, function ($E1Tkt, $TCxPq) { return strcmp($TCxPq, $E1Tkt); }); goto NJVTG; sI9bq: $PKeQw = glob($aEBTv); goto eV2O7; KcJKv: $aEBTv = self::rotateLogPattern($v3nkx, $d8IEK, $l0FHz); goto sI9bq; NJVTG: foreach (array_slice($PKeQw, $PNxJE) as $okURS) { Log::info('Vendor.LoggerClean - ' . $okURS); @unlink($okURS); } goto qL1GV; eV2O7: if (empty($PKeQw)) { return; } goto eN6rf; qL1GV: } public static function rotateLog($v3nkx, $d8IEK = null, $PNxJE = 7, $l0FHz = null) { goto jwNOu; BOP9H: return $kHgRs; goto g5ayj; jwNOu: if (null === $l0FHz) { $l0FHz = storage_path('logs'); } goto eyLtd; vZWrT: if (!file_exists($kHgRs)) { self::rotateLogClean($v3nkx, $d8IEK, $PNxJE, $l0FHz); } goto BOP9H; eyLtd: $kHgRs = self::rotateLogPath($v3nkx, $d8IEK, $l0FHz); goto vZWrT; g5ayj: } private static function write($okURS, $AIxhN, $QO4PK, $trk4v) { goto Kvjre; Kvjre: if (!is_string($trk4v)) { $trk4v = json_encode($trk4v, JSON_UNESCAPED_UNICODE); } goto Se5KQ; TdeYK: return $rW9zd; goto yoTCK; V6Wdg: $OgcP2 = self::rotateLog($okURS, $AIxhN); goto dyyk6; dyyk6: @file_put_contents($OgcP2, $rW9zd . '
', FILE_APPEND); goto TdeYK; Se5KQ: $rW9zd = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$QO4PK}" . ($trk4v ? " - {$trk4v}" : ''); goto V6Wdg; yoTCK: } public static function info($okURS, $QO4PK, $trk4v = '') { return self::write($okURS, 'info', $QO4PK, $trk4v); } public static function error($okURS, $QO4PK, $trk4v = '') { return self::write($okURS, 'error', $QO4PK, $trk4v); } }