Exemple #1
0
 internal override void WriteInformation(
     PSEventId id,
     PSOpcode opcode,
     PSTask task,
     params object[] args)
 {
 }
        /// <summary>
        /// Writes a log entry.
        /// </summary>
        /// <param name="eventId">The event id of the log entry.</param>
        /// <param name="channel">The channel to log.</param>
        /// <param name="task">The task for the log entry.</param>
        /// <param name="opcode">The operation for the log entry.</param>
        /// <param name="level">The logging level.</param>
        /// <param name="keyword">The keyword(s) for the event.</param>
        /// <param name="args">The payload for the log message.</param>
        public void Log(PSEventId eventId, PSChannel channel, PSTask task, PSOpcode opcode, PSLevel level, PSKeyword keyword, params object[] args)
        {
            if (ShouldLog(level, keyword, channel))
            {
                int threadId = Thread.CurrentThread.ManagedThreadId;

                StringBuilder sb = MessageBuilder;
                sb.Clear();

                // add the message preamble
                sb.AppendFormat(CultureInfo.InvariantCulture,
                                "({0}:{1:X}:{2:X}) [{3:G}:{4:G}.{5:G}.{6:G}] ",
                                PSVersionInfo.GitCommitId, threadId, channel, eventId, task, opcode, level);

                // add the message
                GetEventMessage(sb, eventId, args);

                NativeMethods.SysLogPriority priority;
                if ((int)level <= _levels.Length)
                {
                    priority = _levels[(int)level];
                }
                else
                {
                    priority = NativeMethods.SysLogPriority.Info;
                }
                // log it.
                NativeMethods.SysLog(priority, sb.ToString());
            }
        }
Exemple #3
0
 internal override void WriteWarning(
     PSEventId id,
     PSOpcode opcode,
     PSTask task,
     params object[] args)
 {
 }
Exemple #4
0
 /// <summary>
 /// Writes a single event
 /// </summary>
 /// <param name="id">event id</param>
 /// <param name="channel"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="logContext">log context</param>
 /// <param name="payLoad"></param>
 internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad)
 {
     s_provider.Log(id, channel, task, opcode, GetPSLevelFromSeverity(logContext.Severity), DefaultKeywords,
                    LogContextToString(logContext),
                    GetPSLogUserData(logContext.ExecutionContext),
                    payLoad);
 }
Exemple #5
0
 internal override void WriteCritialError(
     PSEventId id,
     PSOpcode opcode,
     PSTask task,
     params object[] args)
 {
 }
Exemple #6
0
 internal override void WriteEvent(
     PSEventId id,
     PSLevel level,
     PSOpcode opcode,
     PSTask task,
     params object[] args)
 {
 }
Exemple #7
0
 static internal void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword,
                                         Int64 objectId,
                                         Int64 fragmentId,
                                         int isStartFragment,
                                         int isEndFragment,
                                         UInt32 fragmentLength,
                                         PSETWBinaryBlob fragmentData)
 {
 }
Exemple #8
0
 internal static void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, long objectId, long fragmentId, int isStartFragment, int isEndFragment, int fragmentLength, PSETWBinaryBlob fragmentData)
 {
     if (provider.IsEnabled(PSLevel.Verbose, keyword))
     {
         string str = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length);
         str = string.Format(CultureInfo.InvariantCulture, "0x{0}", new object[] { str.Replace("-", "") });
         provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Verbose, task, keyword, new object[] { objectId, fragmentId, isStartFragment, isEndFragment, fragmentLength, str });
     }
 }
Exemple #9
0
 internal static void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, long objectId, long fragmentId, int isStartFragment, int isEndFragment, int fragmentLength, PSETWBinaryBlob fragmentData)
 {
     if (provider.IsEnabled(PSLevel.Verbose, keyword))
     {
         string str = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length);
         str = string.Format(CultureInfo.InvariantCulture, "0x{0}", new object[] { str.Replace("-", "") });
         provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Verbose, task, keyword, new object[] { objectId, fragmentId, isStartFragment, isEndFragment, fragmentLength, str });
     }
 }
Exemple #10
0
        internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSLevel level, PSTask task, PSKeyword keyword, params object[] args)
        {
            long keywords = 0L;

            if ((keyword == PSKeyword.UseAlwaysAnalytic) || (keyword == PSKeyword.UseAlwaysOperational))
            {
                keywords = 0L;
            }
            else
            {
                keywords = (long)keyword;
            }
            System.Diagnostics.Eventing.EventDescriptor eventDescriptor = new System.Diagnostics.Eventing.EventDescriptor((int)id, 1, (byte)channel, (byte)level, (byte)opcode, (int)task, keywords);
            etwProvider.WriteEvent(ref eventDescriptor, args);
        }
Exemple #11
0
        /// <summary>
        /// Logs remoting fragment data to verbose channel.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opcode"></param>
        /// <param name="task"></param>
        /// <param name="keyword"></param>
        /// <param name="objectId"></param>
        /// <param name="fragmentId"></param>
        /// <param name="isStartFragment"></param>
        /// <param name="isEndFragment"></param>
        /// <param name="fragmentLength"></param>
        /// <param name="fragmentData"></param>
        internal static void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword,
                                                Int64 objectId,
                                                Int64 fragmentId,
                                                int isStartFragment,
                                                int isEndFragment,
                                                UInt32 fragmentLength,
                                                PSETWBinaryBlob fragmentData)
        {
            if (provider.IsEnabled(PSLevel.Verbose, keyword))
            {
                string payLoadData = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length);
                payLoadData = string.Format(CultureInfo.InvariantCulture, "0x{0}", payLoadData.Replace("-", string.Empty));

                provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Verbose, task, keyword,
                                    objectId, fragmentId, isStartFragment, isEndFragment, fragmentLength,
                                    payLoadData);
            }
        }
Exemple #12
0
        /// <summary>
        /// Writes an event
        /// </summary>
        /// <param name="id"></param>
        /// <param name="channel"></param>
        /// <param name="opcode"></param>
        /// <param name="level"></param>
        /// <param name="task"></param>
        /// <param name="keyword"></param>
        /// <param name="args"></param>
        internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSLevel level, PSTask task, PSKeyword keyword, params object[] args)
        {
            long longKeyword = 0x00;

            if (keyword == PSKeyword.UseAlwaysAnalytic ||
                keyword == PSKeyword.UseAlwaysOperational)
            {
                longKeyword = 0x00;
            }
            else
            {
                longKeyword = (long)keyword;
            }

            EventDescriptor desc = new EventDescriptor((int)id, (byte)PSEventVersion.One, (byte)channel,
                                                       (byte)level, (byte)opcode, (int)task, longKeyword);

            etwProvider.WriteEvent(ref desc, args);
        }
        /// <summary>
        /// Writes a log entry.
        /// </summary>
        /// <param name="eventId">The event id of the log entry.</param>
        /// <param name="channel">The channel to log.</param>
        /// <param name="task">The task for the log entry.</param>
        /// <param name="opcode">The operation for the log entry.</param>
        /// <param name="level">The logging level.</param>
        /// <param name="keyword">The keyword(s) for the event.</param>
        /// <param name="args">The payload for the log message.</param>
        public void Log(PSEventId eventId, PSChannel channel, PSTask task, PSOpcode opcode, PSLevel level, PSKeyword keyword, params object[] args)
        {
            if (keyword == PSKeyword.UseAlwaysAnalytic)
            {
                // Use the 'DefaultKeywords' to work around the default keyword filter.
                // Note that the PSKeyword argument is not really used in writing SysLog.
                keyword = PSSysLogProvider.DefaultKeywords;
            }

            if (ShouldLog(level, keyword, channel))
            {
                int threadId = Thread.CurrentThread.ManagedThreadId;

                StringBuilder sb = MessageBuilder;
                sb.Clear();

                // add the message preamble
                sb.AppendFormat(CultureInfo.InvariantCulture,
                                "({0}:{1:X}:{2:X}) [{3:G}:{4:G}.{5:G}.{6:G}] ",
                                PSVersionInfo.GitCommitId, threadId, channel, eventId, task, opcode, level);

                // add the message
                GetEventMessage(sb, eventId, args);

                NativeMethods.SysLogPriority priority;
                if ((int)level <= _levels.Length)
                {
                    priority = _levels[(int)level];
                }
                else
                {
                    priority = NativeMethods.SysLogPriority.Info;
                }
                // log it.
                NativeMethods.SysLog(priority, sb.ToString());
            }
        }
Exemple #14
0
 /// <summary>
 /// Writes an event
 /// </summary>
 /// <param name="id"></param>
 /// <param name="channel"></param>
 /// <param name="opcode"></param>
 /// <param name="level"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSLevel level, PSTask task, PSKeyword keyword, params object[] args)
 {
     s_provider.Log(id, channel, task, opcode, level, keyword, args);
 }
Exemple #15
0
 internal abstract void WriteDebug(
     PSEventId id,
     PSOpcode opcode,
     PSTask task,
     params object[] args);
Exemple #16
0
 /// <summary>
 /// Logs informational message to the analytic channel
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal static void LogAnalyticInformational(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
 }
Exemple #17
0
        /// <summary>
        /// Writes an event
        /// </summary>
        /// <param name="id"></param>
        /// <param name="channel"></param>
        /// <param name="opcode"></param>
        /// <param name="level"></param>
        /// <param name="task"></param>
        /// <param name="keyword"></param>
        /// <param name="args"></param>
        internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSLevel level, PSTask task, PSKeyword keyword, params object[] args)
        {
            long longKeyword = 0x00;

            if (keyword == PSKeyword.UseAlwaysAnalytic ||
                keyword == PSKeyword.UseAlwaysOperational)
            {
                longKeyword = 0x00;
            }
            else
            {
                longKeyword = (long)keyword;
            }

            EventDescriptor desc = new EventDescriptor((int)id, (byte)PSEventVersion.One, (byte)channel,
                (byte)level, (byte)opcode, (int)task, longKeyword);

            etwProvider.WriteEvent(ref desc, args);
        }
Exemple #18
0
 internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSLevel level, PSTask task, PSKeyword keyword, params object[] args)
 {
     long keywords = 0L;
     if ((keyword == PSKeyword.UseAlwaysAnalytic) || (keyword == PSKeyword.UseAlwaysOperational))
     {
         keywords = 0L;
     }
     else
     {
         keywords = (long) keyword;
     }
     System.Diagnostics.Eventing.EventDescriptor eventDescriptor = new System.Diagnostics.Eventing.EventDescriptor((int) id, 1, (byte) channel, (byte) level, (byte) opcode, (int) task, keywords);
     etwProvider.WriteEvent(ref eventDescriptor, args);
 }
Exemple #19
0
 /// <summary>
 /// Writes a single event
 /// </summary>
 /// <param name="id">event id.</param>
 /// <param name="channel"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="logContext">log context.</param>
 /// <param name="payLoad"></param>
 internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad)
 {
     WriteEvent(id, channel, opcode, GetPSLevelFromSeverity(logContext.Severity), task, (PSKeyword)0x0,
                LogContextToString(logContext), GetPSLogUserData(logContext.ExecutionContext), payLoad);
 }
Exemple #20
0
 /// <summary>
 /// Logs error message to operation channel.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal static void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
     provider.WriteEvent(id, PSChannel.Operational, opcode, PSLevel.Error, task, keyword, args);
 }
Exemple #21
0
 static internal void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
 }
Exemple #22
0
 internal abstract void WriteCritialError(
     PSEventId id,
     PSOpcode opcode,
     PSTask task,
     params object[] args);
Exemple #23
0
 /// <summary>
 /// Logs error message to operation channel.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal static void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
     provider.WriteEvent(id, PSChannel.Operational, opcode, PSLevel.Error, task, keyword, args);
 }
Exemple #24
0
        /// <summary>
        /// Logs remoting fragment data to verbose channel.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opcode"></param>
        /// <param name="task"></param>
        /// <param name="keyword"></param>
        /// <param name="objectId"></param>
        /// <param name="fragmentId"></param>
        /// <param name="isStartFragment"></param>
        /// <param name="isEndFragment"></param>
        /// <param name="fragmentLength"></param>
        /// <param name="fragmentData"></param>
        internal static void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword,
            Int64 objectId,
            Int64 fragmentId,
            int isStartFragment,
            int isEndFragment,
            UInt32 fragmentLength,
            PSETWBinaryBlob fragmentData)
        {
            if (provider.IsEnabled(PSLevel.Verbose, keyword))
            {
                string payLoadData = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length);
                payLoadData = string.Format(CultureInfo.InvariantCulture, "0x{0}", payLoadData.Replace("-", ""));

                provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Verbose, task, keyword,
                                    objectId, fragmentId, isStartFragment, isEndFragment, fragmentLength,
                                    payLoadData);
            }
        }
Exemple #25
0
 static internal void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args) { }
Exemple #26
0
 static internal void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword,
     Int64 objectId,
     Int64 fragmentId,
     int isStartFragment,
     int isEndFragment,
     UInt32 fragmentLength,
     PSETWBinaryBlob fragmentData)
 { }
Exemple #27
0
 static internal void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad)
 {
 }
Exemple #28
0
 internal abstract void WriteInformation(
     PSEventId id,
     PSOpcode opcode,
     PSTask task,
     params object[] args);
Exemple #29
0
 /// <summary>
 /// Logs informational message to the analytic channel.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal static void LogAnalyticInformational(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
     provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Informational, task, keyword, args);
 }
Exemple #30
0
 /// <summary>
 /// Logs error message to operation channel.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal static void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
 }
Exemple #31
0
 /// <summary>
 /// Logs error message to the operational channel.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="logContext"></param>
 /// <param name="payLoad"></param>
 internal static void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad)
 {
     provider.WriteEvent(id, PSChannel.Operational, opcode, task, logContext, payLoad);
 }
Exemple #32
0
 /// <summary>
 /// Writes a single event
 /// </summary>
 /// <param name="id">event id</param>
 /// <param name="channel"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="logContext">log context</param>
 /// <param name="payLoad"></param>
 internal void WriteEvent(PSEventId id, PSChannel channel, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad)
 {
     WriteEvent(id, channel, opcode, GetPSLevelFromSeverity(logContext.Severity), task, (PSKeyword)0x0,
         LogContextToString(logContext), GetPSLogUserData(logContext.ExecutionContext), payLoad);
 }
Exemple #33
0
 static internal void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad) { }
Exemple #34
0
 static internal void LogOperationalInformation(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
 }
Exemple #35
0
 /// <summary>
 /// Logs informational message to the analytic channel
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="keyword"></param>
 /// <param name="args"></param>
 internal static void LogAnalyticInformational(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args)
 {
     provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Informational, task, keyword, args);
 }
Exemple #36
0
 static internal void LogOperationalInformation(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args) { }
Exemple #37
0
 /// <summary>
 /// Logs error message to the operational channel
 /// </summary>
 /// <param name="id"></param>
 /// <param name="opcode"></param>
 /// <param name="task"></param>
 /// <param name="logContext"></param>
 /// <param name="payLoad"></param>
 internal static void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad)
 {
     provider.WriteEvent(id, PSChannel.Operational, opcode, task, logContext, payLoad);
 }
Exemple #38
0
 internal abstract void WriteEvent(
     PSEventId id,
     PSLevel level,
     PSOpcode opcode,
     PSTask task,
     params object[] args);