question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Discussion] Format objects sent to Log Streams with "out-string" by default

See original GitHub issue

Since Output/Verbose/Debug/etc. streams are considered log channels for the powershell worker, it should by default format objects in the same way a powershell console host would.

For instance: get-childitem | fl returns

Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData

whereas the expected output to a typical powershell developer would be the equivalent of get-childitem | fl | out-string

Since these are only log entries, I wouldn’t consider this a breaking change for a preview item (unless someone is parsing result logs already programatically)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AnatoliBcommented, Jun 14, 2019

@JustinGrote Please note though that logging of Output objects in the regular PowerShell console is special. Out-String is automatically applied to the objects written to Output, but not to other streams. For example:

get-childitem | fl | Write-Verbose -Verbose

will print:

VERBOSE: Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
VERBOSE: Microsoft.PowerShell.Commands.Internal.Format.GroupStartData
VERBOSE: Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
VERBOSE: Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
...
0reactions
AnatoliBcommented, Jul 10, 2019

I was going to make the change we agreed on, but it looks like this is already the current behavior. When running on Azure and locally (using the PS Worker from dev and master branches), get-childitem | fl produces the following traces:

2019-07-10T19:47:27.050 [Information] OUTPUT:     Directory: D:\home\site\wwwroot
2019-07-10T19:47:27.060 [Information] OUTPUT:
2019-07-10T19:47:27.089 [Information] OUTPUT: Name           : HttpTrigger
2019-07-10T19:47:27.091 [Information] OUTPUT: CreationTime   : 5/31/2019 10:36:38 PM
2019-07-10T19:47:27.102 [Information] OUTPUT: LastWriteTime  : 5/31/2019 10:36:38 PM
2019-07-10T19:47:27.169 [Information] OUTPUT: LastAccessTime : 5/31/2019 10:36:38 PM
2019-07-10T19:47:27.169 [Information] OUTPUT: Mode           : d-----
2019-07-10T19:47:27.170 [Information] OUTPUT: LinkType       :
2019-07-10T19:47:27.170 [Information] OUTPUT: Target         :
2019-07-10T19:47:27.170 [Information] OUTPUT:
2019-07-10T19:47:28.128 [Information] OUTPUT: Name           : .funcignore
2019-07-10T19:47:28.710 [Information] OUTPUT: Length         : 41
2019-07-10T19:47:28.711 [Information] OUTPUT: CreationTime   : 5/16/2019 9:48:36 PM
2019-07-10T19:47:28.711 [Information] OUTPUT: LastWriteTime  : 5/16/2019 9:48:36 PM
2019-07-10T19:47:28.711 [Information] OUTPUT: LastAccessTime : 5/16/2019 9:48:36 PM
2019-07-10T19:47:28.711 [Information] OUTPUT: Mode           : ------
2019-07-10T19:47:28.712 [Information] OUTPUT: LinkType       :
2019-07-10T19:47:28.712 [Information] OUTPUT: Target         :
2019-07-10T19:47:28.712 [Information] OUTPUT: VersionInfo    : File:             D:\home\site\wwwroot\.funcignore
2019-07-10T19:47:28.712 [Information] OUTPUT:                  InternalName:
2019-07-10T19:47:28.713 [Information] OUTPUT:                  OriginalFilename:
2019-07-10T19:47:28.713 [Information] OUTPUT:                  FileVersion:
2019-07-10T19:47:28.713 [Information] OUTPUT:                  FileDescription:
2019-07-10T19:47:28.713 [Information] OUTPUT:                  Product:
2019-07-10T19:47:28.714 [Information] OUTPUT:                  ProductVersion:
2019-07-10T19:47:28.714 [Information] OUTPUT:                  Debug:            False
2019-07-10T19:47:28.714 [Information] OUTPUT:                  Patched:          False
2019-07-10T19:47:28.720 [Information] OUTPUT:                  PreRelease:       False
2019-07-10T19:47:28.720 [Information] OUTPUT:                  PrivateBuild:     False
2019-07-10T19:47:28.720 [Information] OUTPUT:                  SpecialBuild:     False
2019-07-10T19:47:28.721 [Information] OUTPUT:                  Language:
2019-07-10T19:47:28.721 [Information] OUTPUT:
2019-07-10T19:47:28.721 [Information] OUTPUT:
2019-07-10T19:47:28.722 [Information] OUTPUT: Name           : extensions.csproj
2019-07-10T19:47:28.722 [Information] OUTPUT: Length         : 369
2019-07-10T19:47:28.722 [Information] OUTPUT: CreationTime   : 5/16/2019 9:42:36 PM
2019-07-10T19:47:28.722 [Information] OUTPUT: LastWriteTime  : 5/16/2019 9:42:36 PM
2019-07-10T19:47:28.722 [Information] OUTPUT: LastAccessTime : 5/16/2019 9:42:36 PM
2019-07-10T19:47:28.723 [Information] OUTPUT: Mode           : ------
2019-07-10T19:47:28.723 [Information] OUTPUT: LinkType       :
2019-07-10T19:47:28.723 [Information] OUTPUT: Target         :
2019-07-10T19:47:28.723 [Information] OUTPUT: VersionInfo    : File:             D:\home\site\wwwroot\extensions.csproj
2019-07-10T19:47:28.723 [Information] OUTPUT:                  InternalName:
2019-07-10T19:47:28.724 [Information] OUTPUT:                  OriginalFilename:
2019-07-10T19:47:28.724 [Information] OUTPUT:                  FileVersion:
2019-07-10T19:47:28.730 [Information] OUTPUT:                  FileDescription:
2019-07-10T19:47:28.730 [Information] OUTPUT:                  Product:
2019-07-10T19:47:28.730 [Information] OUTPUT:                  ProductVersion:
2019-07-10T19:47:28.731 [Information] OUTPUT:                  Debug:            False
2019-07-10T19:47:28.731 [Information] OUTPUT:                  Patched:          False
2019-07-10T19:47:28.731 [Information] OUTPUT:                  PreRelease:       False
2019-07-10T19:47:28.732 [Information] OUTPUT:                  PrivateBuild:     False
2019-07-10T19:47:28.732 [Information] OUTPUT:                  SpecialBuild:     False
2019-07-10T19:47:28.732 [Information] OUTPUT:                  Language:
...

Please note that I’m looking specifically at the Output stream, as this is the only stream where we wanted to apply Out-String automatically.

I’m closing this issue, unless someone can still repro it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How should the PowerShell worker implement $returns ( ...
Everything that gets thrown onto the pipeline will be logged, but the LAST item added to the pipeline will be the output for...
Read more >
PowerShell: write-output only writes one object
If the output stream's objets aren't redirected or captured in some form, they are sent to the host by default (typically, the console), ......
Read more >
How does Select-String work with Pipelines of objects?
By default, they go to Out-Host but you can pipe this to Out-File, Out-Printer or Out-String. (NOTE: these OUT-xxx commands are pretty clever, ......
Read more >
write-host vs | out-host : r/PowerShell
The cmdlets that contain the Out verb, Out-, don't format objects. They render objects and send them to the specified display destination.
Read more >
Properties (Java Platform SE 8 )
The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found