Exemplo n.º 1
0
 public void OnMemLog(object sender, MemLogEventArgs e)
 {
     lock (_lock)
     {
         _log.Add(e.Log); // store log and immediately unlock
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Write Log
        /// </summary>
        /// <param name="text">Log Text</param>
        public void WriteLine(string text)
        {
            if ((_minLogLevel > LogLevel.None) || (!_logFileIsOpened))
            {
                return;
            }


            lock (_lock)
            {
                DateTime dateTime = DateTime.Now;

                MemLogEventArgs memLogEventArgs = new MemLogEventArgs {
                    TimeReached = dateTime
                };


                string formattedTime = String.Format("{0:yyyy/MM/dd; HH:mm:ss.fff}", dateTime);


                GetMethodName(out string className, out string methodName);

                memLogEventArgs.Log = string.Format("{0,-26}; {1,-11}; {2,-14}; {3,-17}; {4,-33}\r\n", formattedTime, LogLevel.None.ToString(), className, methodName, text);

                _logList.Add(memLogEventArgs);
                _logLines++;

                if (_useMemLog)
                {
                    memLogEventArgs.Log = String.Format("{0:HH:mm:ss.fff; }", dateTime) + LogLevel.None.ToString() + "; " + text;
                    _memLogList.Add(memLogEventArgs);
                    OnMemLog(memLogEventArgs);
                }

                if (_logLines >= MAX_LOG_LINES_BEFORE_FLUSH)
                {
                    Flush();
                }
            }
        }
Exemplo n.º 3
0
 protected virtual void OnMemLog(MemLogEventArgs e)
 {
     MemLog?.Invoke(this, e);
 }