public ILoggy Get(string name = null, Action <ILoggy> setup = null) { if (string.IsNullOrWhiteSpace(name)) { name = "default"; } var result = loggers.GetOrAdd(name, n => { var l = new DefaultLoggy { Name = n }; if (n == "_failsafe") { l.Isolated = true; l.Level = LogLevel.All; l.Appenders.Add(new ConsoleAppender { Format = "%{Level} - %{UserName} - %{Message}" }); l.Appenders.Add(new UdpAppender("127.0.0.2", 7071) { Format = "%{UserName} - %{Message}" }); return(l); } if (n != "default") { ILoggy parent = null; if (n.Contains(".")) { var parts = n.Split('.'); var path = string.Join(".", parts.Take(parts.Length - 1)); parent = Get(path); } else { parent = Get(); } l.SubLoggers.Add(parent); l.Level = parent.Level; } else { l.Isolated = true; } if (null != setup) { setup(l); } return(l); }); return(result); }
public void CanGetExplicitlySetNamed() { var l = new DefaultLoggy(); manager.Loggers["x"] = l; Assert.AreEqual(l,manager.Get("x")); }
public void Setup() { this.logger = new DefaultLoggy(); logger.Appenders.Add(this.appender = new TestAppender{Level = LogLevel.Info}); }