コード例 #1
0
ファイル: Logger.cs プロジェクト: waldfee/stackify-api-dotnet
        /// <summary>
        /// Used to check if there have been recent failures or if the queue is backed up and if logs can be sent or not
        /// </summary>
        /// <returns></returns>
        public static bool CanSend()
        {
            if (_LogClient == null)
            {
                return(false);
            }

            return(_LogClient.CanQueue());
        }
コード例 #2
0
 protected override void Write(AsyncLogEventInfo logEvent)
 {
     try
     {
         //make sure the buffer isn't overflowing
         //if it is skip since we can't do anything with the message
         if (StackifyLib.Logger.PrefixEnabled() || _logClient.CanQueue())
         {
             var logMsg = Translate(logEvent.LogEvent);
             if (logMsg != null)
             {
                 _logClient.QueueMessage(logMsg);
             }
             logEvent.Continuation(null); // Signal success to NLog
         }
         else
         {
             InternalLogger.Warn("StackifyTarget: Cannot send because queue is full");
             logEvent.Continuation(new OperationCanceledException("StackifyTarget: Cannot send because queue is full")); // Signal failure to NLog
             StackifyAPILogger.Log("Unable to send log because the queue is full");
         }
     }
     catch (Exception ex)
     {
         InternalLogger.Error("StackifyTarget: Failed to send");
         logEvent.Continuation(ex);  // Signal failure to NLog
         StackifyAPILogger.Log(ex.ToString());
     }
 }
コード例 #3
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            try
            {
                //make sure the buffer isn't overflowing
                //if it is skip since we can't do anything with the message

                if (Logger.PrefixEnabled() || _logClient.CanQueue())
                {
                    var logMsg = Translate(loggingEvent);
                    if (logMsg != null)
                    {
                        _logClient.QueueMessage(logMsg);
                    }
                }
                else
                {
                    StackifyAPILogger.Log("Unable to send log because the queue is full");
                }
            }
            catch (Exception ex)
            {
                StackifyAPILogger.Log(ex.ToString());
            }
        }