public static void NormalLog(LogItem aLog) { lock (locker) { normalQueue.Enqueue(aLog); while (normalQueue.Count > 1000) { LogItem log = null; normalQueue.TryDequeue(out log); } ConcurrentQueue<LogItem> tokenDictQue = null; if (tokenDict.TryGetValue(aLog.token, out tokenDictQue)) { tokenDictQue.Enqueue(aLog); } else { tokenDict.TryAdd(aLog.token, new ConcurrentQueue<LogItem>(new LogItem[] { aLog })); tokenQueue.Enqueue(aLog.token); while(tokenQueue.Count > 1000) { string token = null; tokenQueue.TryDequeue(out token); tokenDict.TryRemove(token, out tokenDictQue); } } if (onNewNormalLog != null) onNewNormalLog(null, new NewLogEventArgs(aLog)); } }
private static void ProcessLog(LogItem aLog) { switch(aLog.token) { case "BEAT": LogCore.BeatLog(aLog); break; default: LogCore.NormalLog(aLog); break; } }
public static void BeatLog(LogItem aLog) { lock(locker) { beatQueue.Enqueue(aLog); while(beatQueue.Count > 1000) { LogItem log = null; beatQueue.TryDequeue(out log); } if (onNewBeatLog != null) onNewBeatLog(null, new NewLogEventArgs(aLog)); } }
public NewLogEventArgs(LogItem aLog) { Log = aLog; }