File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ itself has been updated to dotnet 8.0 and is now using the new information
1515- Introduced software unit tests [ #17 ] ( https://github.com/stprograms/SuperSoco485Monitor/issues/17 )
1616- Introduced timestamp for telegrams [ #22 ] ( https://github.com/stprograms/SuperSoco485Monitor/issues/22 )
1717- Introduced storing of telegrams with timestamp [ #23 ] ( https://github.com/stprograms/SuperSoco485Monitor/issues/23 )
18+ - Showing offset to previous telegram in time view [ #24 ] ( https://github.com/stprograms/SuperSoco485Monitor/issues/24 )
1819
1920## 1.2.0
2021### Modified
Original file line number Diff line number Diff line change 11using NLog ;
22
33/// <summary>
4- /// Simple class printing the telegram to the log
4+ /// Simple class printing the telegram to the log.
5+ ///
6+ /// It will print the telegrams in the following format:
7+ /// - offset to the last telegram in milliseconds
8+ /// - Raw data of the telegram
9+ /// - Detailed string representation of the telegram
510/// </summary>
611public class LogPrinter : IUserVisualizable
712{
8-
913 /// <summary>
1014 /// class logger
1115 /// </summary>
1216 private static readonly Logger log = LogManager . GetCurrentClassLogger ( ) ;
17+ /// <summary>
18+ /// Timestamp of the last printed telegram.
19+ ///
20+ /// If no telegram was printed yet, it is null.
21+ /// </summary>
22+ private DateTime ? lastTelegramTimestamp = null ;
1323
1424 /// <summary>
1525 /// Flush output
@@ -25,6 +35,9 @@ public void Flush()
2535 /// <param name="tg"></param>
2636 public void PrintTelegram ( BaseTelegram tg )
2737 {
28- log . Info ( tg . ToStringDetailed ( ) ) ;
38+ var offset = lastTelegramTimestamp . HasValue ? tg . TimeStamp - lastTelegramTimestamp . Value : TimeSpan . Zero ;
39+ lastTelegramTimestamp = tg . TimeStamp ;
40+
41+ log . Info ( $ "[{ offset . TotalMilliseconds , 5 : N0} ms] { tg . ToStringDetailed ( ) } ") ;
2942 }
30- }
43+ }
You can’t perform that action at this time.
0 commit comments