Esempio n. 1
0
            protected override async void Output(EventLevel level, int id, string eventName, EventKeywords eventKeywords, string text, bool doNotTranslatePaths = false)
            {
                if ((level != EventLevel.Error) && (level != EventLevel.Warning))
                {
                    return;
                }

                if (((long)eventKeywords & (long)Keywords.NotForwardedToMaster) > 0)
                {
                    return;
                }

                try
                {
                    await m_workerService.SendEventMessagesAsync(
                        forwardedEvents : new List <EventMessage>(1)
                    {
                        new EventMessage()
                        {
                            Id            = Interlocked.Increment(ref m_nextEventId),
                            Level         = (int)level,
                            EventKeywords = (long)eventKeywords,
                            EventId       = id,
                            EventName     = eventName,
                            Text          = text,
                        },
                    });
                }
                catch (Exception ex) when(ExceptionUtilities.HandleUnexpectedException(ex))
                {
                    // Do nothing. Exception filter handles the logic.
                }
            }
            protected override async void Output(EventLevel level, EventWrittenEventArgs eventData, string text, bool doNotTranslatePaths = false)
            {
                if ((level != EventLevel.Error) && (level != EventLevel.Warning))
                {
                    return;
                }

                if (((long)eventData.Keywords & (long)Keywords.NotForwardedToMaster) > 0)
                {
                    return;
                }

                try
                {
                    PipProcessErrorEvent pipProcessErrorEvent = null;
                    if (eventData.EventId == (int)LogEventId.PipProcessError)
                    {
                        var pipProcessErrorEventFields = new PipProcessErrorEventFields(eventData.Payload, false);
                        pipProcessErrorEvent = new PipProcessErrorEvent()
                        {
                            PipSemiStableHash   = pipProcessErrorEventFields.PipSemiStableHash,
                            PipDescription      = pipProcessErrorEventFields.PipDescription,
                            PipSpecPath         = pipProcessErrorEventFields.PipSpecPath,
                            PipWorkingDirectory = pipProcessErrorEventFields.PipWorkingDirectory,
                            PipExe                 = pipProcessErrorEventFields.PipExe,
                            OutputToLog            = pipProcessErrorEventFields.OutputToLog,
                            MessageAboutPathsToLog = pipProcessErrorEventFields.MessageAboutPathsToLog,
                            PathsToLog             = pipProcessErrorEventFields.PathsToLog,
                            ExitCode               = pipProcessErrorEventFields.ExitCode,
                            OptionalMessage        = pipProcessErrorEventFields.OptionalMessage,
                            ShortPipDescription    = pipProcessErrorEventFields.ShortPipDescription,
                        };
                    }

                    await m_workerService.SendEventMessagesAsync(
                        forwardedEvents : new List <EventMessage>(1)
                    {
                        new EventMessage()
                        {
                            Id                   = Interlocked.Increment(ref m_nextEventId),
                            Level                = (int)level,
                            EventKeywords        = (long)eventData.Keywords,
                            EventId              = eventData.EventId,
                            EventName            = eventData.EventName,
                            Text                 = text,
                            PipProcessErrorEvent = pipProcessErrorEvent,
                        },
                    });
                }
                catch (Exception ex) when(ExceptionUtilities.HandleUnexpectedException(ex))
                {
                    // Do nothing. Exception filter handles the logic.
                }
            }