Update smart_shutdown.ps1 v0.2
每次写日志时,都重新根据当前日期确定日志文件名
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user