コード例 #1
0
 public void Append(string date, ReportLevel reportLevel, string message)
 {
     if (this.ReportLevel <= reportLevel)
     {
         Console.WriteLine(string.Format(this.layout.Format, date, reportLevel.ToString().ToUpper(), message));
         this.messagesAppended++;
     }
 }
コード例 #2
0
 public string Format(string message, ReportLevel reportLevel, string dateTime)
 {
     return("<log>" + Environment.NewLine +
            $"   <date>{dateTime}</date>" + Environment.NewLine +
            $"   <level>{reportLevel.ToString().ToUpper()}</level>" + Environment.NewLine +
            $"   <message>{message}</message>" + Environment.NewLine +
            "</log>");
 }
コード例 #3
0
 private void AppendWithAllAppenders(string message, ReportLevel reportLevel)
 {
     string reportLevelString = reportLevel.ToString();
     foreach (var appender in Appenders)
     {
         appender.Append(reportLevelString, message);
     }
 }
コード例 #4
0
 public override void AppendLine(string dateTime, ReportLevel level, string msg)
 {
     if (level >= this.ReportLevel)
     {
         Console.WriteLine(this.Layout.Format, dateTime, level.ToString().ToUpper(), msg);
         this.AppendedMessages++;
     }
 }
コード例 #5
0
 public void AppendLine(string time, ReportLevel reportLevel, string message)
 {
     if (this.ReportLevel <= reportLevel)
     {
         Console.WriteLine(string.Format(this.Layout.Format, time, reportLevel.ToString().ToUpper(), message));
         this.MessageCount++;
     }
 }
コード例 #6
0
        public void Append(string datetime, ReportLevel reportLevel, string errorMessage)
        {
            if (this.ReportLevel <= reportLevel)
            {
                Console.WriteLine(String.Format(layout.Format, datetime, reportLevel.ToString().ToUpper(), errorMessage));

                AppendedMessages++;
            }
        }
コード例 #7
0
 private void AppendMessageToAllAvailable(string date, string message, ReportLevel reportLevel)
 {
     foreach (IAppender appender in appenders)
     {
         if ((int)appender.ReportLevel <= (int)reportLevel)
         {
             appender.Append(date, reportLevel.ToString(), message);
         }
     }
 }
コード例 #8
0
 public void Append(string date, ReportLevel reportLevel, string message)
 {
     if (this.ReportLevel <= reportLevel)
     {
         string text = string.Format(this.layout.Format, date, reportLevel.ToString().ToUpper(), message);
         File.AppendAllText(path, text + Environment.NewLine);
         this.logFile.Write(text);
         this.messagesAppended++;
     }
 }
コード例 #9
0
        public string GetMessage(ReportLevel level)
        {
            string msg = GetReportMessageByFile(level.ToString());

            msg = msg.Replace("{time}", DateTime.Now.ToString("yyyy/MM/dd HH:mm"));
            msg = msg.Replace("{duration}", errorDuration.ToString());
            msg = msg.Replace("{log}", log);

            return(msg);
        }
コード例 #10
0
    public override string FormatMessage(ReportLevel level, string date, string message)
    {
        var sb = new StringBuilder();

        sb.AppendLine("<log>")
        .AppendLine($"  <date>{date}</date>")
        .AppendLine($"  <level>{level.ToString().ToUpper()}</level>")
        .AppendLine($"  <message>{message}</message>")
        .Append("</log>");
        return(sb.ToString());
    }
コード例 #11
0
        public void Append(string datetime, ReportLevel reportLevel, string errorMessage)
        {
            if (this.ReportLevel <= reportLevel)
            {
                string content = string.Format(this.layout.Format, datetime, reportLevel.ToString().ToUpper(), errorMessage);
                File.AppendAllText(path, content + "\n");
                logFile.Write(content);

                AppendedMessages++;
            }
        }
コード例 #12
0
        public override string Status()
        {
            string appenderType = this.GetType().Name;

            string result = $"Appender type: {appenderType}, " +
                            $"Layout type: {LayoutType.GetType().Name}, " +
                            $"Report level: {ReportLevel.ToString().ToUpper()}, " +
                            $"Messages appended: {MessagesAppended}";

            return(result);
        }
コード例 #13
0
        public string FormatMessage(string date, ReportLevel reportLevel, string message)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("<log>")
            .AppendLine($"  <date>{date}</date>")
            .AppendLine($"  <level>{reportLevel.ToString().ToUpper()}</level>")
            .AppendLine($"  <message>{message}</message>")
            .AppendLine("</log>");

            return(builder.ToString().TrimEnd());
        }
コード例 #14
0
        public string Formatting(ReportLevel reportLevel, string date, string msg)
        {
            var sb = new StringBuilder();

            sb.AppendLine("<log>");
            sb.AppendLine($"    <date>{date}</date>");
            sb.AppendLine($"    <level>{reportLevel.ToString().ToUpper()}</level>");
            sb.AppendLine($"    <message>{msg}</message>");
            sb.AppendLine("</log>");

            return(sb.ToString().Trim());
        }
    public string FormatLogData(string dateAndTime, string message, ReportLevel reportLevel)
    {
        StringBuilder result = new StringBuilder();

        result.AppendLine("<log>");
        result.AppendLine($"{Indent}<date>{dateAndTime}</date>");
        result.AppendLine($"{Indent}<level>{reportLevel.ToString().ToUpper()}</level>");
        result.AppendLine($"{Indent}<message>{message}</message>");
        result.Append("</log>");

        return(result.ToString());
    }
コード例 #16
0
        public override void Append(string datetime, ReportLevel reportLevel, string message)
        {
            if (this.IsReportLevelInRange(reportLevel))
            {
                string result = string.Format(this.layout.Layout,
                                              datetime,
                                              reportLevel.ToString().ToUpper(),
                                              message);

                Console.WriteLine(result);
                this.appendCounter++;
            }
        }
コード例 #17
0
 public override void AppendLine(string dateTime, ReportLevel level, string msg)
 {
     if (level >= this.ReportLevel)
     {
         using (StreamWriter writer = new StreamWriter(this.file.Path, true))
         {
             string message = string.Format(this.Layout.Format, dateTime, level.ToString().ToUpper(), msg);
             this.file.Write(message);
             writer.WriteLine(message);
             this.AppendedMessages++;
         }
     }
 }
コード例 #18
0
ファイル: XmlLayout.cs プロジェクト: ranjithmurthy/HQC
        public string Layout(ReportLevel reportLevel, string message)
        {
            this.stringBuilder.AppendLine("<log>");

            this.stringBuilder.Append("\t<date>");
            this.stringBuilder.Append(string.Format("{0}", DateTime.Now));
            this.stringBuilder.AppendLine("</date>");

            this.stringBuilder.Append("\t<level>");
            this.stringBuilder.Append(string.Format("{0}", reportLevel.ToString()));
            this.stringBuilder.AppendLine("</level>");

            this.stringBuilder.Append("\t<message>");
            this.stringBuilder.Append(string.Format("{0}", message));
            this.stringBuilder.AppendLine("</message>");

            this.stringBuilder.AppendLine("</log>");

            return(this.stringBuilder.ToString());
        }
コード例 #19
0
ファイル: XmlLayout.cs プロジェクト: ivayloivanof/HQC
        public string Layout(ReportLevel reportLevel, string message)
        {
            this.stringBuilder.AppendLine("<log>");

            this.stringBuilder.Append("\t<date>");
            this.stringBuilder.Append(string.Format("{0}", DateTime.Now));
            this.stringBuilder.AppendLine("</date>");

            this.stringBuilder.Append("\t<level>");
            this.stringBuilder.Append(string.Format("{0}", reportLevel.ToString()));
            this.stringBuilder.AppendLine("</level>");

            this.stringBuilder.Append("\t<message>");
            this.stringBuilder.Append(string.Format("{0}", message));
            this.stringBuilder.AppendLine("</message>");

            this.stringBuilder.AppendLine("</log>");

            return this.stringBuilder.ToString();
        }
コード例 #20
0
 public override string FormatMessage(ReportLevel level, string date, string message)
 {
     return(string.Format($"{date} - {level.ToString().ToUpper()} - {message}"));
 }
コード例 #21
0
 public override string ToString()
 {
     return($"Appender type: {this.GetType().Name}, Layout type: {layout.GetType().Name}, Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {AppendedMessages}");
 }
コード例 #22
0
        public string Write(ILayout layout, IError error)
        {
            string format = layout.Format;

            DateTime    dateTime    = error.DateTime;
            ReportLevel reportLevel = error.ReportLevel;
            string      message     = error.Message;

            string formatedMessage = String.Format(format,
                                                   dateTime.ToString(GlobalConstants.DATE_TIME_FORMAT,
                                                                     CultureInfo.InvariantCulture), reportLevel.ToString(), message) + Environment.NewLine;

            return(formatedMessage);
        }
 /// <summary>
 /// Provides a (valid) string representation of the provided ReportLevel.
 /// </summary>
 /// <param name="value">The value to serialize to string.</param>
 /// <returns>A (valid) string representation of the provided ReportLevel.</returns>
 private static string ReportLevelToString(ReportLevel value)
 {
     return LevelToString(value.ToString());
 }
コード例 #24
0
 public override string ToString()
 {
     return($"Appender type: {GetType().Name}, Layout type: {Layout.GetType().Name}, Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {AppendedMessages}, File size: {LogFile.Size}\n");
 }
コード例 #25
0
ファイル: SimpleLayout.cs プロジェクト: ivayloivanof/HQC
 public string Layout(ReportLevel reportLevel, string message)
 {
     return string.Format("{0} - {1} - {2}", DateTime.Now, reportLevel.ToString(), message);
 }
コード例 #26
0
ファイル: Appender.cs プロジェクト: MartiHr/Softuni
 public override string ToString()
 {
     return($"Appender type: {GetType().Name}, Layout type: {Layout.GetType().Name}, " +
            $"Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {MessageCount}");
 }
コード例 #27
0
 /// <summary>
 /// Provides a (valid) string representation of the provided ReportLevel.
 /// </summary>
 /// <param name="value">The value to serialize to string.</param>
 /// <returns>A (valid) string representation of the provided ReportLevel.</returns>
 private static string ReportLevelToString(ReportLevel value)
 {
     return(LevelToString(value.ToString()));
 }
コード例 #28
0
    public string FormatLogData(string dateAndTime, string message, ReportLevel reportLevel)
    {
        string result = $"{dateAndTime} - {reportLevel.ToString().ToUpper()} - {message}";

        return(result);
    }
コード例 #29
0
 public string Layout(ReportLevel reportLevel, string message)
 {
     return(string.Format("{0} - {1} - {2}", DateTime.Now, reportLevel.ToString(), message));
 }
コード例 #30
0
 public string Formatting(ReportLevel reportLevel, string date, string message)
 {
     return($"{date} - {reportLevel.ToString().ToUpper()} - {message}");
 }
コード例 #31
0
        public void Append(IError error)
        {
            string format = this.Layout.Format;

            DateTime    dateTime    = error.DateTime;
            ReportLevel reportLevel = error.ReportLevel;
            string      message     = error.Message;

            string formatedMessage = String.Format(format,
                                                   dateTime.ToString(GlobalConstants.DATE_TIME_FORMAT,
                                                                     CultureInfo.InvariantCulture), reportLevel.ToString(), message);

            Console.WriteLine(formatedMessage);
            this.MessagesAppended++;
        }