Skip to content

Commit

Permalink
Update TUN.Logging to version 1.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
echalone committed Aug 3, 2023
1 parent 76c163a commit 57bf3e2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 62 deletions.
3 changes: 2 additions & 1 deletion PowerShell/Modules/TUN.Logging/TUN.Logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ V 1.1.1: Bugfixing fallback color<br/>
V 1.1.2: Updated markdown help and added examples<br/>
V 1.1.3: Changed output of error messages slightly to show more error details<br/>
V 1.1.4: Bumped version number in markdown readme<br/>
V 1.1.7: Only initialize script-wide logging variables if they haven''t already been initialized by another logging module import from a parent script/call<br/>

### Required Modules
* TUN.Credentials (1.1.0)
Expand Down Expand Up @@ -394,7 +395,7 @@ PARAM
)
# Import the logging module
Import-Module "TUN.Logging" -Force
Import-Module "TUN.Logging"
try {
# Start the file logging in the current directory, with computer name, script name and current date all present in the log-filename
Expand Down
8 changes: 5 additions & 3 deletions PowerShell/Modules/TUN.Logging/TUN.Logging.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Markus Szumovski
#
# Generated on: 27.07.2023
# Generated on: 01.08.2023
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'TUN.Logging.psm1'

# Version number of this module.
ModuleVersion = '1.1.4'
ModuleVersion = '1.1.8'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -126,7 +126,9 @@ V 1.1.0: Bugfixes for Linux, now compatible with Linux Powershell Core
V 1.1.1: Bugfixing fallback color
V 1.1.2: Updated markdown help and added examples
V 1.1.3: Changed output of error messages slightly to show more error details
V 1.1.4: Bumped version number in markdown readme'
V 1.1.4: Bumped version number in markdown readme
V 1.1.7: Only initialize script-wide logging variables if they haven''''t already been initialized by another logging module import from a parent script/call
V 1.1.8: Removed -Force switch from import example'

# Prerelease string of this module
# Prerelease = ''
Expand Down
118 changes: 60 additions & 58 deletions PowerShell/Modules/TUN.Logging/TUN.Logging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,66 @@ Set-StrictMode -Version Latest

Import-Module "TUN.Credentials" -Force

$script:CmdletSupport_AddContent_NoNewline = $false # tells us if the Add-Content cmdlet supports the NoNewline parameter
$script:WhatIfLog = $false # tells us if the -WhatIf switch is set
$script:LogFile = $null # Path to the logfile
$script:LogMailCredentialFile = $null # Path to the credential file for smtp server authentication (in case of mail log sending)
$script:LogMailText = "" # The stored text for the mail log
$script:LogRunning = $false # Is logging in process?
$script:LogMailRunning = $false # Is logging to mail log in process?
$script:LogPreference_NoTimestamp = $false # Should timestamps for the log-file be omitted?
$script:LogPreference_AsOutput = $false # Should the log file contain whatever the output contains (or everything=$false)?
$script:LogPreference_MailAsOutput = $false # Should the mail log contain whatever the output contains (or everything=$false)?
$script:LogPreference_FallbackForegroundColor = ` # Fallback color for foreground color if it is not possible to retrieve the information from the console
[ConsoleColor]::Gray
$script:LogPreference_FallbackBackgroundColor = ` # Fallback color for background color if it is not possible to retrieve the information from the console
[ConsoleColor]::Black

[Nullable[bool]] $script:LogPreference_MailError = $null # Should errors be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailHost = $null # Should host messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailOutput = $null # Should output messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailVerbose = $null # Should verbose messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailWarning = $null # Should warnings be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailDebug = $null # Should debug messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailInformation = $null # Should information be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)

[Nullable[bool]] $script:LogPreference_LogError = $null # Should errors be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogHost = $null # Should host messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogOutput = $null # Should output messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogVerbose = $null # Should verbose messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogWarning = $null # Should warnings be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogDebug = $null # Should debug messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogInformation = $null # Should information be logged? ($null...either always or as output if -AsOutput switch is set)

$script:ErrorMailCount = 0 # how often has an error been saved for mail log sending?
$script:HostMailCount = 0 # how often has a host message been saved for mail log sending?
$script:OutputMailCount = 0 # how often has an output message been saved for mail log sending?
$script:VerboseMailCount = 0 # how often has a verbose message been saved for mail log sending?
$script:WarningMailCount = 0 # how often has a warning been saved for mail log sending?
$script:DebugMailCount = 0 # how often has a debug message been saved for mail log sending?
$script:InformationMailCount = 0 # how often has an information been saved for mail log sending?

$script:ErrorLogCount = 0 # how often has an error been logged to the file?
$script:HostLogCount = 0 # how often has a host message been logged to the file?
$script:OutputLogCount = 0 # how often has an output message been logged to the file?
$script:VerboseLogCount = 0 # how often has a verbose message been logged to the file?
$script:WarningLogCount = 0 # how often has a warning been logged to the file?
$script:DebugLogCount = 0 # how often has a debug message been logged to the file?
$script:InformationLogCount = 0 # how often has an information been logged to the file?

$script:ForceLogSend = $false # stores if mail log should be sent forcefully
$script:ForceLogReason = "" # stores a reason for forced mail log sending

$script:ScriptInfo_Retrieved = $false # determines if information about the executing main scriptfile has already been retrieved
$script:ScriptInfo_Call = $null # The line with which the executing main scriptfile was called
$script:ScriptInfo_Path = $null # The path to the executing main scriptfile
$script:ScriptInfo_File = $null # The filename of the executing main scriptfile
$script:ScriptInfo_Name = $null # The filename without extension of the executing main scriptfile
$script:ScriptInfo_Version = $null # The version of the executing main scriptfile
$script:ScriptInfo_CurrentUser = $null # The user context at the start of logging
$script:ScriptInfo_ComputerName = $null # The machine name at the start of logging
if(!(Test-Path variable:script:LogRunning)) {
$script:CmdletSupport_AddContent_NoNewline = $false # tells us if the Add-Content cmdlet supports the NoNewline parameter
$script:WhatIfLog = $false # tells us if the -WhatIf switch is set
$script:LogFile = $null # Path to the logfile
$script:LogMailCredentialFile = $null # Path to the credential file for smtp server authentication (in case of mail log sending)
$script:LogMailText = "" # The stored text for the mail log
$script:LogRunning = $false # Is logging in process?
$script:LogMailRunning = $false # Is logging to mail log in process?
$script:LogPreference_NoTimestamp = $false # Should timestamps for the log-file be omitted?
$script:LogPreference_AsOutput = $false # Should the log file contain whatever the output contains (or everything=$false)?
$script:LogPreference_MailAsOutput = $false # Should the mail log contain whatever the output contains (or everything=$false)?
$script:LogPreference_FallbackForegroundColor = ` # Fallback color for foreground color if it is not possible to retrieve the information from the console
[ConsoleColor]::Gray
$script:LogPreference_FallbackBackgroundColor = ` # Fallback color for background color if it is not possible to retrieve the information from the console
[ConsoleColor]::Black

[Nullable[bool]] $script:LogPreference_MailError = $null # Should errors be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailHost = $null # Should host messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailOutput = $null # Should output messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailVerbose = $null # Should verbose messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailWarning = $null # Should warnings be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailDebug = $null # Should debug messages be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_MailInformation = $null # Should information be sent in the log mail? ($null...either always or as output if -AsOutput switch is set)

[Nullable[bool]] $script:LogPreference_LogError = $null # Should errors be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogHost = $null # Should host messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogOutput = $null # Should output messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogVerbose = $null # Should verbose messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogWarning = $null # Should warnings be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogDebug = $null # Should debug messages be logged? ($null...either always or as output if -AsOutput switch is set)
[Nullable[bool]] $script:LogPreference_LogInformation = $null # Should information be logged? ($null...either always or as output if -AsOutput switch is set)

$script:ErrorMailCount = 0 # how often has an error been saved for mail log sending?
$script:HostMailCount = 0 # how often has a host message been saved for mail log sending?
$script:OutputMailCount = 0 # how often has an output message been saved for mail log sending?
$script:VerboseMailCount = 0 # how often has a verbose message been saved for mail log sending?
$script:WarningMailCount = 0 # how often has a warning been saved for mail log sending?
$script:DebugMailCount = 0 # how often has a debug message been saved for mail log sending?
$script:InformationMailCount = 0 # how often has an information been saved for mail log sending?

$script:ErrorLogCount = 0 # how often has an error been logged to the file?
$script:HostLogCount = 0 # how often has a host message been logged to the file?
$script:OutputLogCount = 0 # how often has an output message been logged to the file?
$script:VerboseLogCount = 0 # how often has a verbose message been logged to the file?
$script:WarningLogCount = 0 # how often has a warning been logged to the file?
$script:DebugLogCount = 0 # how often has a debug message been logged to the file?
$script:InformationLogCount = 0 # how often has an information been logged to the file?

$script:ForceLogSend = $false # stores if mail log should be sent forcefully
$script:ForceLogReason = "" # stores a reason for forced mail log sending

$script:ScriptInfo_Retrieved = $false # determines if information about the executing main scriptfile has already been retrieved
$script:ScriptInfo_Call = $null # The line with which the executing main scriptfile was called
$script:ScriptInfo_Path = $null # The path to the executing main scriptfile
$script:ScriptInfo_File = $null # The filename of the executing main scriptfile
$script:ScriptInfo_Name = $null # The filename without extension of the executing main scriptfile
$script:ScriptInfo_Version = $null # The version of the executing main scriptfile
$script:ScriptInfo_CurrentUser = $null # The user context at the start of logging
$script:ScriptInfo_ComputerName = $null # The machine name at the start of logging
}

function Coalesce
{
Expand Down

0 comments on commit 57bf3e2

Please sign in to comment.