diff --git a/smart_shutdown.ps1 b/smart_shutdown.ps1 index 18e4f3b..b0369c6 100644 --- a/smart_shutdown.ps1 +++ b/smart_shutdown.ps1 @@ -34,7 +34,7 @@ # 日志配置 [string]$LogDirectory = Join-Path -Path $PSScriptRoot -ChildPath "logs" -[string]$LogFile = Join-Path -Path $LogDirectory -ChildPath "network_monitor_$(Get-Date -Format 'yyyyMMdd').log" +#[string]$LogFile = Join-Path -Path $LogDirectory -ChildPath "network_monitor_$(Get-Date -Format 'yyyyMMdd').log" [int]$MaxLogDays = 30 # ================================================= @@ -52,6 +52,11 @@ function Write-Log { [string]$Message ) + # ===================== V0.2update ===================== + # 每次写日志时,都重新根据当前日期确定日志文件名 + $LogFile = Join-Path -Path $LogDirectory -ChildPath "network_monitor_$(Get-Date -Format 'yyyyMMdd').log" + # ==================================================== + $logTimestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $logEntry = "[$logTimestamp] [$Level] $Message" @@ -231,4 +236,4 @@ while ($true) {# 测试网络连接 Start-Sleep -Seconds $NormalPingInterval } } -} \ No newline at end of file +}