<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($EEeBk, $QuQ2t, $bjBDx) { $R6CaI = date('Ymd'); return rtrim($bjBDx, '/') . '/' . $EEeBk . ($QuQ2t ? '_' . $QuQ2t : '') . '_' . $R6CaI . '.log'; } private static function rotateLogPattern($EEeBk, $QuQ2t, $bjBDx) { return rtrim($bjBDx, '/') . '/' . $EEeBk . ($QuQ2t ? '_' . $QuQ2t : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($EEeBk, $QuQ2t, $PlupV, $bjBDx) { goto T670s; d1X6Y: if (empty($M3ujS)) { return; } goto xjAi7; H4mSM: $M3ujS = glob($c0jdW); goto d1X6Y; xjAi7: usort($M3ujS, function ($OkF3_, $TpLrr) { return strcmp($TpLrr, $OkF3_); }); goto zTd9W; zTd9W: foreach (array_slice($M3ujS, $PlupV) as $x_XbT) { Log::info('Vendor.LoggerClean - ' . $x_XbT); @unlink($x_XbT); } goto CC3Op; T670s: $c0jdW = self::rotateLogPattern($EEeBk, $QuQ2t, $bjBDx); goto H4mSM; CC3Op: } public static function rotateLog($EEeBk, $QuQ2t = null, $PlupV = 7, $bjBDx = null) { goto N4aUc; NuBUO: return $vanIz; goto SOOec; kMhqJ: $vanIz = self::rotateLogPath($EEeBk, $QuQ2t, $bjBDx); goto zmSR4; zmSR4: if (!file_exists($vanIz)) { self::rotateLogClean($EEeBk, $QuQ2t, $PlupV, $bjBDx); } goto NuBUO; N4aUc: if (null === $bjBDx) { $bjBDx = storage_path('logs'); } goto kMhqJ; SOOec: } private static function write($x_XbT, $OUt2n, $shsWz, $axEh6) { goto xZqHW; ohlRh: $Epw61 = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$shsWz}" . ($axEh6 ? " - {$axEh6}" : ''); goto kaEOs; kaEOs: $cIadt = self::rotateLog($x_XbT, $OUt2n); goto kdnUe; xZqHW: if (!is_string($axEh6)) { $axEh6 = json_encode($axEh6, JSON_UNESCAPED_UNICODE); } goto ohlRh; pFSDu: return $Epw61; goto m4Bv6; kdnUe: @file_put_contents($cIadt, $Epw61 . '
', FILE_APPEND); goto pFSDu; m4Bv6: } public static function info($x_XbT, $shsWz, $axEh6 = '') { return self::write($x_XbT, 'info', $shsWz, $axEh6); } public static function error($x_XbT, $shsWz, $axEh6 = '') { return self::write($x_XbT, 'error', $shsWz, $axEh6); } }