Skip to content

Instantly share code, notes, and snippets.

@tobyqin
Created December 22, 2015 08:54
Show Gist options
  • Save tobyqin/d22f1998ef98834d3b6a to your computer and use it in GitHub Desktop.
Save tobyqin/d22f1998ef98834d3b6a to your computer and use it in GitHub Desktop.
function Get-LogDir($env)
{
$dir = $globalConf.LogDir
New-Item -Path $dir -ItemType "Directory" -Force | Out-Null
return $dir
}
function Init-LogFile($env, $stepName)
{
$logDir = Get-LogDir $env
$dateString = Get-Date -Format "yyyyMMdd_HHmmss"
$stepName = "{0}_{1}" -f $stepName, $dateString
$file = Join-Path "$logDir" "$stepName.log"
Log-Info "Log: $file"
New-Item -Path $file -ItemType "File" -Force | Out-Null
return $file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment