-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed spelling mistake closes #1
- Loading branch information
Showing
1 changed file
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ Function Write-ToLog { | |
<# | ||
.SYNOPSIS | ||
A PowerShell function for writing specified messages to a log file. | ||
.DESCRIPTION | ||
Add this function to your script for easy, consitent writes to a log file. | ||
Add this function to your script for easy, consistent writes to a log file. | ||
Writes a specified message to a log file, creating the log file if it does not already exist. | ||
Log entries are date and time stamped using ISO 8601 date format (e.g. 2022-09-02 19:22:00) | ||
Logging is enabled by default unless $script:LoggingEnabled variable is present and set to zero. | ||
|
@@ -14,48 +14,48 @@ Function Write-ToLog { | |
Author : Patrick Cage ([email protected]) | ||
Version : 1.0.4 (2023-04-16) | ||
License : GNU General Public License (GPL) v3 | ||
.PARAMETER Message | ||
<string> [Required] The message to be written to the log file | ||
.PARAMETER Severity | ||
<string> [Optional] The severity of the message being written | ||
Valid values: DEBUG, INFO, WARNING, ERROR | ||
.PARAMETER Tag | ||
<string> [Optional] The Tag to be added to the logged message | ||
.PARAMETER LogFile | ||
<System.IO.FileInfo> [Optional] The full path of the log file to be written to | ||
If not specified when calling the function or in the calling script, | ||
a file will be created within a LOGS folder inside the scripts parent folder. | ||
If the scripts parent folder path can't be obtained, it will fall back to C:\LOGS | ||
.EXAMPLE | ||
Write-ToLog "This message will be written to the log file" | ||
2022-09-02 19:22:00 : This message will be written to the log file | ||
.EXAMPLE | ||
Write-ToLog "This message will be written to the log file" -LogFile "C:\Path\To\LogFile.txt" | ||
2022-09-02 19:22:00 : This message will be written to the log file | ||
.EXAMPLE | ||
Write-ToLog -Message "This message will be written to the log file" -Severity INFO -Tag "TagValue" | ||
2022-09-02 19:22:00 : INFO: [TagValue] This message will be written to the log file | ||
.EXAMPLE | ||
Write-ToLog -Message "This message will be written to the log file" -Tag "TagValue" | ||
2022-09-02 19:22:00 : [TagValue] This message will be written to the log file | ||
.LINK | ||
https://www.patrickcage.com/write-tolog | ||
.LINK | ||
https://github.com/C493/write-tolog | ||
#> | ||
|
@@ -92,7 +92,7 @@ Function Write-ToLog { | |
} | ||
else { $LogFile = $script:LogFile } | ||
} | ||
|
||
# Create the LogFile path if it doesn't exist | ||
If (!(Test-Path $LogFile -PathType Leaf)) { | ||
Try { | ||
|
@@ -115,4 +115,4 @@ Function Write-ToLog { | |
Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)] ${SeverityLevel}${Tag}${Message}" | ||
} | ||
|
||
Get-Help Write-ToLog -Full | ||
#Get-Help Write-ToLog -Full |