Exemple #1
0
        public void Init(HttpApplication context)
        {
            var count = Interlocked.Increment(ref initializedModuleCount);

            if (count != 1)
            {
                return;
            }

            timer = new Timer(_ =>
            {
                try
                {
                    if (LogglyId != null && LogglyPw != null)
                    {
                        var basicParam = Encoding.ASCII.GetBytes($"{LogglyId}:{LogglyPw}");
                        Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(basicParam));
                        Loggly.Ranking.Hourly = GetRankingData("h");
                        Loggly.Ranking.Daily  = GetRankingData("d");
                        Loggly.Ranking.Weekly = GetRankingData("w");
                        Loggly.SendJob(nameof(GetRankingModule)).Wait();
                    }
                }
                catch (Exception ex)
                {
                    Loggly.SendError(ex).FireAndForget();
                }
            }, null, TimeSpan.Zero, TimeSpan.FromMinutes(10));
        }
 public static void SetImage(string key, byte[] image)
 {
     try
     {
         SafeConn?.GetDatabase().StringSet(key, image, TimeSpan.FromDays(1), flags: CommandFlags.FireAndForget);
     }
     catch (Exception e)
     {
         Loggly.SendError(e).FireAndForget();
     }
 }
 public static async Task <byte[]> GetImage(string key)
 {
     try
     {
         var db = SafeConn?.GetDatabase();
         if (db == null)
         {
             return(null);
         }
         return(await db.StringGetAsync(key));
     }
     catch (Exception e)
     {
         Loggly.SendError(e).FireAndForget();
         return(null);
     }
 }
Exemple #4
0
 public override void Log(ExceptionLoggerContext context)
 {
     Loggly.SendError(context.Exception).FireAndForget();
 }
Exemple #5
0
 public async override Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
 {
     await Loggly.SendError(context.Exception);
 }