![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Tracing Cmdlets and providers Is there a way to hook into the Set-TraceSource/Trace-Command infrastructure so that our Cmdlets and Providers can output trace information? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Tracing Cmdlets and providers On Apr 12, 3:36 pm, "John Vottero" <JVott...@mvpsi.com> wrote: > Is there a way to hook into the Set-TraceSource/Trace-Command infrastructure > so that our Cmdlets and Providers can output trace information? PStracesource , is a public class on system.management.automation , as is as is PStracesourceoptions enum so i don't see why not. and it uses the standard dotnet tracing techniques.. i.e with this attribute [TraceSource("Mycommands", "Sometext")] .... static PSTraceSource tracer = PSTraceSource.GetTracer("Mycommands", "Sometext"); and using this pattern using (IDisposable disposable = tracer.TraceMethod()) { } If you get anywhere with this, we'd love an example, i haven't bothered messing very much with it as of yet. -Karl |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Tracing Cmdlets and providers <klumsy@xtra.co.nz> wrote in message news:1176441861.301009.45690@w1g2000hsg.googlegroups.com... > On Apr 12, 3:36 pm, "John Vottero" <JVott...@mvpsi.com> wrote: >> Is there a way to hook into the Set-TraceSource/Trace-Command >> infrastructure >> so that our Cmdlets and Providers can output trace information? > > PStracesource , is a public class on system.management.automation , as > is as is PStracesourceoptions enum so i don't see why not. PSTraceSource is public but, the constructors and all of the GetTracer methods are internal. I can't figure out why some of it is public but, it appears, not enough to be useful. > > and it uses the standard dotnet tracing techniques.. > i.e with this attribute > [TraceSource("Mycommands", "Sometext")] > I expected the base class of PSTraceSurce to be TraceSource but, it isn't. > ... > > static PSTraceSource tracer = PSTraceSource.GetTracer("Mycommands", > "Sometext"); > > and using this pattern > > using (IDisposable disposable = tracer.TraceMethod()) > { > } That's what I would like to do but, GetTracer and TraceMethod are both internal. > > If you get anywhere with this, we'd love an example, i haven't > bothered messing very much with it as of yet. > At this point, I just want to be able to spit out text when the user does a Trace-Command that invokes one of my Cmdlets or Providers. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Tracing Cmdlets and providers hmm, well you can maybe build your own wrapper class and use reflection to get the internal methods. very hacky though |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| System.net tracing | PowerShell | |||
| Book: Professional Windows PowerShell Programming: Snapins, Cmdlets,Hosts and Providers (Paperback) by Wrox | PowerShell | |||
| Writing generic cmdlets that work across different (navigation) providers | PowerShell | |||
| tracing | Vista General | |||
| Installing PowerShell Cmdlets, providers etc. | PowerShell | |||