GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - PoshCode/PowerShellLogging

BranchesTags
Open more actions menu

Latest commit

 

History

60 Commits
60 Commits

Folders and files

NameName
Last commit message
Last commit date
Commands
Commands
 
 
Module/PowerShellLogging
Module/PowerShellLogging
 
 
Tests
Tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
Build.ps1
Build.ps1
 
 
HostIOInterceptor.cs
HostIOInterceptor.cs
 
 
HostIOSubscriberBase.cs
HostIOSubscriberBase.cs
 
 
IHostIOSubscriber.cs
IHostIOSubscriber.cs
 
 
LICENSE
LICENSE
 
 
LogFile.cs
LogFile.cs
 
 
PowerShellLoggingModule.csproj
PowerShellLoggingModule.csproj
 
 
PowerShellLoggingModule.sln
PowerShellLoggingModule.sln
 
 
README.md
README.md
 
 
ScriptBlockOutputSubscriber.cs
ScriptBlockOutputSubscriber.cs
 
 
StreamType.cs
StreamType.cs
 
 
Test.ps1
Test.ps1
 
 

Repository files navigation

PowerShellLoggingModule

Uses Reflection to intercept text output headed for the PowerShell console. All lines of output are sent to any number of subscriber objects producing complete log files of script output (adding date/timestamps) without needing extra code by the script author.

The upside is that any text which would have shown up in the console is logged, and the downside is that only that text is logged. For example, verbose output is only logged if VerbosePreference is Continue...

Supports PowerShell 2, 3, 4, 5, 6 and 7

Install from the PowerShell Gallery

Install-Module PowerShellLogging

Compile your own copy

You can compile the assembly with:

dotnet build -c Release

To generate the full module, you can run the build script:

.\build -Version $(gitversion -showvariable nugetversion)

Note: this script builds into a version numbered folder in the module root. The expectation is that you have the source in a folder like ~\Projects\Modules\PowerShellLogging where the parent folder can be added to your PSModulePath for testing purposes, so the build will end up in, e.g.: ~\Projects\Modules\PowerShellLogging\1.4.0 and the build script will update the metadata to make it all versioned properly!

Testing

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.

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.:

foreach ($testcase in Get-ChildItem Tests\*.Tests.ps1) {
    powershell -NoProfile -Command Invoke-Pester $testcase.FullName
}

Alternative Download

Note, the original version is also available from:

http://gallery.technet.microsoft.com/scriptcenter/Enhanced-Script-Logging-27615f85

About

No description, website, or topics provided.

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.