51
static object write_lock = new object ();
52
static bool writing = false;
50
53
public static LogLevel DisplayLevel { get; set; }
52
static bool Writing { get; set; }
53
static ICollection<LogCall> PendingLogCalls { get; set; }
58
PendingLogCalls = new LinkedList<LogCall> ();
61
55
public static void Write (LogLevel level, string msg, params object[] args)
63
if (level < DisplayLevel) return;
65
msg = string.Format (msg, args);
67
// In the process of logging, another log call has been made.
68
// We need to avoid the infinite regress this may cause.
69
PendingLogCalls.Add (new LogCall (level, msg));
73
if (PendingLogCalls.Any ()) {
74
// Flush delayed log calls.
75
// First, swap PendingLogCalls with an empty collection so it
76
// is not modified while we enumerate.
77
IEnumerable<LogCall> calls = PendingLogCalls;
78
PendingLogCalls = new LinkedList<LogCall> ();
80
// Log all pending calls.
81
foreach (LogCall call in calls)
82
foreach (ILogService log in Services.Logs)
83
log.Log (call.Level, call.Message);
87
foreach (ILogService log in Services.Logs)
57
if (level < DisplayLevel)
61
msg = string.Format (msg, args);
64
throw new InvalidOperationException (String.Format ("Logger implementation attempted to call Log from its own Log method.\n" +
66
"***************************\n" +
68
"***************************", msg));
74
foreach (ILogService log in Services.Logs)