Переглянути джерело

Add date time to console outputs

Tigran 4 роки тому
батько
коміт
13f6d3d1e3

+ 3 - 2
MafiaTelegramBot/Controllers/MessageController.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Globalization;
 using System.Threading;
 using System.Threading.Tasks;
 using MafiaTelegramBot.Models;
@@ -37,7 +38,7 @@ namespace MafiaTelegramBot.Controllers
 
         private static Task UnknownUpdateHandlerAsync(Update update)
         {
-            Console.WriteLine(update.Type);
+            Console.WriteLine($"[{DateTime.Now.ToString()}] {update.Type}");
             return Task.CompletedTask;
         }
 
@@ -51,7 +52,7 @@ namespace MafiaTelegramBot.Controllers
                 _ => exception.ToString()
             };
 
-            Console.WriteLine(errorMessage);
+            Console.WriteLine($"[{DateTime.Now.ToString()}] {errorMessage}");
             return Task.CompletedTask;
         }
     }

+ 2 - 2
MafiaTelegramBot/Game/GameRooms/GameRoom.GameProcess.cs

@@ -66,7 +66,7 @@ namespace MafiaTelegramBot.Game.GameRooms
                 }
                 catch (Exception e)
                 {
-                    await Console.Out.WriteLineAsync(e.Message);
+                    await Console.Out.WriteLineAsync($"[{DateTime.Now.ToString()}] {e.Message}");
                 }
 
                 await PlayersMessageChannel.SendSticker(Stickers.Sticker["Night"]);
@@ -95,7 +95,7 @@ namespace MafiaTelegramBot.Game.GameRooms
                 }
                 catch (Exception e)
                 {
-                    await Console.Out.WriteLineAsync(e.Message);
+                    await Console.Out.WriteLineAsync($"[{DateTime.Now.ToString()}] {e.Message}");
                 }
 
                 foreach (var player in Players.Values)

+ 4 - 5
MafiaTelegramBot/Models/Bot.cs

@@ -108,7 +108,7 @@ namespace MafiaTelegramBot.Models
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message);
+                Console.WriteLine($"[{DateTime.Now.ToString()}] {e.Message}");
                 return new Message();
             }
         }
@@ -121,7 +121,7 @@ namespace MafiaTelegramBot.Models
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message);
+                Console.WriteLine($"[{DateTime.Now.ToString()}] {e.Message}");
                 return new Message();
             }
         }
@@ -136,7 +136,7 @@ namespace MafiaTelegramBot.Models
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message);
+                Console.WriteLine($"[{DateTime.Now.ToString()}] {e.Message}");
                 return new Message();
             }
         }
@@ -150,7 +150,7 @@ namespace MafiaTelegramBot.Models
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message);
+                Console.WriteLine($"[{DateTime.Now.ToString()}] {e.Message}");
                 return new Message();
             }
         }
@@ -159,7 +159,6 @@ namespace MafiaTelegramBot.Models
         {
             var token = new CancellationToken();
             await Get().AnswerPreCheckoutQueryAsync(preCheckoutQueryId, token);
-            Console.WriteLine(token.IsCancellationRequested);
         }
 
         public static async Task RegisterNewUser(Update update)

+ 1 - 1
MafiaTelegramBot/Resources/Constants.cs

@@ -6,7 +6,7 @@ namespace MafiaTelegramBot.Resources
 {
     public static class Constants
     {
-        public const bool DEBUG = false;
+        public const bool DEBUG = true;
         
         public const int PLAYER_LIMITS_MIN = DEBUG ? 1 : 6;
         public const int MEMORY_CLEANER_INTERVAL = 60 * 60 * 1000;