From eb3d7138d688ebe8d575c1fb716a02107a82f9c6 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 20 Jun 2022 19:16:37 +0800 Subject: [PATCH] fix getLogFile when use env --- app/Console/Commands/BackupCronjob.php | 1 + include/globalfunctions.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/BackupCronjob.php b/app/Console/Commands/BackupCronjob.php index de6d0e82..8fd39115 100644 --- a/app/Console/Commands/BackupCronjob.php +++ b/app/Console/Commands/BackupCronjob.php @@ -40,6 +40,7 @@ class BackupCronjob extends Command { $force = $this->option('force'); $this->info("force: $force"); + do_log("ENV: " . getenv('NEXUS_LOG_DIR', true) . ", logFile: " . getLogFile()); $rep = new ToolRepository(); $result = $rep->cronjobBackup($force); $log = sprintf( diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 75f2f007..6f99d263 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -177,7 +177,8 @@ function do_log($log, $level = 'info', $echo = false) $logFile = getLogFile(); if (($fd = fopen($logFile, 'a')) === false) { - $fd = fopen(sys_get_temp_dir() . '/nexus.log', 'a'); + $log .= "--------Can not open $logFile"; + $fd = fopen(sys_get_temp_dir() . '/nexus.log', 'a'); } $uid = 0; if (IN_NEXUS) { @@ -235,7 +236,7 @@ function getLogFile() $fromEnv = false; $path = sys_get_temp_dir(); } - $logFile = rtrim($path, '/') . '/nexus_' . date('Y-m-d') . '.log'; + $logFile = rtrim($path, '/') . '/nexus.log'; if (!$fromEnv && !empty($config['log_file'])) { $logFile = $config['log_file']; }