public ElmahIoLogger(string apiKey, Guid logId, ElmahIoProviderOptions options)
 {
     _logId      = logId;
     _elmahioApi = new ElmahioAPI(new ApiKeyCredentials(apiKey), HttpClientHandlerFactory.GetHttpClientHandler(options));
     _elmahioApi.Messages.OnMessage     += (sender, args) => options.OnMessage?.Invoke(args.Message);
     _elmahioApi.Messages.OnMessageFail += (sender, args) => options.OnError?.Invoke(args.Message, args.Error);
 }
예제 #2
0
 public ElmahIoLogger(string apiKey, Guid logId, ElmahIoProviderOptions options)
 {
     _logId      = logId;
     _elmahioApi = ElmahioAPI.Create(apiKey);
     _elmahioApi.Messages.OnMessage     += (sender, args) => options.OnMessage?.Invoke(args.Message);
     _elmahioApi.Messages.OnMessageFail += (sender, args) => options.OnError?.Invoke(args.Message, args.Error);
     _options = options;
 }
        public ElmahIoLoggerProvider(IOptions <ElmahIoProviderOptions> options)
        {
            var loggerOptions = options.Value;

            _apiKey  = loggerOptions.ApiKey;
            _logId   = loggerOptions.LogId;
            _options = loggerOptions;
        }
예제 #4
0
 public static HttpClientHandler GetHttpClientHandler(ElmahIoProviderOptions options)
 {
     if (DateTime.Now.Subtract(_initTime) > _lifeTime || _instance == null)
     {
         _instance = new HttpClientHandler
         {
             UseProxy = options.WebProxy != null,
             Proxy    = options.WebProxy,
         };
         _initTime = DateTime.Now;
     }
     return(_instance);
 }
        public ElmahIoLoggerProvider(string apiKey, Guid logId, ElmahIoProviderOptions options = null)
        {
#if NETSTANDARD1_1
            _filter = new FilterLoggerSettings
            {
                { "*", LogLevel.Warning }
            };
#endif
            _apiKey         = apiKey;
            _logId          = logId;
            _options        = options ?? new ElmahIoProviderOptions();
            _options.ApiKey = apiKey;
            _options.LogId  = logId;
        }
        public ElmahIoLoggerProvider(string apiKey, Guid logId, FilterLoggerSettings filter = null, ElmahIoProviderOptions options = null)
        {
            _apiKey = apiKey;
            _logId  = logId;

            if (filter == null)
            {
                filter = new FilterLoggerSettings
                {
                    { "*", LogLevel.Warning }
                };
            }
            _filter = filter;

            _options = options ?? new ElmahIoProviderOptions();
        }
예제 #7
0
 public static ILoggerFactory AddElmahIo(this ILoggerFactory factory, string apiKey, Guid logId, FilterLoggerSettings filter, ElmahIoProviderOptions options)
 {
     factory.AddProvider(new ElmahIoLoggerProvider(apiKey, logId, filter, options));
     return(factory);
 }