Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions IISParser.PowerShell/AsyncPSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@

namespace IISParser.PowerShell;

/// <summary>
/// Base class for asynchronous PowerShell cmdlets that exposes asynchronous equivalents
/// of the standard <see cref="PSCmdlet"/> lifecycle methods.
/// </summary>
/// <summary>Provides asynchronous execution support for cmdlets.</summary>
/// <para>Derived classes override asynchronous lifecycle methods to interact with the PowerShell pipeline without blocking.</para>
/// <list type="alertSet">
/// <item>
/// <term>Note</term>
/// <description>Override <c>BeginProcessingAsync</c>, <c>ProcessRecordAsync</c>, and <c>EndProcessingAsync</c> instead of their synchronous counterparts.</description>
/// </item>
/// </list>
/// <seealso href="https://learn.microsoft.com/powershell/developer/cmdlet/cmdlet-overview" />
/// <seealso href="https://github.com/EvotecIT/IISParser" />
public abstract class AsyncPSCmdlet : PSCmdlet, IDisposable {
private readonly CancellationTokenSource _cancelSource = new();

Expand Down
46 changes: 28 additions & 18 deletions IISParser.PowerShell/CmdletGetIISParsedLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,53 @@

namespace IISParser.PowerShell;

/// <summary>
/// PowerShell cmdlet that parses an IIS log file and returns the parsed entries.
/// </summary>
/// <summary>Parses entries from an IIS log file.</summary>
/// <para>Reads the specified log and converts each record into a PowerShell object for further processing.</para>
/// <para>Use filtering parameters to limit the number of events returned.</para>
/// <list type="alertSet">
/// <item>
/// <term>Note</term>
/// <description>The cmdlet loads the entire log into memory before applying filters, which may impact large files.</description>
/// </item>
/// </list>
/// <example>
/// <summary>Parse an entire log file.</summary>
/// <prefix>PS&gt; </prefix>
/// <code>Get-IISParsedLog -FilePath "C:\\Logs\\u_ex230101.log"</code>
/// <para>Outputs all entries from the specified log.</para>
/// </example>
/// <example>
/// <summary>Retrieve a subset of entries.</summary>
/// <prefix>PS&gt; </prefix>
/// <code>Get-IISParsedLog -FilePath "C:\\Logs\\u_ex230101.log" -Skip 10 -First 5</code>
/// <para>Skips the first ten lines and returns the next five.</para>
/// </example>
/// <seealso href="https://learn.microsoft.com/iis/configuration/system.webserver/httplogging" />
/// <seealso href="https://github.com/EvotecIT/IISParser" />
[Cmdlet(VerbsCommon.Get, "IISParsedLog", DefaultParameterSetName = "Default")]
public class CmdletGetIISParsedLog : AsyncPSCmdlet {
private ParserEngine? _parser;

/// <summary>
/// Gets or sets the path to the IIS log file.
/// </summary>
/// <summary>Path to the IIS log file.</summary>
[Parameter(Mandatory = true, ParameterSetName = "Default")]
[Parameter(Mandatory = true, ParameterSetName = "FirstLastSkip")]
[Parameter(Mandatory = true, ParameterSetName = "SkipLast")]
[Alias("LogPath")]
public string FilePath { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the number of records to take from the start of the log.
/// </summary>
/// <summary>Selects the first number of log entries to return.</summary>
[Parameter(ParameterSetName = "FirstLastSkip")]
public int? First { get; set; }

/// <summary>
/// Gets or sets the number of records to take from the end of the log.
/// </summary>
/// <summary>Returns only the last number of log entries.</summary>
[Parameter(ParameterSetName = "FirstLastSkip")]
public int? Last { get; set; }

/// <summary>
/// Gets or sets the number of records to skip from the start of the log.
/// </summary>
/// <summary>Skips a specified number of entries from the start.</summary>
[Parameter(ParameterSetName = "FirstLastSkip")]
public int? Skip { get; set; }

/// <summary>
/// Gets or sets the number of records to skip from the end of the log.
/// </summary>
/// <summary>Omits a specified number of entries from the end.</summary>
[Parameter(ParameterSetName = "SkipLast")]
public int? SkipLast { get; set; }

Expand Down
1 change: 1 addition & 0 deletions IISParser.PowerShell/IISParser.PowerShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<PropertyGroup>
<!-- This is needed for XmlDoc2CmdletDoc to generate a PowerShell documentation file. -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<XmlDoc2CmdletDocArguments>-strict</XmlDoc2CmdletDocArguments>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading