|
1 | 1 | PowerShellLoggingModule
|
2 | 2 | =======================
|
3 |
| -Uses Reflection to intercept text output headed for the PowerShell |
4 |
| -console or ISE. Lines of output are sent to any number of |
5 |
| -subscriber objects for the purpose of producing complete log files |
6 |
| -of script output (including date/timestamps) without the need for |
7 |
| -extra code by the script author. |
| 3 | +Uses Reflection to intercept text output headed for the PowerShell console. |
| 4 | +All lines of output are sent to any number of subscriber objects |
| 5 | +producing complete log files of script output (adding date/timestamps) |
| 6 | +without needing extra code by the script author. |
8 | 7 |
|
9 |
| -The source code is maintained on GitHub. If you would like to use |
10 |
| -the module but can't compile it yourself, you can install it with |
11 |
| -PowerShellGet: |
| 8 | +The upside is that any text which would have shown up in the console is logged, |
| 9 | +and the downside is that only that text is logged. |
| 10 | +For example, verbose output is only logged if VerbosePreference is Continue... |
| 11 | + |
| 12 | + |
| 13 | +Supports PowerShell 2, 3, 4, 5, 6 and 7 |
| 14 | + |
| 15 | + |
| 16 | +Install from the PowerShell Gallery |
| 17 | +================================== |
12 | 18 |
|
13 | 19 | ```posh
|
14 | 20 | Install-Module PowerShellLogging
|
15 | 21 | ```
|
16 | 22 |
|
17 |
| -Or download a zip file of the module from: |
| 23 | +Compile your own copy |
| 24 | +==================== |
| 25 | + |
| 26 | +You can run `build.ps1` to assembly a copy in an `Output` folder, |
| 27 | +or you can just compile the assembly with: |
| 28 | + |
| 29 | +```posh |
| 30 | +dotnet build -c Release |
| 31 | +``` |
| 32 | + |
| 33 | +Testing |
| 34 | +======= |
| 35 | + |
| 36 | +The test cases are very minimal (basically just covering the fact that it logs, and testing a couple of edge cases where it used to fail to log). Despite that, weand have some problems due to the way that WindowsPowerShell breaks when they fail. |
| 37 | + |
| 38 | + As a result, _to be sure that the tests are actually working_ (reporting the correct results), you should run each test case in a new session. There is a wrapper script `test.ps1` which you can use to do that, it basically just runs each test case in `PowerShell` and `pwsh` to ensure everything is working in both WindowsPowerShell and PowerShell core. E.g.: |
| 39 | + |
| 40 | +``` |
| 41 | +foreach ($testcase in Get-ChildItem Tests\*.Tests.ps1) { |
| 42 | + powershell -NoProfile -Command Invoke-Pester $testcase.FullName |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +Alternative Download |
| 47 | +=================== |
| 48 | + |
| 49 | +Note, the original version is also available from: |
18 | 50 |
|
19 | 51 | http://gallery.technet.microsoft.com/scriptcenter/Enhanced-Script-Logging-27615f85
|
0 commit comments