<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($hKKLG, $lDiNi, $OSpVD) { $bOHW_ = date('Ymd'); return rtrim($OSpVD, '/') . '/' . $hKKLG . ($lDiNi ? '_' . $lDiNi : '') . '_' . $bOHW_ . '.log'; } private static function rotateLogPattern($hKKLG, $lDiNi, $OSpVD) { return rtrim($OSpVD, '/') . '/' . $hKKLG . ($lDiNi ? '_' . $lDiNi : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($hKKLG, $lDiNi, $B3Czk, $OSpVD) { goto VWdn6; KcVY0: foreach (array_slice($tqeuq, $B3Czk) as $obXaA) { Log::info('Vendor.LoggerClean - ' . $obXaA); @unlink($obXaA); } goto TVLnA; aRsvX: if (empty($tqeuq)) { return; } goto co63y; VWdn6: $xkOoz = self::rotateLogPattern($hKKLG, $lDiNi, $OSpVD); goto JtYlh; co63y: usort($tqeuq, function ($P_pSY, $ZfWBX) { return strcmp($ZfWBX, $P_pSY); }); goto KcVY0; JtYlh: $tqeuq = glob($xkOoz); goto aRsvX; TVLnA: } public static function rotateLog($hKKLG, $lDiNi = null, $B3Czk = 7, $OSpVD = null) { goto YKhMD; N_sgq: if (!file_exists($pqMR1)) { self::rotateLogClean($hKKLG, $lDiNi, $B3Czk, $OSpVD); } goto QTCRc; QTCRc: return $pqMR1; goto VZ9Bk; zfwHA: $pqMR1 = self::rotateLogPath($hKKLG, $lDiNi, $OSpVD); goto N_sgq; YKhMD: if (null === $OSpVD) { $OSpVD = storage_path('logs'); } goto zfwHA; VZ9Bk: } private static function write($obXaA, $mhYne, $L5Bsx, $wk1ic) { goto aXbQe; PL4w_: $LVIHw = self::rotateLog($obXaA, $mhYne); goto xBm9N; xBm9N: @file_put_contents($LVIHw, $kwNqe . '
', FILE_APPEND); goto VllKs; qGUFb: $kwNqe = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$L5Bsx}" . ($wk1ic ? " - {$wk1ic}" : ''); goto PL4w_; VllKs: return $kwNqe; goto WArpH; aXbQe: if (!is_string($wk1ic)) { $wk1ic = json_encode($wk1ic, JSON_UNESCAPED_UNICODE); } goto qGUFb; WArpH: } public static function info($obXaA, $L5Bsx, $wk1ic = '') { return self::write($obXaA, 'info', $L5Bsx, $wk1ic); } public static function error($obXaA, $L5Bsx, $wk1ic = '') { return self::write($obXaA, 'error', $L5Bsx, $wk1ic); } }