コード例 #1
0
        public static void AddEntry(ServerLogEntry newEntry)
        {
            lock (SyncRoot)
            {
                Entries.AddLast(newEntry);
                if (Entries.Count > MaxEntries)
                {
                    Entries.RemoveFirst();
                }

                if (MaxLogEntry == null)
                {
                    MaxLogEntry = newEntry;
                }
                else if (MaxLogEntry.CacheAccessTimeInMilliseconds < newEntry.CacheAccessTimeInMilliseconds)
                {
                    MaxLogEntry = newEntry;
                }
            }

            ExternalLog?.LogInfo(newEntry.ToString());
        }
コード例 #2
0
 private bool ParseLine(string line, int lineNumber, out ServerLogEntryBase entry)
 {
     entry = null;
     var match = _channelCallPattern.Match(line);
     if (match.Success)
     {
         if (!_includeChannelCall)
         {
             return false;
         }
         var g = match.Groups;
         entry = new ServerLogChannelCallEntry(
             LogFile,
             lineNumber,
             DateTime.ParseExact(
                 g["when"].Value,
                 "yyyy-MM-dd HH:mm:ss,fff",
                 CultureInfo.InvariantCulture,
                 DateTimeStyles.AssumeLocal),
             g["op"].Value,
             g["client"].Value,
             int.Parse(g["recb"].Value),
             int.Parse(g["rect"].Value),
             int.Parse(g["sentb"].Value),
             int.Parse(g["sendt"].Value),
             int.Parse(g["prt"].Value),
             int.Parse(g["sert"].Value),
             int.Parse(g["dest"].Value),
             int.Parse(g["mt"].Value),
             int.Parse(g["zip"].Value),
             g["ip"].Value);
         return true;
     }
     match = _perfUpdatePattern.Match(line);
     if (match.Success)
     {
         if (!_includePerfUpdate)
         {
             return false;
         }
         var g = match.Groups;
         var op = g["op"].Value;
         if (g["query"].Success)
         {
             op += ' ' + g["query"].Value;
         }
         entry = new ServerLogUpdatePerfEntry(
             LogFile,
             lineNumber,
             DateTime.ParseExact(
                 g["when"].Value,
                 "yyyy-MM-dd HH:mm:ss,fff",
                 CultureInfo.InvariantCulture,
                 DateTimeStyles.AssumeLocal),
             op,
             int.Parse(g["optime"].Value));
         return true;
     }
     match = _serverLogPattern.Match(line);
     if (match.Success)
     {
         if (!(_includeChannel || _includeOperation))
         {
             return false;
         }
         var g = match.Groups;
         var se = new ServerLogEntry(
             LogFile,
             lineNumber,
             DateTime.ParseExact(
                 g["when"].Value,
                 "yyyy-MM-dd HH:mm:ss,fff",
                 CultureInfo.InvariantCulture,
                 DateTimeStyles.AssumeLocal),
             GetSeverity(g["Severity"].Value),
             g["Kind"].Value,
             g["op"].Value);
         if (se.Kind == "Operations" && _includeOperation)
         {
             entry = se;
             return true;
         }
         if (se.Kind == "Channel" && _includeChannel)
         {
             entry = se;
             return true;
         }
         return false;
     }
     match = _errorPattern.Match(line);
     if (match.Success)
     {
         if (!_includeError)
         {
             return false;
         }
         var g = match.Groups;
         entry = new ServerLogErrorEntry(
             LogFile,
             lineNumber,
             DateTime.ParseExact(
                 g["when"].Value,
                 "yyyy-MM-dd HH:mm:ss,fff",
                 CultureInfo.InvariantCulture,
                 DateTimeStyles.AssumeLocal),
             g["error"].Value);
         return true;
     }
     if (_includeUnknown)
     {
         entry = new ServerLogEntry(LogFile, lineNumber, DateTime.MinValue, LogSeverity.Unknown, "Unknown", line);
         return true;
     }
     return false;
 }