Beispiel #1
0
        static void DealMessages(Dictionary<string, StringBuilder> logs)
        {
            try
            {
                DateTime now = DateTime.Now;
                int spanBak = (now - bakTime).Minutes;
                int spanClear = (now - clearTime).Minutes;
                if (spanBak > bakMinutes) bakTime = now;
                if (spanClear > clearMinutes) clearTime = now;
                string act = "";
                string timeFormat = now.ToString("yyyy-MM-dd HH-00-00") + ".txt";
                if (LogConfig.TimedLog == 2)
                    timeFormat = now.ToString("yyyy-MM-dd 00-00-00") + ".txt";
                string w = LogAction.Write.ToString();

                foreach (string action in logs.Keys)
                {
                    try
                    {
                        act = (action + "\\").Replace(w + "\\", "");
                        if (logDep == 0)
                            act = act.Replace(logPrex, "");
                        Directory.CreateDirectory(logPath + act);
                        WriteMsg(logs[action], logPath + act + timeFormat, backPath + act, LogConfig.IsMutex);
                    }
                    catch (Exception e) { e = null; logs.Clear(); }
                }
                if (spanClear > clearMinutes)
                {
                    ClearLog(logPath, backPath);
                    GC.Collect();
                }
            }
            catch (Exception e)
            {
                e = null;
                logs.Clear();
            }
            LogEventArgs arg = new LogEventArgs(logs);
            OnFlush(arg);
            //logs.Clear();
            //logs = null;
        }
Beispiel #2
0
 protected static void OnLogging(LogEventArgs args)
 {
     EventHandler handler = eventHandler[logEventKey] as EventHandler;
     if (null != handler)
         handler(log, args);
 }