-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoggerImpl.cs
More file actions
60 lines (53 loc) · 1.85 KB
/
LoggerImpl.cs
File metadata and controls
60 lines (53 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace SublimeLogger
{
public class LoggerImpl : Logger
{
private Stopwatch _stopwatch;
#region Overrides of Logger
public override void Initialize(IEventSource eventSource)
{
eventSource.BuildStarted += BuildStarted;
eventSource.BuildFinished += BuildFinished;
eventSource.ErrorRaised += ErrorRaised;
}
void BuildFinished(object sender, BuildFinishedEventArgs e)
{
_stopwatch.Stop();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Compilation done in {0}ms.", _stopwatch.ElapsedMilliseconds);
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White;
if (e.Succeeded)
{
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("Compilation SUCCEEDED.");
}
else
{
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Compilation FAILED!.");
}
Console.BackgroundColor = ConsoleColor.Black;
}
void BuildStarted(object sender, BuildStartedEventArgs e)
{
_stopwatch = Stopwatch.StartNew();
Console.WriteLine("Initializing the compilation.");
Console.WriteLine();
Console.WriteLine();
}
void ErrorRaised(object sender, BuildErrorEventArgs e)
{
var path = Path.GetDirectoryName(e.ProjectFile);
var fullPath = Path.Combine(path, e.File);
Console.WriteLine(" *{0}({1},{2}): {3}.", fullPath, e.LineNumber, e.ColumnNumber, e.Message);
}
#endregion
}
}