Exemple #1
0
        public void AddLogMessage(IComponentControl componentControl, LogMessage logMessage)
        {
            if (componentControl == null)
            {
                return;
            }
            if (logMessage == null)
            {
                return;
            }
            if (Disabled)
            {
                return;
            }
            var webLogs = new WebLogMessage()
            {
                Attemps          = 0,
                ComponentControl = componentControl,
                CreateDate       = DateTime.Now,
                Order            = Order,
                Date             = logMessage.Date,
                Level            = logMessage.Level,
                Message          = logMessage.Message,
                Context          = logMessage.Context,
                Properties       = logMessage.Properties
            };

            webLogs.Size = GetMessageSize(webLogs);
            LogQueue.Add(webLogs);
            Order++;

            OnAddLogMessage?.Invoke(componentControl, logMessage);
        }
Exemple #2
0
 public void Add(WebLogMessage message)
 {
     if (message != null)
     {
         lock (this)
         {
             Messages.Add(message);
             AllBytes += message.Size;
         }
     }
 }
Exemple #3
0
        protected virtual int GetMessageSize(WebLogMessage message)
        {
            int length = 40; // служебные поля componentId + дата + уровень

            length += StringHelper.GetLengthInMemory(message.Message);
            length += StringHelper.GetLengthInMemory(message.Context);
            if (message.Properties != null)
            {
                length += message.Properties.GetWebSize();
            }
            return(length);
        }