示例#1
0
        public LogListItem(object eventSource, LogEventArg eventArg)
        {
            this.EventDate   = DateTime.Now;
            this.EventSource = eventSource;

            base.Level       = eventArg.Level;
            base.Title       = eventArg.Title;
            base.Message     = eventArg.Message;
            base.ShowAs      = eventArg.ShowAs;
        }
示例#2
0
        public LogListItem(object eventSource, LogEventArg eventArg)
        {
            this.EventDate   = DateTime.Now;
            this.EventSource = eventSource;

            base.Level   = eventArg.Level;
            base.Title   = eventArg.Title;
            base.Message = eventArg.Message;
            base.ShowAs  = eventArg.ShowAs;
        }
示例#3
0
        private void ApppendLogsTo(string logFileName, LogEventArg e)
        {
            if (logFileName.IsBlank()) return;
            switch (e.Level)
            {
                case L4j.Off:               //
                case L4j.Debug:             //  ignore these levels
                case L4j.Trace: return;     //
            }
            if (e.ShowAs != ShowLogAs.Normal) return;

            if (_logFile == null)
                _logFile = _fs.File(_fs.GetAssemblyDir().Bslash(logFileName));

            var line = L.f + TextLog.Format(e.Title, e.Message);
            _logFile.Write(line, EncodeAs.UTF8, false, false);
        }
示例#4
0
        private bool Arg(L4j level, ShowLogAs showAs, string title, string message)
        {
            if (level == L4j.Off)
            {
                return(false);
            }

            var e = new LogEventArg
            {
                Level   = level,
                ShowAs  = showAs,
                Title   = title,
                Message = message
            };

            try   { _logAdded?.Invoke(this, e); }
            catch { }

            return(e.Level.Polarity());
        }
示例#5
0
        public string RewriteToInclude(LogEventArg e)
        {
            switch (e.ShowAs)
            {
            case ShowLogAs.Normal:
                return(AppendNormal(e.Level, e.Title, e.Message));

            case ShowLogAs.Header:
                return(AppendHeader(e.Level, e.Title, e.Message));

            case ShowLogAs.Intro:
                return(AppendIntro(e.Level, e.Title));

            case ShowLogAs.Outro:
                return(AppendOutro(e.Level, e.Message));

            default:
                throw Error.Unsupported(e.ShowAs);
            }
        }
示例#6
0
        public string RewriteToInclude(LogEventArg e)
        {
            switch (e.ShowAs)
            {
                case ShowLogAs.Normal:
                    return AppendNormal(e.Level, e.Title, e.Message);

                case ShowLogAs.Header:
                    return AppendHeader(e.Level, e.Title, e.Message);
                    
                case ShowLogAs.Intro:
                    return AppendIntro(e.Level, e.Title);
                    
                case ShowLogAs.Outro:
                    return AppendOutro(e.Level, e.Message);
                    
                default:
                    throw Error.Unsupported(e.ShowAs);
            }
        }
示例#7
0
        public void ShowLog(object src, LogEventArg e)
        {
            if (Fired(e)) return;

            switch (e.ShowAs)
            {
                case ShowLogAs.Header:
                    this.LogHeader(e.Level, e.Title, e.Message);
                    break;

                case ShowLogAs.Intro:
                    this.LogIntro(e.Level, e.Title);
                    break;

                case ShowLogAs.Outro:
                    this.LogOutro(e.Level, e.Message);
                    break;

                default:
                    this.LogNormal(e.Level, e.Title, e.Message);
                    break;
            }
        }
示例#8
0
 public static string Format(LogEventArg e, int maxCol1Width = 40)
 {
     return(e.Title.AlignLeft(maxCol1Width)
            + " : " + e.Message);
 }
示例#9
0
        //public void LogNormal(L4j level, string col1, string col2)
        //    => _cons.LogNormal(level, col1, col2);

        public void ShowLog(object src, LogEventArg e)
            => _cons.ShowLog(src, e);
示例#10
0
 public static string Format(LogEventArg e, int maxCol1Width = 40)
 {
     return e.Title.AlignLeft(maxCol1Width) 
             + " : " + e.Message;
 }
示例#11
0
        //public void ScrollToEnd() => cons.ScrollToEnd();


        private static bool Fired(LogEventArg e, object o = null)
        {
            if (_evtHistory.TryGetValue(e, out o)) return true;
            _evtHistory.Add(e, null);
            return false;
        }