Skip to content

Commit

Permalink
Merge pull request #115 from tosoikea/master
Browse files Browse the repository at this point in the history
Added initialization to file target
  • Loading branch information
EsOsO authored Feb 18, 2021
2 parents fe4b47c + 7aa1b7c commit 2eb6136
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Logging/targets/File.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
Level = @{Required = $false; Type = [string]; Default = $Logging.Level }
Format = @{Required = $false; Type = [string]; Default = $Logging.Format }
}
Init = {
param(
[hashtable] $Configuration
)

[String] $directoryPath = [System.IO.Path]::GetDirectoryName($Configuration.Path)

# We (try to) create the directory if it is not yet given
if (-not [System.IO.Directory]::Exists($directoryPath)){
# "Creates all directories and subdirectories in the specified path unless they already exist."
# https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory?view=net-5.0#System_IO_Directory_CreateDirectory_System_String_
[System.IO.Directory]::CreateDirectory($directoryPath) | Out-Null
}
}
Logger = {
param(
[hashtable] $Log,
Expand Down

0 comments on commit 2eb6136

Please sign in to comment.