示例#1
0
 internal static void Truncate(QLogEntry log)
 {
     log.Area = TruncateString(log.Area, AREA_MAX_LENGTH);
     log.AreaColor = TruncateString(log.AreaColor, AREA_COLOR_MAX_LENGTH);
     log.ThreadId = TruncateString(log.ThreadId, THREAD_ID_MAX_LENGTH);
     log.SessionId = TruncateString(log.SessionId, SESSION_ID_MAX_LENGTH);
     log.UserAgent = TruncateString(log.UserAgent, USER_AGENT_MAX_LENGTH);
     log.UserHost = TruncateString(log.UserHost, USER_HOST_MAX_LENGTH);
     log.Class = TruncateString(log.Class, CLASS_MAX_LENGTH);
     log.Method = TruncateString(log.Method, METHOD_MAX_LENGTH);
 }
示例#2
0
 /// <summary>
 /// Saves single log entry in data source.
 /// </summary>
 /// <param name="log"></param>
 public void Save(QLogEntry log)
 {
     CloudStorageAccount storageAccount = GetStorageAccount();
     CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
     string tableName = GetTableName(log);
     CloudTable table = tableClient.GetTableReference(tableName);
     table.CreateIfNotExists();
     log.PartitionKey = log.CreatedOn.ToString("HH");
     log.RowKey = String.Format("{0}{1}", (DateTime.MaxValue - log.CreatedOn).Ticks.ToString("d19"), log.Guid.ToString("N"));
     log.Message = log.Message.Trim();
     table.Execute(TableOperation.Insert(log));
 }
示例#3
0
 /// <summary>
 /// Returns QLog entry basing on the passed informations
 /// </summary>
 /// <param name="area"></param>
 /// <param name="msg"></param>
 /// <param name="className"></param>
 /// <param name="methodName"></param>
 /// <returns></returns>
 public QLogEntry GetLog(Type area, string msg, string className, string methodName)
 {
     QLogEntry result = new QLogEntry();
     result.Guid = Guid.NewGuid();
     result.Message = msg;
     result.Area = area.Name;
     result.AreaColor = AreaHelper.GetAreaColor(area);
     result.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString();
     result.SessionId = GetSessionId();
     result.UserAgent = GetUserAgent();
     result.UserHost = GetUserHost();
     result.Class = className;
     result.Method = methodName;
     result.InstanceId = GetInstanceId();
     result.DeploymentId = GetDeploymentId();
     result.CreatedOn = DateTime.UtcNow;
     TruncateHelper.Truncate(result);
     return result;
 }
示例#4
0
 public void Save(QLogEntry log)
 {
     Debug.WriteLine("{0} :: {1}", log.Area, log.Message);
 }
示例#5
0
 private string GetTableName(QLogEntry log)
 {
     string tableName = String.Format(DEFAULT_TABLE_NAME, log.CreatedOn.ToString("yyyyMMdd"));
     if (!String.IsNullOrWhiteSpace(ComponentsService.Config.GetDataSourcePostfix()))
     {
         tableName = String.Format(POSTFIX_TABLE_NAME, ComponentsService.Config.GetDataSourcePostfix().ToLower(), log.CreatedOn.ToString("yyyyMMdd"));
     }
     return tableName;
 }
示例#6
0
 /// <summary>
 /// Saves single QLog entry in to the buffer and returns information whether buffer is full and should be flushed
 /// </summary>
 /// <param name="log"></param>
 /// <param name="isBufferFull"></param>
 public void Enqueue(QLogEntry log, out bool isBufferFull)
 {
     isBufferFull = false;
     if (!EnqueueWithAdditionalBuffer(log, out isBufferFull))
         EnqueueLogWithStaticBuffer(log, out isBufferFull);
 }
示例#7
0
        /// <summary>
        /// Tries to enqueue an object with an additional buffer. If it's not possible - returns false.
        /// </summary>
        /// <returns></returns>
        private bool EnqueueWithAdditionalBuffer(QLogEntry log, out bool isBufferFull)
        {
            isBufferFull = false;
            if ((HttpContext.Current == null) || (HttpContext.Current.Items == null))
                return false;

            if (HttpContext.Current.Items[LOGS_QUEUE_KEY] != null)
            {
                Queue<QLogEntry> logEntries = (Queue<QLogEntry>)HttpContext.Current.Items[LOGS_QUEUE_KEY];
                logEntries.Enqueue(log);
            }
            else
            {
                Queue<QLogEntry> logEntries = new Queue<QLogEntry>();
                logEntries.Enqueue(log);
                HttpContext.Current.Items[LOGS_QUEUE_KEY] = logEntries;
            }
            if (IsRequestBufferFull())
                isBufferFull = true;

            return true;
        }
示例#8
0
 /// <summary>
 /// Enqueues log entry using static queue buffer _logEntries
 /// </summary>
 /// <param name="log"></param>
 /// <param name="isBufferFull"></param>
 private void EnqueueLogWithStaticBuffer(QLogEntry log, out bool isBufferFull)
 {
     isBufferFull = false;
     lock (_locker)
     {
         _logEntries.Enqueue(log);
         if (IsStaticBufferFull())
             isBufferFull = true;
     }
 }