예제 #1
0
        public LevelLogger(Level level, Logger logger)
        {
            Level = level;
            Logger = logger;
            Writer = logger.Writer ?? LogWriter.Adhoc;

#if TRACE
            IsEnabled = true;
#endif
        }
예제 #2
0
        public virtual void SetUp()
        {
            _writer = LogWriter.Get(this.GetType().AssemblyQualifiedName + "::" + Id + "::" + Guid.NewGuid());
            _writer.Medium = new AdhocMedium();
            _writer.Multiplex(Out = new StringBuilder());
            Log = Logger.Get(this.GetType().AssemblyQualifiedName + "::" + Id + "::" + Guid.NewGuid()).Debug;
            Log.OverrideWriter(_writer);
            MultiplexLogs(Logger.Adhoc);

            UnitTest.Context["Current Fixture"] = this.GetType();
            _flash = new Dictionary<String, Object>();
        }
예제 #3
0
        internal Logger(String name, LogWriter writer)
        {
            Name = name;

            Debug = new LevelLogger(Level.Debug, this);
            Info = new LevelLogger(Level.Info, this);
            Warn = new LevelLogger(Level.Warn, this);
            Error = new LevelLogger(Level.Error, this);
            Fatal = new LevelLogger(Level.Fatal, this);
            Writer = writer ?? LogWriter.Adhoc;

            MinLevel = Level.Debug;
            IsEnabled = true;
        }
예제 #4
0
        public IDisposable OverrideWriter(LogWriter new_out)
        {
            var old_out = Writer;
            Writer = new_out;
            var this_override = new DisposableAction(() => Writer = old_out);

            var debug_override = Debug.OverrideWriter(new_out);
            var info_override = Info.OverrideWriter(new_out);
            var warn_override = Warn.OverrideWriter(new_out);
            var error_override = Error.OverrideWriter(new_out);
            var fatal_override = Fatal.OverrideWriter(new_out);

            return this_override + debug_override + info_override + warn_override + error_override + fatal_override;
        }
예제 #5
0
 public IDisposable OverrideWriter(LogWriter new_out)
 {
     var old_out = Writer;
     Writer = new_out;
     return new DisposableAction(() => Writer = old_out);
 }