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++; } }
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>"); }
private void AppendWithAllAppenders(string message, ReportLevel reportLevel) { string reportLevelString = reportLevel.ToString(); foreach (var appender in Appenders) { appender.Append(reportLevelString, message); } }
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++; } }
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++; } }
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++; } }
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); } } }
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++; } }
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); }
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()); }
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++; } }
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); }
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()); }
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()); }
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++; } }
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++; } } }
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()); }
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(); }
public override string FormatMessage(ReportLevel level, string date, string message) { return(string.Format($"{date} - {level.ToString().ToUpper()} - {message}")); }
public override string ToString() { return($"Appender type: {this.GetType().Name}, Layout type: {layout.GetType().Name}, Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {AppendedMessages}"); }
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()); }
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"); }
public string Layout(ReportLevel reportLevel, string message) { return string.Format("{0} - {1} - {2}", DateTime.Now, reportLevel.ToString(), message); }
public override string ToString() { return($"Appender type: {GetType().Name}, Layout type: {Layout.GetType().Name}, " + $"Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {MessageCount}"); }
/// <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())); }
public string FormatLogData(string dateAndTime, string message, ReportLevel reportLevel) { string result = $"{dateAndTime} - {reportLevel.ToString().ToUpper()} - {message}"; return(result); }
public string Layout(ReportLevel reportLevel, string message) { return(string.Format("{0} - {1} - {2}", DateTime.Now, reportLevel.ToString(), message)); }
public string Formatting(ReportLevel reportLevel, string date, string message) { return($"{date} - {reportLevel.ToString().ToUpper()} - {message}"); }
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++; }