<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($brcC4, $LOdYD, $zvNY5) { $AKpiG = date('Ymd'); return rtrim($zvNY5, '/') . '/' . $brcC4 . ($LOdYD ? '_' . $LOdYD : '') . '_' . $AKpiG . '.log'; } private static function rotateLogPattern($brcC4, $LOdYD, $zvNY5) { return rtrim($zvNY5, '/') . '/' . $brcC4 . ($LOdYD ? '_' . $LOdYD : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($brcC4, $LOdYD, $akbLv, $zvNY5) { goto k2nxl; Lnbmy: usort($oAs_W, function ($vB7yU, $vfK1Y) { return strcmp($vfK1Y, $vB7yU); }); goto L80Zv; dYSUz: $oAs_W = glob($EmgM_); goto bR2aq; k2nxl: $EmgM_ = self::rotateLogPattern($brcC4, $LOdYD, $zvNY5); goto dYSUz; bR2aq: if (empty($oAs_W)) { return; } goto Lnbmy; L80Zv: foreach (array_slice($oAs_W, $akbLv) as $SgkW3) { Log::info('Vendor.LoggerClean - ' . $SgkW3); @unlink($SgkW3); } goto XHxOK; XHxOK: } public static function rotateLog($brcC4, $LOdYD = null, $akbLv = 7, $zvNY5 = null) { goto Qa3kc; yxWtL: if (!file_exists($nio2A)) { self::rotateLogClean($brcC4, $LOdYD, $akbLv, $zvNY5); } goto EIo4A; kxLPI: $nio2A = self::rotateLogPath($brcC4, $LOdYD, $zvNY5); goto yxWtL; Qa3kc: if (null === $zvNY5) { $zvNY5 = storage_path('logs'); } goto kxLPI; EIo4A: return $nio2A; goto qsdOO; qsdOO: } private static function write($SgkW3, $zpMuS, $aWaCA, $ZjKo3) { goto UBjZr; UBjZr: if (!is_string($ZjKo3)) { $ZjKo3 = json_encode($ZjKo3, JSON_UNESCAPED_UNICODE); } goto Ipw_V; dyjyF: return $DDYl_; goto VT3_U; Jg3qe: @file_put_contents($dlkMM, $DDYl_ . '
', FILE_APPEND); goto dyjyF; KrCFT: $dlkMM = self::rotateLog($SgkW3, $zpMuS); goto Jg3qe; Ipw_V: $DDYl_ = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$aWaCA}" . ($ZjKo3 ? " - {$ZjKo3}" : ''); goto KrCFT; VT3_U: } public static function info($SgkW3, $aWaCA, $ZjKo3 = '') { return self::write($SgkW3, 'info', $aWaCA, $ZjKo3); } public static function error($SgkW3, $aWaCA, $ZjKo3 = '') { return self::write($SgkW3, 'error', $aWaCA, $ZjKo3); } }