Ejemplo n.º 1
0
        public override void LogEntry(LogEntryBase entry)
        {
            // Write log entry line.
            // Override this
            if (!IsEnabled(entry.LevelId))   // ignore this entry?
            {
                return;
            }

            try
            {
                DateTime tLocalNow = DateTime.Now;       // local server time for log file stamp
                lock (this) using (var w = OpenLogFile(tLocalNow))
                    {
                        if (w == null)
                        {
                            return;
                        }
                        w.WriteLine(string.Concat(tLocalNow.ToDtString("HH:mm:ss"), GetSeparator(entry.LevelId), entry.ToString())); // local TZ
                        if (!ValidState.IsEmpty(entry.Detail))
                        {
                            w.WriteLine("\t" + entry.Detail);
                        }
                        if (entry.LevelId >= LogLevel.Error || LoggerUtil.LogStart != null)  // important messages should be flushed immediately. In case we crash.
                        {
                            w.Flush();
                        }
                    }
            }
            catch
            {
                // Don't throw if failed to log.
            }
        }
Ejemplo n.º 2
0
        public virtual void LogEntry(LogEntryBase entry)    // ILogger
        {
            // ILogger Override this
            // default behavior = debug.

            if (!IsEnabled(entry.LevelId))   // ignore this?
            {
                return;
            }

            if (ValidState.IsValidId(entry.UserId))
            {
            }
            if (entry.Detail != null)
            {
            }

            System.Diagnostics.Debug.WriteLine(GetSeparator(entry.LevelId) + entry.ToString());
        }