123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- namespace App\Http\Utils;
- class LoggerFactoryUtil extends BaseUtil
- {
- /**
- * 请求开始时间
- * @var string $startTime
- */
- private static $startTime="";
- /**
- * 类文件名
- * @var string $class
- */
- protected $class="";
- /**
- * 自定义日志
- * @var array $message
- */
- private static $message=[];
- /**
- * 执行的sql语句
- * @var array $sqlMessage
- */
- private static $sqlMessage=[];
- /**
- * 请求ID
- * @var string $requestId
- */
- private static $requestId;
- /**
- * 是否推送日志
- * @var int
- */
- private static $isPush=0;
- /**
- * @return int
- */
- public static function getIsPush(): int
- {
- return self::$isPush;
- }
- /**
- * @param int $isPush
- */
- public static function setIsPush(int $isPush): void
- {
- self::$isPush = $isPush;
- }
- /**
- * @return string
- */
- public static function getRequestId()
- {
- return self::$requestId;
- }
- /**
- * @param string $requestId
- */
- public static function setRequestId(string $requestId)
- {
- self::$requestId = $requestId;
- }
- /**
- * LoggerFactoryUtil constructor.
- */
- public function __construct(string $class)
- {
- $this->class;
- }
- /**
- * 记录自定义日志信息
- * @param string $msg
- */
- public function info(string $msg)
- {
- $time = date("Y-m-d H:i:s");
- self::$message[] = "[$time]".$this->class.":".$msg;
- }
- /**
- * 记录sql日志
- * @param string $sql
- */
- public static function addSqlMessage(string $sql)
- {
- self::$sqlMessage[] = $sql;
- }
- /**
- * @return array
- */
- public static function getMessage(): array
- {
- return self::$message;
- }
- /**
- * @return array
- */
- public static function getSqlMessage(): array
- {
- return self::$sqlMessage;
- }
- /**
- * @return string
- */
- public static function getStartTime(): string
- {
- return self::$startTime;
- }
- /**
- * @param string $startTime
- */
- public static function setStartTime(string $startTime): void
- {
- self::$startTime = $startTime;
- }
- }
|