12345678910111213141516171819202122232425262728 |
- #if NETSTANDARD1_3
- #else
- using System;
- using System.Diagnostics;
- namespace NModbus.Logging
- {
- public class TraceModbusLogger : ModbusLogger
- {
- private const int LevelColumnSize = 15;
- private static readonly string BlankHeader = Environment.NewLine + new string(' ', LevelColumnSize);
- public TraceModbusLogger(LoggingLevel minimumLoggingLevel = LoggingLevel.Debug)
- : base(minimumLoggingLevel)
- {
- }
- protected override void LogCore(LoggingLevel level, string message)
- {
- message = message?.Replace(Environment.NewLine, BlankHeader) ?? string.Empty;
- Trace.WriteLine($"[{level}]".PadRight(LevelColumnSize) + message);
- }
- }
- }
- #endif
|