예제 #1
0
        /// <summary>
        /// Initializes the logger and subscribes to the relevant events.
        /// </summary>
        /// <param name="eventSource">The available events that processEvent logger can subscribe to.</param>
        public override void Initialize(IEventSource eventSource)
        {
            ProcessParameters();

            eventSource.BuildStarted  += (s, args) => _build = new Build(args);
            eventSource.BuildFinished += (o, args) => _build.CompleteBuild(args, _logFile, _errors, _warings);

            eventSource.ProjectStarted  += (o, args) => TryProcessEvent(() => _build.AddProject(args));
            eventSource.ProjectFinished += (o, args) => TryProcessEvent(() => _build.CompleteProject(args));
            eventSource.TargetStarted   += (o, args) => TryProcessEvent(() => _build.AddTarget(args));
            eventSource.TargetFinished  += (o, args) => TryProcessEvent(() => _build.CompleteTarget(args));
            eventSource.TaskStarted     += (o, args) => TryProcessEvent(() => _build.AddTask(args));
            eventSource.TaskFinished    += (o, args) => TryProcessEvent(() => _build.CompleteTask(args));

            eventSource.TaskFinished += (o, args) => TryProcessEvent(() => _build.CompleteTask(args));

            eventSource.MessageRaised += HandleMessageRaised;

            eventSource.ErrorRaised += (o, args) =>
            {
                _errors++;
                _build.AddMessage(args, string.Format("Error {0}: {1}", args.Code, args.Message));
            };
            eventSource.WarningRaised += (o, args) =>
            {
                _warings++;
                _build.AddMessage(args, string.Format("Warning {0}: {1}", args.Code, args.Message));
            };
        }