예제 #1
0
 public WebApiTester(SimpleLogFactory simpleLogFactory)
 {
     //todo: refactor code
     //var response = await httpClient.GetAsync(uri).ConfigureAwait(false);
     //var handler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip };
     //_httpClient = new HttpClient(handler);
     _simpleLog = simpleLogFactory.CreateLogFor(this);
 }
예제 #2
0
 public static ISimpleLog CreateLogFor(this SimpleLogFactory factory, object instance)
 {
     if (instance == null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     if (instance is Type type)
     {
         return(factory.CreateLogFor(type));
     }
     return(factory.CreateLogFor(instance.GetType()));
 }
예제 #3
0
        public void Log_Should_LogByLevel()
        {
            var simpleLog = SimpleLogFactory.Resolve().Create("Foo");

            simpleLog.EnabledLevel = SimpleLogLevel.Information;

            simpleLog.ShouldLog(SimpleLogLevel.Trace).ShouldFalse();
            simpleLog.ShouldLog(SimpleLogLevel.Debug).ShouldFalse();

            simpleLog.ShouldLog(SimpleLogLevel.Information).ShouldTrue();
            simpleLog.ShouldLog(SimpleLogLevel.Warning).ShouldTrue();
            simpleLog.ShouldLog(SimpleLogLevel.Error).ShouldTrue();
            simpleLog.ShouldLog(SimpleLogLevel.Critical).ShouldTrue();
        }
예제 #4
0
 public static ISimpleLog CreateLogFor <T>(this SimpleLogFactory factory)
 {
     return(factory.CreateLogFor(typeof(T)));
 }
예제 #5
0
 public static ISimpleLog CreateLogFor(this SimpleLogFactory factory, Type type)
 {
     return(factory.CreateLog(type.Name));
 }
예제 #6
0
        private ISimpleLog GetLogger(string category = null)
        {
            var logger = SimpleLogFactory.Resolve().GetOrCreate(category);

            return(logger);
        }