Skip to content

Commit 41895aa

Browse files
committed
Add tag support to console logging messages
Log messages now include tags if provided, formatted as a comma-separated list in square brackets before the message. This enhances log clarity by associating tags directly with their messages.
1 parent 94c0207 commit 41895aa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Modules/CIPPCore/Public/Tools/Enable-CippConsoleLogging.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ function Enable-CippConsoleLogging {
5757
if ($PSBoundParameters.ContainsKey('MessageData') -and $MessageData) {
5858
# Send to telemetry
5959
if (-not [string]::IsNullOrWhiteSpace(($MessageData | Out-String).Trim())) {
60-
Send-CippConsoleLog -Message ($MessageData | Out-String).Trim() -Level 'Information'
60+
# If tag is supplied, include it in the log message
61+
$LogMessage = if ($Tags -and $Tags.Count -gt 0) {
62+
'[{0}] {1}' -f ($Tags -join ','), ($MessageData | Out-String).Trim()
63+
} else {
64+
($MessageData | Out-String).Trim()
65+
}
66+
Send-CippConsoleLog -Message $LogMessage -Level 'Information'
6167
}
6268

6369
# Call original function

0 commit comments

Comments
 (0)