/// <summary> /// The single instance method that writes to the log file /// </summary> /// <param name="message">The message to write to the log</param> public void WriteToLog(LogEntry logEntry) { // Lock the queue while writing to prevent contention for the log file logQueue.Enqueue(logEntry); // If we have reached the Queue Size then flush the Queue if (logQueue.Count >= queueSize || DoPeriodicFlush()) { FlushLog(); } }
public static void LogEvent(LogEntry logentry) { if (SystemLogger.Instance.IsLogEnabled) { try { SystemLogger.Instance.WriteToLog(logentry); } catch (Exception ex) { Console.WriteLine("Logger: could not process event! " + ex.Message + "\n" + ex.StackTrace); } } }
public static void LogEvent(string domain, string source, string description, string property, string value) { var logEntry = new LogEntry() { Domain = domain, Source = source, Description = description, Property = property, Value = value.Replace("\"", "") }; LogEvent(logEntry); }
internal void LogBroadcastEvent( string domain, string source, string description, string property, string value ) { // these events are also routed to the UI var logEntry = new LogEntry() { Domain = domain, Source = source, Description = description, Property = property, Value = value }; try { if (recentEventsLog.Count > 100) { recentEventsLog.RemoveRange(0, recentEventsLog.Count - 100); } recentEventsLog.Add(logEntry); // if (LogEventAction != null) { LogEventAction(logEntry); } } catch { System.Diagnostics.Debugger.Break(); } // LogEvent(logEntry); }
/// <summary> /// The single instance method that writes to the log file /// </summary> /// <param name="message">The message to write to the log</param> public void WriteToLog(LogEntry logEntry) { standardOutput.WriteLine(logEntry); ThreadPool.QueueUserWorkItem(new WaitCallback((state)=>{ lock (logQueue) { // Lock the queue while writing to prevent contention for the log file logQueue.Enqueue(logEntry); // If we have reached the Queue Size then flush the Queue if (logQueue.Count >= queueSize || DoPeriodicFlush()) { FlushLog(); } } })); }