public void Create()
		{
			var formatter = new TableMessageFormatter();
			Assert.Equal(CultureInfo.InvariantCulture, formatter.FormatProvider);
			Assert.Equal(LogMessageField.None, formatter.FormattedFields);

			// the formatter should not contain any columns at start
			// => the output should be an empty string
			string output = formatter.Format(new LogMessage());
			Assert.Equal("", output);
		}
		public void Format(LogMessageField fields, LogMessage message, string expected)
		{
			var formatter = new TableMessageFormatter();

			if (fields.HasFlag(LogMessageField.Timestamp)) formatter.AddTimestampColumn();
			if (fields.HasFlag(LogMessageField.HighPrecisionTimestamp)) formatter.AddHighPrecisionTimestampColumn();
			if (fields.HasFlag(LogMessageField.LogWriterName)) formatter.AddLogWriterColumn();
			if (fields.HasFlag(LogMessageField.LogLevelName)) formatter.AddLogLevelColumn();
			if (fields.HasFlag(LogMessageField.Tags)) formatter.AddTagsColumn();
			if (fields.HasFlag(LogMessageField.ApplicationName)) formatter.AddApplicationNameColumn();
			if (fields.HasFlag(LogMessageField.ProcessName)) formatter.AddProcessNameColumn();
			if (fields.HasFlag(LogMessageField.ProcessId)) formatter.AddProcessIdColumn();
			if (fields.HasFlag(LogMessageField.Text)) formatter.AddTextColumn();

			Assert.Equal(fields, formatter.FormattedFields);

			string output = formatter.Format(message);
			Assert.Equal(expected, output);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessNameColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public ProcessNameColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.ProcessName)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnBase"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 /// <param name="field">The formatted log message field.</param>
 protected ColumnBase(TableMessageFormatter formatter, LogMessageField field)
 {
     Formatter = formatter;
     Field     = field;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagsColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public TagsColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.Tags)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TextColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public TextColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.Text)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TimestampColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 /// <param name="format">Timestamp format to use.</param>
 public TimestampColumn(TableMessageFormatter formatter, string format = "u") : base(formatter, LogMessageField.Timestamp)
 {
     TimestampFormat = format;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogLevelColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public LogLevelColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.LogLevelName)
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogWriterColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public LogWriterColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.LogWriterName)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationNameColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public ApplicationNameColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.ApplicationName)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HighPrecisionTimestampColumn"/> class.
 /// </summary>
 /// <param name="formatter">The formatter the column belongs to.</param>
 public HighPrecisionTimestampColumn(TableMessageFormatter formatter) : base(formatter, LogMessageField.HighPrecisionTimestamp)
 {
 }