<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Log; use Illuminate\Support\Facades\Log; class Logger { private static function rotateLogPath($TwpyJ, $y1Xfs, $ulGT1) { $kTMtd = date('Ymd'); return rtrim($ulGT1, '/') . '/' . $TwpyJ . ($y1Xfs ? '_' . $y1Xfs : '') . '_' . $kTMtd . '.log'; } private static function rotateLogPattern($TwpyJ, $y1Xfs, $ulGT1) { return rtrim($ulGT1, '/') . '/' . $TwpyJ . ($y1Xfs ? '_' . $y1Xfs : '') . '_[0-9][0-9][0-9][0-9]*.log'; } private static function rotateLogClean($TwpyJ, $y1Xfs, $LnECM, $ulGT1) { goto lxDed; k4Y_b: if (empty($dIa9z)) { return; } goto yB1Sy; lloNr: foreach (array_slice($dIa9z, $LnECM) as $wjJPd) { Log::info('Vendor.LoggerClean - ' . $wjJPd); @unlink($wjJPd); } goto vKj92; yB1Sy: usort($dIa9z, function ($pvtT4, $LqY0C) { return strcmp($LqY0C, $pvtT4); }); goto lloNr; lxDed: $XyY18 = self::rotateLogPattern($TwpyJ, $y1Xfs, $ulGT1); goto a7jVz; a7jVz: $dIa9z = glob($XyY18); goto k4Y_b; vKj92: } public static function rotateLog($TwpyJ, $y1Xfs = null, $LnECM = 7, $ulGT1 = null) { goto kDgsc; LTHkk: $fCnvM = self::rotateLogPath($TwpyJ, $y1Xfs, $ulGT1); goto X2A1J; X2A1J: if (!file_exists($fCnvM)) { self::rotateLogClean($TwpyJ, $y1Xfs, $LnECM, $ulGT1); } goto zVZOh; kDgsc: if (null === $ulGT1) { $ulGT1 = storage_path('logs'); } goto LTHkk; zVZOh: return $fCnvM; goto iCp5l; iCp5l: } private static function write($wjJPd, $zTlk4, $ZioUf, $Lo_ux) { goto t0CWS; cr6Kr: @file_put_contents($rFzy_, $iJa31 . '
', FILE_APPEND); goto UR0d3; t0CWS: if (!is_string($Lo_ux)) { $Lo_ux = json_encode($Lo_ux, JSON_UNESCAPED_UNICODE); } goto Z3tvT; UL1Vu: $rFzy_ = self::rotateLog($wjJPd, $zTlk4); goto cr6Kr; Z3tvT: $iJa31 = '[' . sprintf('%05d', getmypid()) . '] ' . date('Y-m-d H:i:s') . " - {$ZioUf}" . ($Lo_ux ? " - {$Lo_ux}" : ''); goto UL1Vu; UR0d3: return $iJa31; goto w0uwE; w0uwE: } public static function info($wjJPd, $ZioUf, $Lo_ux = '') { return self::write($wjJPd, 'info', $ZioUf, $Lo_ux); } public static function error($wjJPd, $ZioUf, $Lo_ux = '') { return self::write($wjJPd, 'error', $ZioUf, $Lo_ux); } }