Skip to content

Add-PodeLogType

SYNOPSIS

Adds a custom Log Type for parsing custom log items.

SYNTAX

ScriptBlock (Default)

Add-PodeLogType -Name <String> -Method <String[]> -ScriptBlock <ScriptBlock> [-Levels <String[]>]
 [-ArgumentList <Object[]>] [-Version <Int32>] [-LogFormat <PodeLogFormat>] [-LogScriptBlock <ScriptBlock>]
 [-SerialiseFormat <PodeSerialiseFormat>] [-SerialiseScriptBlock <ScriptBlock>] [-SyslogInfo <Hashtable>]
 [-XmlRootName <String>] [-Metadata <Hashtable>] [-LogHeader <String[]>] [-AsUtc]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

Raw

Add-PodeLogType -Name <String> -Method <String[]> [-Levels <String[]>] [-LogFormat <PodeLogFormat>]
 [-LogScriptBlock <ScriptBlock>] [-SerialiseFormat <PodeSerialiseFormat>] [-SerialiseScriptBlock <ScriptBlock>]
 [-SyslogInfo <Hashtable>] [-XmlRootName <String>] [-Metadata <Hashtable>] [-LogHeader <String[]>] [-AsUtc]
 [-Raw] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Adds a custom Log Type for parsing custom log items.

EXAMPLES

EXAMPLE 1

New-PodeLogTerminalMethod | Add-PodeLogType -Name 'LogTypeName' -ScriptBlock { /* logic */ }

EXAMPLE 2

New-PodeLogTerminalMethod | Add-PodeLogType -Name 'LogTypeName' -Raw

EXAMPLE 3

New-PodeLogTerminalMethod | Add-PodeLogType -Name 'LogTypeName' -SerialiseFormat 'Json'

EXAMPLE 4

New-PodeLogTerminalMethod | Add-PodeLogType -Name 'LogTypeName' -SerialiseFormat 'Custom' -SerialiseScriptBlock {
    param($data)
    return $data | ConvertTo-PodeString
}

PARAMETERS

-ArgumentList

An array of arguments to supply to the Custom Log Type's ScriptBlock and SerialiseScriptBlock.

Type: Object[]
Parameter Sets: ScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AsUtc

If supplied, will be set in the Log Type's Formatting Options as to whether to use UTC timestamps or local timestamps.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Levels

The Levels of log items that should be logged. (Default: Informational)

Type: String[]
Parameter Sets: (All)
Aliases: Level

Required: False
Position: Named
Default value: @('Informational')
Accept pipeline input: False
Accept wildcard characters: False

-LogFormat

The format to use for the log output. (Default: Server default, or 'None' if no default set).

Type: PodeLogFormat
Parameter Sets: (All)
Aliases:
Accepted values: None, Custom, Syslog

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-LogHeader

An optional array of strings to use as the header(s) for the log, such as W3C log directives.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-LogScriptBlock

A ScriptBlock to use for custom log formatting of the log entry.

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Metadata

A hashtable of metadata to associate with the Log Type. This data can be retrieved via Get-PodeLogType.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Method

The Log Method ID to use for outputting the log entry.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Name

A unique Name for the Log Type.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Raw

If supplied, the log item returned will be the raw Request item as a hashtable and not a string.

Type: SwitchParameter
Parameter Sets: Raw
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ScriptBlock

The ScriptBlock defining logic that transforms an item, and returns it for outputting.

Type: ScriptBlock
Parameter Sets: ScriptBlock
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SerialiseFormat

Specifies the format to use for serialising the log entry. (Default: Server default, or 'None' if no default set).

Type: PodeSerialiseFormat
Parameter Sets: (All)
Aliases:
Accepted values: None, Custom, Json, Xml, Yaml

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SerialiseScriptBlock

A ScriptBlock defining custom logic for serialising the log data.

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SyslogInfo

A hashtable containing Syslog configuration information, built using New-PodeSyslogInfo.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Version

The version of the Log Type, this determines the arguments which are supplied to the ScriptBlock. (Default: 1) Arguments supplied depending on the version:

  • Version 1: Log Event Data, ArgumentList
  • Version 2: Log Event, ArgumentList

Under Version 2, the "Log Event" contains references to the log event's data, level, timestamp, and metadata.

Type: Int32
Parameter Sets: ScriptBlock
Aliases:

Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False

-XmlRootName

An optional name to use for the root element of the log item when serialising to XML.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES