Esempio n. 1
0
        /// <summary>
        /// Handles a generic BuildMessage event and assigns it to the appropriate logging node.
        /// </summary>
        /// <param name="buildMessageEventArgs">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param>
        public void AddMessage(LazyFormattedBuildEventArgs buildMessageEventArgs, string message)
        {
            LogProcessNode node = this;

            if (buildMessageEventArgs.BuildEventContext.TaskId > 0)
            {
                node = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId)
                    .GetTargetById(buildMessageEventArgs.BuildEventContext.TargetId)
                    .GetTaskById(buildMessageEventArgs.BuildEventContext.TaskId);
            }
            else if (buildMessageEventArgs.BuildEventContext.TargetId > 0)
            {
                node = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId)
                    .GetTargetById(buildMessageEventArgs.BuildEventContext.TargetId);
            }
            else if (buildMessageEventArgs.BuildEventContext.ProjectContextId > 0)
            {
                node = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId);
            }

            node.AddMessage(new Message(message, buildMessageEventArgs.Timestamp));
        }
Esempio n. 2
0
 private static string FormatMessage(LazyFormattedBuildEventArgs e)
 {
     return string.Format("{0}:{1}$$", e.HelpKeyword, e.Message);
 }
Esempio n. 3
0
        private void EventSource_ErrorRaised(
            BuildOutputLogger loggerSender,
            LazyFormattedBuildEventArgs e,
            ErrorLevel errorLevel)
        {
            try
            {
                bool verified = VerifyLoggerBuildEvent(loggerSender, e, errorLevel);
                if (!verified)
                    return;

                int projectInstanceId = e.BuildEventContext.ProjectInstanceId;
                int projectContextId = e.BuildEventContext.ProjectContextId;

                BuildProjectContextEntry projectEntry = loggerSender.Projects.Find(t =>
                    t.InstanceId == projectInstanceId
                    && t.ContextId == projectContextId);

                if (projectEntry == null)
                {
                    TraceManager.Trace(
                        string.Format(
                            "Project entry not found by ProjectInstanceId='{0}' and ProjectContextId='{1}'.",
                            projectInstanceId,
                            projectContextId), 
                        EventLogEntryType.Warning);

                    return;
                }

                if (projectEntry.IsInvalid)
                    return;

                ProjectItem projectItem;
                if (!GetProjectItem(projectEntry, out projectItem))
                {
                    projectEntry.IsInvalid = true;
                    return;
                }

                BuildedProject buildedProject = _buildedProjects[projectItem];
                buildedProject.ErrorsBox.Keep(errorLevel, e);
                OnErrorRaised(this, new BuildErrorRaisedEventArgs(errorLevel, buildedProject));
            }
            catch (Exception ex)
            {
                ex.TraceUnknownException();
            }
        }