Пример #1
0
 public static Task LoadFromManager(this ExtensionCollection extensions, Manager manager, LoggerScope logger)
 {
     if (manager.HasInitialized)
     {
         foreach (ExtensionMetadata v in manager.GetExtensions())
         {
             try
             {
                 ExtensionLoader loader = new ExtensionLoader(v.RootPath, v.Name);
                 extensions.Load(loader);
             }
             catch
             {
                 logger.Warning($"Load extension at {v.RootPath} failed.");
             }
         }
     }
     return(Task.CompletedTask);
 }
Пример #2
0
        public void Scope()
        {
            Logger      logger = new Logger();
            LoggerScope scope  = logger.CreateScope("scope", LogLevel.Information);

            scope.Information("info");
            scope.Debug("debug");
            scope.Warning("warning");
            scope.Error("error");
            scope.Error(new Exception());
            scope.Fatal("fatal");
            scope.Fatal(new Exception());
            LogItem item = logger.View().FirstOrDefault();

            Assert.IsNotNull(item);
            Assert.AreEqual(LogLevel.Information, item.Level);
            Assert.AreEqual("/scope", item.Scope);
            StringAssert.Contains(item.Content, "info");

            LoggerScope subScope = scope.CreateScope("subScope", LogLevel.Debug);

            Assert.AreEqual("/scope/subScope", subScope.Name);
        }