aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
241 stars 79 forks source link

Verbose Output switched to debug #31

Closed sheldonhull closed 5 years ago

sheldonhull commented 5 years ago

Currently when trying to debug any scripts that need verbose output, AWSPowershell/Netcore output the import module process with an extremely detailed output of the functions and exports. This is brought to head even more when leveraging AWS System Manager sessions as the amount of the content streamed takes a long time to finish streaming.

Current Behavior The performance difference in one test was pretty significant.

measure-command {Import-Module AWSPowershell -force -verbose}
measure-command {Import-Module AWSPowershell -force -verbose:$false}

To work around this when I'm trying to debug chocolatey, verbose debugging for ssm docs, or other scripts, I have to often resort to this terrible approach: Import-Module AWSPowershell -verbose:$false *>$null This ensures that even if global verbose preference is set that all of it gets supressed.

Description Timing
Verbose Output 42 second
Without Verbose 1 second
Routing To Null 2 second

Possible Solution Recommend that verbose output provide summary type diagnostic info such as:

AWSPowershell version 1.0.0 imported
2 ms | 20 functions loaded
1 ms | 20 aliases exported
2 ms | initialized tacos

Context Excessive logging is resulting in slower performance, hacky workarounds to suppress the output, and more difficult debugging process.

Your Environment

matteo-prosperi commented 5 years ago

Hello, the output of Import-Module depends on Microsoft implementation. I am not surprised by the lengthy verbose output, considering that AWSPowerShell and AWSPowerShell.NetCore export almost 6000 cmdlets each. I don't think there is anything we can do to reduce the verbose output of the import command though.

You may want to try and switch your application to use the new modular AWS Tools for PowerShell. See https://github.com/aws/aws-tools-for-powershell/issues/33. Importing only the modules for the services that you plan to use should reduce the verbose output a lot! You will also get improvements in import speed and memory usage.

bpayette commented 5 years ago

@sheldonhull As a note - the Import-Module verbose information was designed to help module authors debug the modules they were writing. It's generated automatically by the runtime not the module itself. (We just never figured that there would be modules with 6000 cmdlets). Anyway, we've had discussions in the PowerShell Committee about this and I know that others have complained about it. The refactored AWS modules should make this less of an issue but I still think it's a good idea to open an issue on PowerShell describing your scenario and the issues you've run into. Thanks.