functions/Get-DbatoolsLog.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Get-DbatoolsLog {
    <#
    .SYNOPSIS
    Returns log entries for dbatools
 
    .DESCRIPTION
    Returns log entries for dbatools. Handy when debugging or developing for it. Also used when preparing a support package.
 
    .PARAMETER Errors
    Instead of log entries, the error entries will be retrieved
 
    .NOTES
    Author: Fred Weinmann (@FredWeinmann)
    Tags: Debug
 
    Website: https://dbatools.io
    Copyright: (C) Chrissy LeMaire, clemaire@gmail.com
    License: MIT https://opensource.org/licenses/MIT
 
    .LINK
    https://dbatools.io/Get-DbatoolsLog
 
    .EXAMPLE
    Get-DbatoolsLog
 
    Returns all log entries currently in memory.
    #>

    [CmdletBinding()]
    param
    (
        [switch]
        $Errors
    )

    BEGIN {
        # No Write-Message, since that would clutter the very log you want to retrieve
    }

    PROCESS {
        if ($Errors) { return [Sqlcollaborative.Dbatools.dbaSystem.DebugHost]::GetErrors() }
        else { return [Sqlcollaborative.Dbatools.dbaSystem.DebugHost]::GetLog() }
    }

    END {

    }
}