Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
luolongfei committed Mar 14, 2022
2 parents 756df8c + 73fd16a commit 43c77ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function lang($key = '')
function system_log($content, array $response = [], $fileName = '')
{
try {
$path = sprintf('%s/logs/%s/', ROOT_PATH, date('Y-m'));
# 云函数只有 /tmp 目录可写
$path = IS_SCF ? '/tmp/' : sprintf('%s/logs/%s/', ROOT_PATH, date('Y-m'));
$file = $path . ($fileName ?: date('d')) . '.log';

if (!is_dir($path)) {
Expand Down
3 changes: 2 additions & 1 deletion libs/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class Log extends Base
public static function logger()
{
if (!self::$loggerInstance instanceof Logger) {
// 云函数只能在 /tmp 目录下写文件
$handler = new StreamHandler(
config('debug') ? 'php://stdout' : sprintf('%s/logs/%s.log', ROOT_PATH, date('Y-m/d')),
config('debug') || IS_SCF ? 'php://stdout' : sprintf('%s/logs/%s.log', ROOT_PATH, date('Y-m/d')),
config('debug') ? Logger::DEBUG : Logger::INFO
);
if (config('debug')) {
Expand Down

0 comments on commit 43c77ea

Please sign in to comment.