Last active
December 19, 2019 10:00
-
-
Save atao/1ab32d886688c706cba315bc0739c12d to your computer and use it in GitHub Desktop.
Revisions
-
atao revised this gist
Dec 19, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #region Journalisation function initLog { param( [string]$loggerPath = "$PSScriptRoot\file.log" ) if (!(Test-Path $loggerPath)){New-Item -Path $loggerPath -ItemType File} loggerInfo "-----------------------------------------------" $loggerPath @@ -12,8 +12,8 @@ function initLog { function loggerInfo { Param ( [parameter(Mandatory = $true)][string]$msg, [string]$loggerPath = "$PSScriptRoot\file.log" ) # Verification de la presence du chemin temporaire de l'utilisateur If (Test-Path -Path $loggerPath) @@ -34,8 +34,8 @@ function loggerInfo { function loggerErreur { Param ( [parameter(Mandatory = $true)][string]$msg, [string]$loggerPath = "$PSScriptRoot\file.log" ) # Verification de la presence du chemin temporaire de l'utilisateur If (Test-Path -Path $loggerPath) -
atao created this gist
Dec 18, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #region Journalisation function initLog { param( [string]$loggerPath ) if (!(Test-Path $loggerPath)){New-Item -Path $loggerPath -ItemType File} loggerInfo "-----------------------------------------------" $loggerPath loggerInfo "+ Programme : BackupAndSend" $loggerPath loggerInfo "+ Version : 18/12/2019" $loggerPath loggerInfo "-----------------------------------------------" $loggerPath } function loggerInfo { Param ( [string]$msg, [string]$loggerPath ) # Verification de la presence du chemin temporaire de l'utilisateur If (Test-Path -Path $loggerPath) { # Recuperation de la date actuelle $dateActuelle = Get-Date -Format "yyyy-MM-dd HH:mm:ss" "$dateActuelle [INFO] $msg" | Out-File -FilePath $loggerPath -Append If (!($?)) { loggerErreur "Impossible d'écrire dans le fichier $loggerPath" } } Else { loggerErreur "Impossible de trouver le chemin $loggerPath" } } function loggerErreur { Param ( [string]$msg, [string]$loggerPath ) # Verification de la presence du chemin temporaire de l'utilisateur If (Test-Path -Path $loggerPath) { # Recuperation de la date actuelle $dateActuelle = Get-Date -Format "yyyy-MM-dd HH:mm:ss" "$dateActuelle [ERROR] $msg" | Out-File -FilePath $loggerPath -Append If (!($?)) { loggerErreur "Impossible d'écrire dans le fichier $loggerPath" } } Else { loggerErreur "Impossible de trouver le chemin $loggerPath" } } #endregion Journalisation