Skip to content

New-PodeLogCustomMethod

SYNOPSIS

Create a new Custom Log Method.

SYNTAX

New-PodeLogCustomMethod [-Id <String>] -ScriptBlock <ScriptBlock> [-ArgumentList <Object[]>] [-Version <Int32>]
 [-BatchInfo <Hashtable>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Creates a new Custom Log Method for outputting log items using custom logic defined in a ScriptBlock. Can be used with Enable-PodeLogRequestType, Enable-PodeLogErrorType, or Add-PodeLogType.

EXAMPLES

EXAMPLE 1

$method = New-PodeLogCustomMethod -ScriptBlock { /* logic */ }

EXAMPLE 2

$arguments = @('arg1', 'arg2')
$methodId = New-PodeLogCustomMethod -ScriptBlock { param($args) /* logic using $args */ } -ArgumentList $arguments

EXAMPLE 3

$batchInfo = New-PodeLogBatchInfo -Size 10 -Timeout 10
$methodId = New-PodeLogCustomMethod -ScriptBlock { /* logic */ } -BatchInfo $batchInfo

PARAMETERS

-ArgumentList

An array of arguments to supply to the Custom Logging output method's ScriptBlock.

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

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

-BatchInfo

An optional hashtable containing batch configuration for writing log items in bulk. Should be created using New-PodeLogBatchInfo.

Type: Hashtable
Parameter Sets: (All)
Aliases:

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

-Id

An optional ID to assign to the Log Method. If not supplied, a random ID will be generated.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
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

-ScriptBlock

The ScriptBlock that defines how to output a log item.

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

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

-Version

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

  • Version 1: Transformed Log Items, ArgumentList, Raw Log Items (legacy)
  • Version 2: Log Items, ArgumentList

Under Version 2, the "Log Items" contains references to the transformed and raw log items.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 1
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

System.String

NOTES