示例#1
0
文件: Logger.cs 项目: loongEgg/Log
 /// <summary>
 /// 使能指定类型的logger
 /// </summary>
 /// <param name="loggers">使能的类型可以使用或(比如: loggers.Debug | logger.Console)</param>
 /// <param name="level"><see cref="Levels"/></param>
 public static void Enable(Loggers loggers, Levels level = Levels.Dbug)
 {
     lock (_Lock)
     {
         if (loggers.HasFlag(Loggers.Console))
         {
             if (!LoggerDict.ContainsKey(Loggers.Console))
             {
                 LoggerDict.Add(Loggers.Console, new ConsoleLogger(level));
             }
         }
         if (loggers.HasFlag(Loggers.Debug))
         {
             if (!LoggerDict.ContainsKey(Loggers.Debug))
             {
                 LoggerDict.Add(Loggers.Debug, new DebugLogger(level));
             }
         }
         if (loggers.HasFlag(Loggers.File))
         {
             if (!LoggerDict.ContainsKey(Loggers.File))
             {
                 LoggerDict.Add(Loggers.File, new FileLogger(level));
             }
         }
         foreach (var log in LoggerDict.Values)
         {
             log.Level = level;
         }
     }
 }
示例#2
0
文件: Logger.cs 项目: loongEgg/Log
        /// <summary>
        /// 禁止指定类型的记录器工作
        /// </summary>
        /// <param name="logger"><see cref="Loggers"/></param>
        public static void Disable(Loggers logger)
        {
            var enums = Enum.GetValues(typeof(Loggers));

            foreach (Loggers item in enums)
            {
                if (logger.HasFlag(item) && LoggerDict.ContainsKey(item))
                {
                    LoggerDict.Remove(item);
                }
            }
        }