Ejemplo n.º 1
0
 private bool Trace(PowerShellTraceEvent traceEvent, PowerShellTraceLevel level, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     EventDescriptor eventDescriptor = new EventDescriptor((int) traceEvent, 1, (byte) this._traceChannel, (byte) level, (byte) operationCode, (int) task, (long) this._keywords);
     if (args != null)
     {
         for (int i = 0; i < args.Length; i++)
         {
             if (args[i] == null)
             {
                 args[i] = string.Empty;
             }
         }
     }
     return _provider.WriteEvent(ref eventDescriptor, args);
 }
Ejemplo n.º 2
0
 internal PowerShellTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords)
 {
     if (this.IsEtwSupported)
     {
         this.debugChannel = new PowerShellChannelWriter(PowerShellTraceChannel.Debug, keywords | (PowerShellTraceKeywords.None | PowerShellTraceKeywords.UseAlwaysDebug));
         this.analyticChannel = new PowerShellChannelWriter(PowerShellTraceChannel.Analytic, keywords | (PowerShellTraceKeywords.None | PowerShellTraceKeywords.UseAlwaysAnalytic));
         this.operationsChannel = new PowerShellChannelWriter(PowerShellTraceChannel.Operational, keywords | (PowerShellTraceKeywords.None | PowerShellTraceKeywords.UseAlwaysOperational));
         this.task = task;
         this.keywords = keywords;
     }
     else
     {
         this.debugChannel = NullWriter.Instance;
         this.analyticChannel = NullWriter.Instance;
         this.operationsChannel = NullWriter.Instance;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// TraceDebug
 /// </summary>
 public override bool TraceDebug(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     // TODO: There is some error thrown by the custom debug level
     // hence Informational is being used
     return(Trace(traceEvent, PowerShellTraceLevel.Informational, operationCode, task, args));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// TraceInformational
 /// </summary>
 public override bool TraceInformational(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return(Trace(traceEvent, PowerShellTraceLevel.Informational, operationCode, task, args));
 }
Ejemplo n.º 5
0
 public virtual bool TraceWarning(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return true;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns an instance of BaseChannelWriter. 
 /// If the Etw is not supported by the platform it will return NullWriter.Instance
 /// 
 /// A Task and a set of Keywords can be specified in the GetTraceSource method (See overloads).  
 ///    The supplied task and keywords are used to pass to the Etw provider in case they are
 /// not defined in the manifest file.
 /// </summary>
 public static PowerShellTraceSource GetTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords)
 {
     return new PowerShellTraceSource(task, keywords);
 }
Ejemplo n.º 7
0
 internal PowerShellTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords)
 {
 }
Ejemplo n.º 8
0
 public override bool TraceVerbose(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return(this.Trace(traceEvent, PowerShellTraceLevel.Verbose, operationCode, task, args));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// TraceCritical
 /// </summary>
 public virtual bool TraceCritical(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return(true);
 }
Ejemplo n.º 10
0
 public override bool TraceDebug(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return this.Trace(traceEvent, PowerShellTraceLevel.Informational, operationCode, task, args);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructor
        /// </summary>
        internal PowerShellTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords)
        {
            if (IsEtwSupported)
            {
                DebugChannel = new PowerShellChannelWriter(PowerShellTraceChannel.Debug,
                                                           keywords | PowerShellTraceKeywords.UseAlwaysDebug);
                AnalyticChannel = new PowerShellChannelWriter(PowerShellTraceChannel.Analytic,
                                                              keywords | PowerShellTraceKeywords.UseAlwaysAnalytic);
                OperationalChannel = new PowerShellChannelWriter(PowerShellTraceChannel.Operational,
                                                                keywords | PowerShellTraceKeywords.UseAlwaysOperational);

                this.Task = task;
                this.Keywords = keywords;
            }
            else
            {
                DebugChannel = NullWriter.Instance;
                AnalyticChannel = NullWriter.Instance;
                OperationalChannel = NullWriter.Instance;
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// TraceCritical
 /// </summary>
 public override bool TraceCritical(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return Trace(traceEvent, PowerShellTraceLevel.Critical, operationCode, task, args);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// TraceDebug
 /// </summary>
 public override bool TraceDebug(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     // TODO: There is some error thrown by the custom debug level
     // hence Informational is being used
     return Trace(traceEvent, PowerShellTraceLevel.Informational, operationCode, task, args);
 }
Ejemplo n.º 14
0
        private bool Trace(PowerShellTraceEvent traceEvent, PowerShellTraceLevel level, PowerShellTraceOperationCode operationCode,
            PowerShellTraceTask task, params object[] args)
        {
            EventDescriptor ed = new EventDescriptor((int)traceEvent, 1, (byte)_traceChannel, (byte)level,
                                                     (byte)operationCode, (int)task, (long)_keywords);

            /*
             * Not using locks because the _provider is thread safe itself.
             **/

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i] == null)
                    {
                        args[i] = string.Empty;
                    }
                }
            }

            return _provider.WriteEvent(ref ed, args);
        }
Ejemplo n.º 15
0
 internal PowerShellTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Returns an instance of BaseChannelWriter.
 /// If the Etw is not supported by the platform it will return NullWriter.Instance
 ///
 /// A Task and a set of Keywords can be specified in the GetTraceSource method (See overloads).
 ///    The supplied task and keywords are used to pass to the Etw provider in case they are
 /// not defined in the manifest file.
 /// </summary>
 public static PowerShellTraceSource GetTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords)
 {
     return(new PowerShellTraceSource(task, keywords));
 }
Ejemplo n.º 17
0
 public override bool TraceWarning(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return this.Trace(traceEvent, PowerShellTraceLevel.Warning, operationCode, task, args);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// TraceWarning
 /// </summary>
 public override bool TraceWarning(PowerShellTraceEvent traceEvent, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
 {
     return(Trace(traceEvent, PowerShellTraceLevel.Warning, operationCode, task, args));
 }
Ejemplo n.º 19
0
        private bool Trace(PowerShellTraceEvent traceEvent, PowerShellTraceLevel level, PowerShellTraceOperationCode operationCode, PowerShellTraceTask task, params object[] args)
        {
            EventDescriptor eventDescriptor = new EventDescriptor((int)traceEvent, 1, (byte)this._traceChannel, (byte)level, (byte)operationCode, (int)task, (long)this._keywords);

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i] == null)
                    {
                        args[i] = string.Empty;
                    }
                }
            }
            return(_provider.WriteEvent(ref eventDescriptor, args));
        }