Example #1
0
        public static StreamWriter GetWriter(string name, DateTime date)
        {
            if (Writers.ContainsKey(name))
            {
                var writer = Writers[name];
                writer.Time = date;
                return(writer.Writer);
            }
            if (!name.Contains(LogConfig.CharacterPrefix))
            {
                return(DefaultLog);
            }

            var w  = CreateWriter(name, date);
            var wd = new WriterData()
            {
                Name   = name,
                Time   = date,
                Writer = w,
            };

            Writers.GetOrAdd(name, wd);
            return(w);
        }
Example #2
0
 private static void RemoveWriter(WriterData data)
 {
     data.Writer.Close();
     data.Writer = null;
     Writers.TryRemove(data.Name, out data);
 }