Skip to content
ConsoleMonster
Cmdlet

New-ConsoleLogEntry

Module ConsoleMonster
Inputs
System.Object
Outputs
ConsoleMonster.Widgets.LogEntry

Creates one log line with a level and a time, for New-ConsoleLog.

Syntax

New-ConsoleLogEntry [-At <TimeSpan>] [-Level <String>] [-Message] <Object> [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Creates one log line with a level and a time, for New-ConsoleLog.

Use it inside the script block of New-ConsoleLog to show a log printed once, or pipe a log made earlier to Add-ConsoleItem with these entries. -Level takes info, warn, err, verbose, debug, pass or skip, or PowerShell's words (Information, Warning, Error, Verbose, Debug, Success, Skipped). -At is the time shown at the start of the line: a TimeSpan, a number of seconds, or a number with a unit (500ms, 2s, 1.5m, 1h). The message is shown literally; rich text from New-ConsoleText keeps its colours. In a running dashboard, write to the log with Write-ConsoleLog instead.

Examples

Authored help example

EXAMPLE 1

New-ConsoleLog -Height 5 {
    New-ConsoleLogEntry 'Discovered 4 domain controllers in 2 domains' -Level Info -At 2s
    New-ConsoleLogEntry 'DC02: replication partner DC05 last success 3h ago' -Level Warning -At 31s
    New-ConsoleLogEntry 'DC02: USN rollback check failed (event 2095)' -Level Error -At 44s
} | Write-ConsoleWidget

A short log printed once

EXAMPLE 2

$events = Import-Csv deploy-events.csv
New-ConsoleLog {
    foreach ($event in $events) { New-ConsoleLogEntry $event.Message -Level $event.Level -At $event.Seconds }
} | Write-ConsoleWidget

Entries from objects

Parameters

-At TimeSpan optional
The time shown at the start of the line: a TimeSpan, seconds (2 or 1.5) or a number with a unit (500ms, 2s, 1.5m, 1h). Default 0.
-Level String optional
The level: info, warn, err, verbose, debug, pass or skip, or PowerShell's words (Information, Warning, Error, Verbose, Debug, Success, Skipped). Default info.
-Message Object requiredposition: 0pipeline: True (ByValue)
The message (shown literally; rich text from New-ConsoleText keeps its colours).

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.