1  using System;
2
3  namespace MS.StrongName.ManagedSN
4  {
5      /// <summary>
6      ///     Handles all I/O with the user
7      /// </summary>
8      internal sealed class Log
9      {
10          private static bool quietMode = false;
11
12          /// <summary>
13          ///     Should we log all events, or just errors
14          /// </summary>
15          public static bool QuietMode
16          {
17              get { return quietMode; }
18              set { quietMode = value; }
19          }
20
21          /// <summary>
22          ///     Write a message to the log
23          /// </summary>
24          /// <exception cref="ArgumentNullException">
25          ///     If <paramref name="message"/> is null
26          /// </exception>
27          /// <param name="message">message to write</param>
28          public static void Message(string message)
29          {
30              if(message == null)
31                  throw new ArgumentNullException("message");
32
33              if(!QuietMode)
34                  Console.WriteLine(message);
35
36              return;
37          }
38
39          /// <summary>
40          ///     Write an error to the log
41          /// </summary>
42          /// <exception cref="ArgumentNullException">
43          ///     If <paramref name="error"/> is null
44          /// </exception>
45          /// <param name="error">error to write</param>
46          public static void Error(string error)
47          {
48              if(error == null)
49                  throw new ArgumentNullException("error");
50
51              Console.Error.WriteLine(error);
52              return;
53          }
54      }
55  }