Skip to content

Commit 4a18212

Browse files
authored
Merge pull request #71 from geekwhocodes/dev
Release v2
2 parents cf9013d + cbfeafd commit 4a18212

26 files changed

+1199
-4
lines changed

Examples/ExtProvider/ExtProvider.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function ExtProvider {
1414
[object]
1515
$Config
1616
)
17+
$null = $Config
1718
$InformationPreference = "Continue"
1819
$logMessage = "$((Get-Date).ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss:ffff tt")) $Name $($Level): $($Message.Trim())"
1920

ExamplesV2/ExtProvider/ExtProvider.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function ExtProvider {
1414
[object]
1515
$Config
1616
)
17+
18+
$null = $Config
1719
$InformationPreference = "Continue"
1820
$logMessage = "$((Get-Date).ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss:ffff tt")) $Name $($Level): $($Message.Trim())"
1921

ExamplesV2/vanilla.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ $SimplePSLoggerConfig = @{
1919
New-SimplePSLogger -Name "vanilla-script" -Configuration $SimplePSLoggerConfig
2020
}
2121
#New-SimplePSLogger -Name "vanilla-script"
22-
$rt = New-SimplePSLogger -Name "vanilla-script-2" -Configuration $SimplePSLoggerConfig
23-
22+
New-SimplePSLogger -Name "vanilla-script-2" -Configuration $SimplePSLoggerConfig
2423
Set-SimplePSLogger -Name "vanilla-script"
2524
# Get-Process | Select-Object -Property @{
2625
# label = 'Message';

SimplePSLogger/SimplePSLogger.AzLogAnalytics/SimplePSLogger.AzLogAnalytics.psm1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Function New-AzLogAnalytics-Logger {
143143
New-Item $bufferFileName -ItemType file
144144
}
145145

146-
$currentBufferSize = Get-Content $bufferFileName | Measure-Object Line
146+
$currentBufferSize = Get-Content $bufferFileName | Measure-Object -Line
147147
$LogsToFlush = New-Object Collections.Generic.List[Object]
148148

149149
if ($currentBufferSize.Lines -ge $Config["BufferSize"] -or $Flush) {
@@ -196,3 +196,4 @@ Function New-AzLogAnalytics-Logger {
196196
# TODO : is there any way to ignore other functions export?
197197
Export-ModuleMember -Function New-AzLogAnalytics-Logger, Send-LogAnalyticsData, Build-Signature
198198

199+

Tests/ExternalLoggingProvider/ExternalLoggingProvider.psm1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function AwesomeLoggingProvider {
1414
[object]
1515
$Config
1616
)
17+
18+
$null = $Config
19+
1720
$InformationPreference = "Continue"
1821
$logMessage = "$((Get-Date).ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss:ffff tt")) $Name $($Level): $($Message.Trim())"
1922

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
external help file: SimplePSLogger-help.xml
3+
id: clear-buffer
4+
Module Name: SimplePSLogger
5+
online version:
6+
schema: 2.0.0
7+
title: Clear-Buffer
8+
---
9+
10+
## SYNOPSIS
11+
Flush buffered logs
12+
13+
## SYNTAX
14+
15+
```
16+
Clear-Buffer [[-Name] <String>] [-All] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
It's always better to batch your tasks and execute them as one task, it improves performance.
21+
To avoid missing logs.
22+
flush them before exiting your script or flow.
23+
24+
## EXAMPLES
25+
26+
### EXAMPLE 1
27+
```
28+
Clear-Buffer # This flushes buffered logs of DEFAULT LOGGER
29+
Clear-Buffer -Name "my-looger" # This flushes logs of provided logger instance
30+
Clear-Buffer -All # This flushes all buffered logs of all logger instances
31+
```
32+
33+
## PARAMETERS
34+
35+
### -Name
36+
Logger name
37+
38+
```yaml
39+
Type: String
40+
Parameter Sets: (All)
41+
Aliases:
42+
43+
Required: False
44+
Position: 1
45+
Default value: None
46+
Accept pipeline input: True (ByPropertyName)
47+
Accept wildcard characters: False
48+
```
49+
50+
### -All
51+
{{ Fill All Description }}
52+
53+
```yaml
54+
Type: SwitchParameter
55+
Parameter Sets: (All)
56+
Aliases:
57+
58+
Required: False
59+
Position: Named
60+
Default value: False
61+
Accept pipeline input: False
62+
Accept wildcard characters: False
63+
```
64+
65+
### CommonParameters
66+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
67+
68+
## INPUTS
69+
70+
## OUTPUTS
71+
72+
## NOTES
73+
Always clear call this command at the end of your script, usually in finally block
74+
75+
## RELATED LINKS
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
external help file: SimplePSLogger-help.xml
3+
id: get-simplepslogger
4+
Module Name: SimplePSLogger
5+
online version:
6+
schema: 2.0.0
7+
title: Get-SimplePSLogger
8+
---
9+
10+
## SYNOPSIS
11+
Retrieve registred logger instance by name or list all of them
12+
13+
## SYNTAX
14+
15+
```
16+
Get-SimplePSLogger [[-Name] <String>] [-List] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
Retrieve registred logger instance by name or list all of them
21+
22+
## EXAMPLES
23+
24+
### EXAMPLE 1
25+
```
26+
Get-SimplePSLogger -All
27+
```
28+
29+
### EXAMPLE 2
30+
```
31+
Get-SimplePSLogger -Name "my-logger"
32+
```
33+
34+
## PARAMETERS
35+
36+
### -Name
37+
Name of the logger instance .PARAMETER
38+
39+
```yaml
40+
Type: String
41+
Parameter Sets: (All)
42+
Aliases:
43+
44+
Required: False
45+
Position: 1
46+
Default value: None
47+
Accept pipeline input: False
48+
Accept wildcard characters: False
49+
```
50+
51+
### -List
52+
List all logger instances .PARAMETER
53+
54+
```yaml
55+
Type: SwitchParameter
56+
Parameter Sets: (All)
57+
Aliases:
58+
59+
Required: False
60+
Position: Named
61+
Default value: False
62+
Accept pipeline input: False
63+
Accept wildcard characters: False
64+
```
65+
66+
### CommonParameters
67+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
68+
69+
## INPUTS
70+
71+
## OUTPUTS
72+
73+
### Returns Object[] of all logger instances
74+
### Returns [SimplePSLogger]
75+
## NOTES
76+
77+
## RELATED LINKS
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
external help file: SimplePSLogger-help.xml
3+
id: new-simplepslogger
4+
Module Name: SimplePSLogger
5+
online version:
6+
schema: 2.0.0
7+
title: New-SimplePSLogger
8+
---
9+
10+
## SYNOPSIS
11+
Create new SimplePSLogger instance
12+
13+
## SYNTAX
14+
15+
```
16+
New-SimplePSLogger [[-Name] <String>] [[-Configuration] <Object>] [-SetDefault] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
You can create multiple loggers for one action but we recommend creating one single logger for your action
21+
SimplePSLogger logger automatically registers x loggers.
22+
Custom logging provider support will be added soon.
23+
24+
## EXAMPLES
25+
26+
### EXAMPLE 1
27+
```
28+
New-SimplePSLogger -Name "action-1234"
29+
```
30+
31+
### EXAMPLE 2
32+
```
33+
New-SimplePSLogger -Configuration $SimplePSLoggerConfig
34+
```
35+
36+
## PARAMETERS
37+
38+
### -Name
39+
SimplePSLogger name which is used to identify current logger instnace
40+
Examples : your script name, unique task name etc.
41+
It will help you to analyze logs
42+
43+
```yaml
44+
Type: String
45+
Parameter Sets: (All)
46+
Aliases:
47+
48+
Required: False
49+
Position: 1
50+
Default value: None
51+
Accept pipeline input: False
52+
Accept wildcard characters: False
53+
```
54+
55+
### -Configuration
56+
SimplePSLogger configuratoin object, this will contain configurations for supported/reistred providers
57+
Configuration for each provider should be defined by creating new section/key with it's name
58+
59+
Example configuration object :
60+
$SimplePSLoggerConfig = @{
61+
Name = "config-example"
62+
Providers = @{
63+
File = @{
64+
LiteralFilePath = "G:\Git\simple-ps-logger\Examples\example-with-config-file\example-with-config.log"
65+
}
66+
}
67+
}
68+
69+
```yaml
70+
Type: Object
71+
Parameter Sets: (All)
72+
Aliases:
73+
74+
Required: False
75+
Position: 2
76+
Default value: None
77+
Accept pipeline input: False
78+
Accept wildcard characters: False
79+
```
80+
81+
### -SetDefault
82+
Set Default
83+
84+
```yaml
85+
Type: SwitchParameter
86+
Parameter Sets: (All)
87+
Aliases:
88+
89+
Required: False
90+
Position: Named
91+
Default value: False
92+
Accept pipeline input: False
93+
Accept wildcard characters: False
94+
```
95+
96+
### CommonParameters
97+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
98+
99+
## INPUTS
100+
101+
## OUTPUTS
102+
103+
## NOTES
104+
105+
## RELATED LINKS

0 commit comments

Comments
 (0)