Skip to content

Commit

Permalink
[update] Log
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeme committed Apr 6, 2021
1 parent 061634c commit c705b10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
12 changes: 0 additions & 12 deletions data/activity_infos.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@
"expire_at": "2021-04-30 23:59:59",
"remarks": "时间不名,暂定一个月。"
},
{
"url": "https://www.bilibili.com/blackboard/activity-YxhUEb7UwQ.html",
"title": "种草大作战特别篇",
"description": "活动期间每天分享页面,新增一次机会。",
"sid": "0cc8ffd7-8d56-11eb-8597-246e966235d8",
"login": "true",
"follow": "false",
"share": "true",
"draw_times": 2,
"expire_at": "2021-01-01 11:11:11",
"remarks": "2021年4月02日开始,先指定为过期。"
},
{
"url": "https://www.bilibili.com/blackboard/activity-M22oqFLY1w.html",
"title": "最强搞事王",
Expand Down
13 changes: 8 additions & 5 deletions src/core/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ private static function prefix()
private static function writeLog($type, $message)
{
if (getenv('APP_WRITE_LOG') == 'true') {
if ($type == 'DEBUG' && getenv("APP_DEBUG") != 'true') {
return;
}
$path = './' . getenv("APP_LOG_PATH") . '/';
if (!file_exists($path)) {
mkdir($path);
Expand All @@ -61,7 +64,7 @@ private static function writeLog($type, $message)
private static function backtrace(): string
{
$backtraces = debug_backtrace();
return "(". pathinfo(basename($backtraces[1]['file']))['filename'] . ") => ";
return "(" . pathinfo(basename($backtraces[1]['file']))['filename'] . ") => ";
}

public static function debug($message, array $context = [])
Expand All @@ -72,31 +75,31 @@ public static function debug($message, array $context = [])

public static function info($message, array $context = [])
{
$message = self::prefix() .self::backtrace() . $message;
$message = self::prefix() . self::backtrace() . $message;
self::writeLog('INFO', $message);
self::getLogger()->addInfo($message, $context);
self::callback(Logger::INFO, 'INFO', $message);
}

public static function notice($message, array $context = [])
{
$message = self::prefix() .self::backtrace() . $message;
$message = self::prefix() . self::backtrace() . $message;
self::writeLog('NOTICE', $message);
self::getLogger()->addNotice($message, $context);
self::callback(Logger::NOTICE, 'NOTICE', $message);
}

public static function warning($message, array $context = [])
{
$message = self::prefix() .self::backtrace() . $message;
$message = self::prefix() . self::backtrace() . $message;
self::writeLog('WARNING', $message);
self::getLogger()->addWarning($message, $context);
self::callback(Logger::WARNING, 'WARNING', $message);
}

public static function error($message, array $context = [])
{
$message = self::prefix() .self::backtrace() . $message;
$message = self::prefix() . self::backtrace() . $message;
self::writeLog('ERROR', $message);
self::getLogger()->addError($message, $context);
self::callback(Logger::ERROR, 'ERROR', $message);
Expand Down

0 comments on commit c705b10

Please sign in to comment.