[mono-symbolicate] Adds log messages.
[mono.git] / mcs / tools / mono-symbolicate / Logger.cs
1 using System;
2
3 namespace Mono
4 {
5         public class Logger
6         {
7                 public enum Level
8                 {
9                         Debug = 1,
10                         Warning = 2,
11                         Error = 3,
12                         None = 4,
13                 }
14
15                 Level level;
16                 Action<string> logAction;
17
18                 public Logger (Level level, Action<string> logAction)
19                 {
20                         this.level = level;
21                         this.logAction = logAction;
22                 }
23
24                 public void LogDebug (string str, params string[] vals)
25                 {
26                         Log (Level.Debug, "Debug: " + str, vals);
27                 }
28
29                 public void LogWarning (string str, params string[] vals)
30                 {
31                         Log (Level.Warning, "Warning: " + str, vals);
32                 }
33
34                 public void LogError (string str, params string[] vals)
35                 {
36                         Log (Level.Error, "Error: " + str, vals);
37                 }
38
39                 private void Log (Level msgLevel, string str, params string[] vals)
40                 {
41                         if ((int) level > (int) msgLevel)
42                                 return;
43
44                         logAction (string.Format (str, vals));
45                 }
46         }
47 }
48