Skip to content

Commit

Permalink
Logging commands - converted to cmdlets
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Jul 14, 2021
1 parent 4369e1a commit 0096aa7
Show file tree
Hide file tree
Showing 11 changed files with 962 additions and 325 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -25,3 +25,6 @@ bld/

//
src/bin/Thycotic.SecretServer.dll
src/bin/Thycotic.SecretServer.deps.json
src/bin/Thycotic.SecretServer.xml
src/bin/Thycotic.SecretServer.pdb
42 changes: 27 additions & 15 deletions docs/commands/logging/Start-TssLog.md
@@ -1,68 +1,76 @@
---
external help file: Thycotic.SecretServer.dll-Help.xml
Module Name: Thycotic.SecretServer
schema: 2.0.0
---

# Start-TssLog

## SYNOPSIS
Creates a new log file with header information
Creates an initial log file with a header.

## SYNTAX

```
Start-TssLog [[-LogFormat] <String>] [[-LogFilePath] <String>] [[-ScriptVersion] <String>] [<CommonParameters>]
Start-TssLog [[-LogFilePath] <String>] [[-LogFormat] <String>] [[-ScriptVersion] <String>] [<CommonParameters>]
```

## DESCRIPTION
{{ Fill in the Description }}
Creates a log file (will delete if the name already exists) and adds a formatted header.

## EXAMPLES

### Example 1
```powershell
PS C:\> {{ Add example code here }}
$newLog = New-TemporaryFile
Start-TssLog -LogFilePath $newLog.FullName -ScriptVersion '1.0.4'
```

{{ Add example description here }}
Generate a new temporary file to use as a log, writing Script version of 1.0.4.

## PARAMETERS

### -LogFormat
Format of log to generate, default to LOG; allowed: log, csv, json, xml, cmtrace
### -LogFilePath
Full file path to the log file to create

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: Log
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -LogFilePath
Exact log path and filename to use
### -LogFormat
Format of log to generate, default to LOG; allowed: log, csv

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: log, csv

Required: False
Position: 2
Default value: None
Position: 1
Default value: Log
Accept pipeline input: False
Accept wildcard characters: False
```

### -ScriptVersion
Reference for use with your scripts
Script Version to include as reference in the log file header

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -78,3 +86,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

[https://thycotic-ps.github.io/thycotic.secretserver/commands/logging/Start-TssLog](https://thycotic-ps.github.io/thycotic.secretserver/commands/logging/Start-TssLog)

[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/Thycotic.SecretServer/cmdlets/logging/StartLogCmdlet.cs](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/Thycotic.SecretServer/cmdlets/logging/StartLogCmdlet.cs)
37 changes: 24 additions & 13 deletions docs/commands/logging/Stop-TssLog.md
@@ -1,54 +1,61 @@
---
external help file: Thycotic.SecretServer.dll-Help.xml
Module Name: Thycotic.SecretServer
schema: 2.0.0
---

# Stop-TssLog

## SYNOPSIS
Write closing data to log file & exits the calling script
Adds footer to the end of the log file.

## SYNTAX

```
Stop-TssLog [[-LogFormat] <String>] [[-LogFilePath] <String>] [<CommonParameters>]
Stop-TssLog [[-LogFilePath] <String>] [[-LogFormat] <String>] [<CommonParameters>]
```

## DESCRIPTION
{{ Fill in the Description }}
Appends a footer to the log file to "close" the logging process. This should be called at the end of your script or workflow.

## EXAMPLES

### Example 1
```powershell
PS C:\> {{ Add example code here }}
Stop-TssLog -LogFilePath $newLog.FullName
```

{{ Add example description here }}
Log file from the Start-TssLog call passed in and footer written to the file.

## PARAMETERS

### -LogFormat
Format of log to generate, default to LOG; allowed: log, csv, json, xml, cmtrace
### -LogFilePath
Full file path to the log file to create

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: Log
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -LogFilePath
Exact log path and filename to use
### -LogFormat
Format of log to generate, default to LOG; allowed: log, csv

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: log, csv

Required: False
Position: 2
Default value: None
Position: 1
Default value: Log
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -63,3 +70,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

[https://thycotic-ps.github.io/thycotic.secretserver/commands/logging/Stop-TssLog](https://thycotic-ps.github.io/thycotic.secretserver/commands/logging/Stop-TssLog)

[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/Thycotic.SecretServer/cmdlets/logging/StopLogCmdlet.cs](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/Thycotic.SecretServer/cmdlets/logging/StopLogCmdlet.cs)
99 changes: 70 additions & 29 deletions docs/commands/logging/Write-TssLog.md
@@ -1,100 +1,137 @@
---
external help file: Thycotic.SecretServer.dll-Help.xml
Module Name: Thycotic.SecretServer
schema: 2.0.0
---

# Write-TssLog

## SYNOPSIS
Writes a message to specified log file
Writes message to the log file.

## SYNTAX

### message
```
Write-TssLog [-LogFilePath] <String> [-LogFormat] <String> [-MessageType] <String> [[-Message] <String>]
[<CommonParameters>]
```

### divider
```
Write-TssLog [[-LogFormat] <String>] [[-LogFilePath] <String>] [[-MessageType] <String>] [[-Message] <String>]
[-Divider] [<CommonParameters>]
Write-TssLog [-LogFilePath] <String> [-LogFormat] <String> [-MessageType] <String> [-Divider]
[[-DividerCharacter] <String>] [<CommonParameters>]
```

## DESCRIPTION
{{ Fill in the Description }}
Writes the message provided by appending. This is used during your script process or workflow to add messages based on the MessageType desired (error, warning, info, etc.).

## EXAMPLES

### Example 1
```powershell
PS C:\> {{ Add example code here }}
Write-TssLog -LogFilePath $newLog.FullName -LogFormat 'log' -MessageType ERROR -Message "Issue capturing secret details: $($_.Exception)"
```

{{ Add example description here }}
Appends an informational message including an error's exception (added to the catch block of a call to a function) using LOG format.

### Example 2
```powershell
Write-TssLog -LogFilePath $newLog.FullName -LogFormat 'csv' -MessageType ERROR -Message "Issue capturing secret details: $($_.Exception)"
```

Appends an informational message including an error's exception (added to the catch block of a call to a function) using CSV format.

## PARAMETERS

### -LogFormat
Format of log to generate, default to LOG; allowed: log, csv, json, xml, cmtrace
### -Divider
Switch to indicate a divider is appended to the log file.

```yaml
Type: SwitchParameter
Parameter Sets: divider
Aliases:

Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -DividerCharacter
The character to use for the divider, autogenerates 120-character divider and append to the log file. Defaults to plus-sign (+)

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: divider
Aliases:

Required: False
Position: 1
Default value: Log
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -LogFilePath
Exact log path and filename to use
Full file path to the log file

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -MessageType
Message type, default INFO; allowed: INFO, WARNING, ERROR, FATAL
### -LogFormat
Format of log to generate, default to LOG; allowed: log, csv

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: log, csv

Required: False
Position: 3
Default value: INFO
Required: True
Position: 1
Default value: Log
Accept pipeline input: False
Accept wildcard characters: False
```

### -Message
Message content to write to file
Message to append to the log

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: message
Aliases:

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

### -Divider
Character divider will be added to file as INFO message, using plus sign (+)
### -MessageType
Message type to write to the log, default INFO (allowed INFO, WARNING, ERROR, FATAL)

```yaml
Type: SwitchParameter
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: INFO, WARNING, ERROR, FATAL

Required: False
Position: Named
Default value: False
Required: True
Position: 2
Default value: INFO
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -109,3 +146,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

[https://thycotic-ps.github.io/thycotic.secretserver/commands/logging/Write-TssLog](https://thycotic-ps.github.io/thycotic.secretserver/commands/logging/Write-TssLog)

[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/Thycotic.SecretServer/cmdlets/logging/WriteLogCmdlet.cs](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/Thycotic.SecretServer/cmdlets/logging/WriteLogCmdlet.cs)

0 comments on commit 0096aa7

Please sign in to comment.