cleanup logging
This commit is contained in:
@@ -26,12 +26,13 @@ Function Log
|
|||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message,
|
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message,
|
||||||
[Parameter(Mandatory=$false)][switch]$Error,
|
[Parameter(Mandatory=$false)][switch]$Error=$false,
|
||||||
[Parameter(Mandatory=$false)][string]$LogName
|
[Parameter(Mandatory=$false)][string]$LogName
|
||||||
)
|
)
|
||||||
If ( $Error ) { $LogEntry = "{0} - Error: {1}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"), $Message }
|
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||||
Else { $LogEntry = "{0} - {1}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"), $Message }
|
If ( $Error ) { $LogEntry = "${Timestamp} - Error: ${Message}" }
|
||||||
If ($LogName )
|
Else { $LogEntry = "${Timestamp} - ${Message}" }
|
||||||
|
If ( $LogName )
|
||||||
{
|
{
|
||||||
$LogFile = "${MSPLogs}\${LogFilePrefix}-${LogName}.log"
|
$LogFile = "${MSPLogs}\${LogFilePrefix}-${LogName}.log"
|
||||||
If (! (Test-Path $LogFile) ) { New-Item -Path $LogFile -ItemType File -Force | Out-Null }
|
If (! (Test-Path $LogFile) ) { New-Item -Path $LogFile -ItemType File -Force | Out-Null }
|
||||||
|
|||||||
Reference in New Issue
Block a user