From 754f53c40476eccf26b3711a1ce3b343cfe6b8c0 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Sun, 30 Aug 2020 12:43:54 +0200 Subject: [PATCH] Change Logging to LoggingFacade --- ChaosBot/Discord/DiscordConnect.cs | 29 ++++----- ChaosBot/Discord/Modules/Admin/Clear.cs | 14 ++--- ChaosBot/Discord/Modules/Admin/Config.cs | 22 ++----- ChaosBot/Discord/Modules/Admin/RankCheck.cs | 13 +--- ChaosBot/Discord/Modules/Admin/Role.cs | 18 ++---- ChaosBot/Discord/Modules/User/Info.cs | 9 +-- ChaosBot/Discord/Modules/User/Level.cs | 11 +--- ChaosBot/Discord/Modules/User/Lodestone.cs | 20 ++----- ChaosBot/Discord/Modules/User/Points.cs | 25 ++------ ChaosBot/Discord/Modules/User/RaffleCmd.cs | 36 ++++------- ChaosBot/Discord/Modules/User/Roll.cs | 9 +-- .../Discord/PreConditions/CheckCommandPerm.cs | 7 +-- .../PreConditions/CheckModuleEnabled.cs | 8 +-- ChaosBot/Discord/Services/CommandHandler.cs | 19 +++--- .../Discord/Services/CustomCommandHandler.cs | 6 +- .../Discord/Services/ExperienceHandler.cs | 7 +-- .../Discord/Services/RoleReactionHandler.cs | 10 +--- ChaosBot/Discord/Services/TimerHandler.cs | 9 ++- ChaosBot/Logging.cs | 4 +- ChaosBot/LoggingFacade.cs | 59 +++++++++++++++++++ ChaosBot/Program.cs | 15 +++-- ChaosBot/Services/CheckPermissions.cs | 10 +--- ChaosBot/Services/LodestoneHttpProxy.cs | 9 +-- ChaosBot/Services/RestrictedConfig.cs | 11 +--- ChaosBot/Services/Timer.cs | 3 +- ChaosBot/WebServer/App/DiscordController.cs | 6 +- ChaosBot/WebServer/Startup.cs | 8 +-- 27 files changed, 166 insertions(+), 231 deletions(-) create mode 100644 ChaosBot/LoggingFacade.cs diff --git a/ChaosBot/Discord/DiscordConnect.cs b/ChaosBot/Discord/DiscordConnect.cs index 9571d96..a670739 100644 --- a/ChaosBot/Discord/DiscordConnect.cs +++ b/ChaosBot/Discord/DiscordConnect.cs @@ -1,5 +1,4 @@ -using NLog; -using System; +using System; using Discord; using Discord.Commands; using Discord.WebSocket; @@ -8,13 +7,11 @@ using ChaosBot.Discord.Services; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - namespace ChaosBot.Discord { public class DiscordConnect { public static DiscordSocketClient _client = null; - private static ILogger _logger = Program.Logger; public static async Task StartUp() { @@ -45,13 +42,13 @@ namespace ChaosBot.Discord } catch (Exception ex) { - _logger.Error($"DiscordConnect.StartUp: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } private static Task ReadyAsync() { - _logger.Info($"Connected as -> [{_client.CurrentUser}] :)"); + LoggingFacade.Info($"Connected as -> [{_client.CurrentUser}] :)"); return Task.CompletedTask; } @@ -69,7 +66,7 @@ namespace ChaosBot.Discord } catch (Exception ex) { - _logger.Error($"DiscordConnect.ConfigureServices: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } return csInfo; @@ -82,34 +79,34 @@ namespace ChaosBot.Discord switch (msg.Severity) { case LogSeverity.Critical: - _logger.Fatal(msg.Message); + LoggingFacade.Fatal(msg.Message); break; case LogSeverity.Debug: - _logger.Debug(msg.Message); + LoggingFacade.Debug(msg.Message); break; case LogSeverity.Error: - _logger.Error(msg.Message); + LoggingFacade.Error(msg.Message); break; case LogSeverity.Info: - _logger.Info(msg.Message); + LoggingFacade.Info(msg.Message); break; case LogSeverity.Warning: - _logger.Warn(msg.Message); + LoggingFacade.Warn(msg.Message); break; case LogSeverity.Verbose: - _logger.Trace(msg.Message); + LoggingFacade.Trace(msg.Message); break; default: - _logger.Trace(msg.Message); + LoggingFacade.Trace(msg.Message); break; } } catch (Exception ex) { - _logger.Error($"DiscordConnect.Log: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } return Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/Admin/Clear.cs b/ChaosBot/Discord/Modules/Admin/Clear.cs index 5392f62..7b70720 100644 --- a/ChaosBot/Discord/Modules/Admin/Clear.cs +++ b/ChaosBot/Discord/Modules/Admin/Clear.cs @@ -5,25 +5,22 @@ using System.Threading.Tasks; using System.Collections.Generic; using System.Reflection; using ChaosBot.Discord.PreConditions; -using NLog; namespace ChaosBot.Discord.Modules.Admin { public class Clear : ModuleBase { - private static readonly ILogger _logger = Program.Logger; - [Command("clear")] [Alias("purge")] [CheckCommandPerm("Admin")] - public async Task ClearCommand(int msgtoDelete = 1) + public async Task ClearCommand(int msgToDelete = 1) { try { - IEnumerable messages = await Context.Channel.GetMessagesAsync(msgtoDelete + 1).FlattenAsync(); + IEnumerable messages = await Context.Channel.GetMessagesAsync(msgToDelete + 1).FlattenAsync(); await ((ITextChannel) Context.Channel).DeleteMessagesAsync(messages); const int delay = 3000; - IUserMessage m = await ReplyAsync($"{Context.User.Mention}, {msgtoDelete} messages deleted."); + IUserMessage m = await ReplyAsync($"{Context.User.Mention}, {msgToDelete} messages deleted."); await Task.Delay(delay); await m.DeleteAsync(); } @@ -31,8 +28,9 @@ namespace ChaosBot.Discord.Modules.Admin { if(ex.Message.Contains("Messages must be younger than two weeks old.")) await ReplyAsync($"{Context.User.Mention}, You cannot delete messages older then 2 weeks old."); - _logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Debug($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.\n{ex.StackTrace}"); } } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/Admin/Config.cs b/ChaosBot/Discord/Modules/Admin/Config.cs index 2a12cc9..ab8c813 100644 --- a/ChaosBot/Discord/Modules/Admin/Config.cs +++ b/ChaosBot/Discord/Modules/Admin/Config.cs @@ -1,8 +1,6 @@ using System; -using System.Linq; using Discord.Commands; using System.Threading.Tasks; -using System.Reflection; using System.Text; using ChaosBot.Discord.PreConditions; using ChaosBot.Models; @@ -11,14 +9,11 @@ using ChaosBot.Services; using Discord; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; -using NLog; namespace ChaosBot.Discord.Modules.Admin { public class Config : ModuleBase { - private static readonly ILogger _logger = Program.Logger; - [Command("config")] [CheckCommandPerm("Admin")] public async Task ConfigCommand(string cmd = "help", string key = null, string value = null) @@ -38,8 +33,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -75,8 +69,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -111,8 +104,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -152,8 +144,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -191,9 +182,8 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/Admin/RankCheck.cs b/ChaosBot/Discord/Modules/Admin/RankCheck.cs index 0adff96..0707603 100644 --- a/ChaosBot/Discord/Modules/Admin/RankCheck.cs +++ b/ChaosBot/Discord/Modules/Admin/RankCheck.cs @@ -6,22 +6,16 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; -using System.Reflection; using System.Text; -using Antlr4.Runtime.Misc; using ChaosBot.Discord.PreConditions; using ChaosBot.Lodestone; using ChaosBot.Models; -using Microsoft.AspNetCore.Http; using Newtonsoft.Json; -using NLog; namespace ChaosBot.Discord.Modules.Admin { public class RankCheck : ModuleBase { - private static readonly ILogger _logger = Program.Logger; - [Command("rankCheck")] [Alias("rc")] [CheckCommandPerm("Admin")] @@ -127,7 +121,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -149,11 +143,10 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } return JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(JsonConvert.DeserializeObject(response).Data)); } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/Admin/Role.cs b/ChaosBot/Discord/Modules/Admin/Role.cs index 1389d88..2b4d63d 100644 --- a/ChaosBot/Discord/Modules/Admin/Role.cs +++ b/ChaosBot/Discord/Modules/Admin/Role.cs @@ -3,21 +3,17 @@ using Discord; using Discord.Commands; using System.Threading.Tasks; using System.Linq; -using System.Reflection; using System.Text; using System.Text.RegularExpressions; using ChaosBot.Discord.PreConditions; using ChaosBot.Models; using ChaosBot.Repositories; using Microsoft.EntityFrameworkCore; -using NLog; namespace ChaosBot.Discord.Modules.Admin { public class Role : ModuleBase { - private static readonly ILogger Logger = Program.Logger; - [Command("role")] [Alias("role help", "role info")] [CheckCommandPerm("Admin")] @@ -53,7 +49,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -118,8 +114,7 @@ namespace ChaosBot.Discord.Modules.Admin catch (Exception ex) { await ReplyAsync($"Something went wrong trying to process {m.Value}: {ex.Message}"); - Logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -128,7 +123,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -151,7 +146,7 @@ namespace ChaosBot.Discord.Modules.Admin foreach (Match m in Regex.Matches(input, pattern)) { - Logger.Info(m.Value); + LoggingFacade.Info(m.Value); try { IEmote emote; @@ -188,8 +183,7 @@ namespace ChaosBot.Discord.Modules.Admin catch (Exception ex) { await ReplyAsync($"Something went wrong trying to process {m.Value}: {ex.Message}"); - Logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -198,7 +192,7 @@ namespace ChaosBot.Discord.Modules.Admin } catch (Exception ex) { - Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } diff --git a/ChaosBot/Discord/Modules/User/Info.cs b/ChaosBot/Discord/Modules/User/Info.cs index e2c6e41..553d79e 100644 --- a/ChaosBot/Discord/Modules/User/Info.cs +++ b/ChaosBot/Discord/Modules/User/Info.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using System.Text; using System.Threading.Tasks; using ChaosBot.Discord.PreConditions; @@ -7,14 +6,11 @@ using ChaosBot.Repositories; using Discord; using Discord.Commands; using Microsoft.Extensions.Configuration; -using NLog; namespace ChaosBot.Discord.Modules.User { public class Info : ModuleBase { - private static readonly ILogger Logger = Program.Logger; - [Command("info")] [Alias("version")] [CheckCommandPerm("User")] @@ -41,9 +37,8 @@ namespace ChaosBot.Discord.Modules.User } catch(Exception ex) { - Logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/User/Level.cs b/ChaosBot/Discord/Modules/User/Level.cs index cd9acc5..90906f0 100644 --- a/ChaosBot/Discord/Modules/User/Level.cs +++ b/ChaosBot/Discord/Modules/User/Level.cs @@ -1,22 +1,16 @@ using System; using System.Linq; -using System.Reflection; using System.Text; using System.Threading.Tasks; using ChaosBot.Discord.PreConditions; using ChaosBot.Models; -using ChaosBot.Repositories; using Discord; using Discord.Commands; -using Microsoft.Extensions.Configuration; -using NLog; namespace ChaosBot.Discord.Modules.User { public class Level : ModuleBase { - private static readonly ILogger Logger = Program.Logger; - [Command("level")] [Alias("xp", "exp", "experience", "lvl")] [CheckCommandPerm("User")] @@ -71,9 +65,8 @@ namespace ChaosBot.Discord.Modules.User } catch(Exception ex) { - Logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/User/Lodestone.cs b/ChaosBot/Discord/Modules/User/Lodestone.cs index 36e56bc..c818100 100644 --- a/ChaosBot/Discord/Modules/User/Lodestone.cs +++ b/ChaosBot/Discord/Modules/User/Lodestone.cs @@ -5,23 +5,17 @@ using Discord.Commands; using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; -using System.Reflection; using ChaosBot.Discord.PreConditions; using ChaosBot.Lodestone; using ChaosBot.Models; using ChaosBot.Repositories; using ChaosBot.Services; -using Discord.Net; using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; -using NLog; namespace ChaosBot.Discord.Modules.User { public class Lodestone : ModuleBase { - private static readonly ILogger _logger = Program.Logger; - [Command("lodestone")] [Alias("ls")] [CheckCommandPerm("User")] @@ -69,8 +63,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -115,8 +108,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -143,7 +135,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -240,7 +232,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -267,7 +259,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -364,4 +356,4 @@ namespace ChaosBot.Discord.Modules.User return embed; } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Modules/User/Points.cs b/ChaosBot/Discord/Modules/User/Points.cs index 63cb333..8dabeeb 100644 --- a/ChaosBot/Discord/Modules/User/Points.cs +++ b/ChaosBot/Discord/Modules/User/Points.cs @@ -1,27 +1,20 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Text; using System.Threading.Tasks; using ChaosBot.Discord.PreConditions; -using ChaosBot.Migrations; using ChaosBot.Models; using Discord; using Discord.Commands; -using NLog; using ChaosBot.Repositories; using ChaosBot.Services; using Discord.WebSocket; using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; namespace ChaosBot.Discord.Modules.User { public class Points : ModuleBase { - private static ILogger _logger = Program.Logger; - [Command("points")] [CheckCommandPerm("User")] public async Task PointsCommand(string cmd = "total", SocketUser user = null, ulong Amount = 0) @@ -73,8 +66,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -110,8 +102,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -132,8 +123,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } await ReplyAsync($"{Context.User.Mention}, you have {cur} points.", false); @@ -175,8 +165,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } await ReplyAsync( @@ -283,8 +272,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -306,8 +294,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } await ReplyAsync( diff --git a/ChaosBot/Discord/Modules/User/RaffleCmd.cs b/ChaosBot/Discord/Modules/User/RaffleCmd.cs index 59e5b88..472adb4 100644 --- a/ChaosBot/Discord/Modules/User/RaffleCmd.cs +++ b/ChaosBot/Discord/Modules/User/RaffleCmd.cs @@ -1,13 +1,11 @@ using System; using System.Linq; -using System.Reflection; using System.Text; using System.Threading.Tasks; using ChaosBot.Discord.PreConditions; using ChaosBot.Models; using Discord; using Discord.Commands; -using NLog; using ChaosBot.Repositories; using ChaosBot.Services; using Discord.WebSocket; @@ -16,8 +14,6 @@ namespace ChaosBot.Discord.Modules.User { public class RaffleCmd : ModuleBase { - private static ILogger _logger = Program.Logger; - [Command("raffle")] [CheckCommandPerm("User")] public async Task RaffleCommand(string cmd = "total", SocketUser user = null, int Amount = 0) @@ -79,8 +75,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -120,8 +115,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -142,8 +136,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } await ReplyAsync($"{Context.User.Mention}, you have {cur} raffle tickets.", false); @@ -185,8 +178,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -221,8 +213,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } await ReplyAsync( @@ -250,16 +241,15 @@ namespace ChaosBot.Discord.Modules.User await dbContext.SaveChangesAsync(); } } + + await ReplyAsync( + $"{Context.User.Mention} has removed all raffle tickets from {user.Mention}.", + false); } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } - - await ReplyAsync( - $"{Context.User.Mention} has removed all raffle tickets from {user.Mention}.", - false); } [Command("raffle clear")] @@ -299,8 +289,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -332,8 +321,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } diff --git a/ChaosBot/Discord/Modules/User/Roll.cs b/ChaosBot/Discord/Modules/User/Roll.cs index 87c8021..6283f4e 100644 --- a/ChaosBot/Discord/Modules/User/Roll.cs +++ b/ChaosBot/Discord/Modules/User/Roll.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Reflection; using System.Text; using System.Threading.Tasks; using ChaosBot.Discord.PreConditions; @@ -8,14 +7,11 @@ using Dice; using Discord; using Discord.Commands; using Microsoft.VisualBasic; -using NLog; namespace ChaosBot.Discord.Modules.User { public class Roll : ModuleBase { - private static readonly ILogger _logger = Program.Logger; - [Command("roll")] [Alias("random", "dice")] [CheckCommandPerm("User")] @@ -53,8 +49,7 @@ namespace ChaosBot.Discord.Modules.User } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -129,4 +124,4 @@ namespace ChaosBot.Discord.Modules.User return sb.ToString(); } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/PreConditions/CheckCommandPerm.cs b/ChaosBot/Discord/PreConditions/CheckCommandPerm.cs index 0bd1ad3..cf1f16e 100644 --- a/ChaosBot/Discord/PreConditions/CheckCommandPerm.cs +++ b/ChaosBot/Discord/PreConditions/CheckCommandPerm.cs @@ -1,26 +1,23 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using ChaosBot.Models; using ChaosBot.Repositories; using Discord.Commands; using Discord.WebSocket; -using NLog; namespace ChaosBot.Discord.PreConditions { public class CheckCommandPerm : PreconditionAttribute { - private static ILogger _logger = Program.Logger; private readonly string _defaultRole; public CheckCommandPerm(string defaultRole) => _defaultRole = defaultRole; public override Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { // Debug information - _logger.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command.Name}"); + LoggingFacade.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command.Name}"); // If user is not SocketGuildUser, then return error if (!(context.User is SocketGuildUser gUser)) return Task.FromResult(PreconditionResult.FromError("You must be in a guild to run this command.")); @@ -79,7 +76,7 @@ namespace ChaosBot.Discord.PreConditions return Task.FromResult(PreconditionResult.FromSuccess()); } else - _logger.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default"); + LoggingFacade.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default"); } // Permission denied diff --git a/ChaosBot/Discord/PreConditions/CheckModuleEnabled.cs b/ChaosBot/Discord/PreConditions/CheckModuleEnabled.cs index b23b92e..502c7c5 100644 --- a/ChaosBot/Discord/PreConditions/CheckModuleEnabled.cs +++ b/ChaosBot/Discord/PreConditions/CheckModuleEnabled.cs @@ -1,25 +1,19 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using ChaosBot.Models; using ChaosBot.Repositories; using Discord.Commands; -using Discord.WebSocket; -using NLog; namespace ChaosBot.Discord.PreConditions { public class CheckModuleEnabled : PreconditionAttribute { - private static ILogger _logger = Program.Logger; private readonly string _moduleName; public CheckModuleEnabled(string moduleName) => _moduleName = moduleName; public override Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { // Debug information - _logger.Trace($"CheckModuleEnabled.CheckPermissionsAsync|Checking module enabled for module: {_moduleName}"); + LoggingFacade.Trace($"CheckModuleEnabled.CheckPermissionsAsync|Checking module enabled for module: {_moduleName}"); if (context.Guild == null) return Task.FromResult(PreconditionResult.FromError("This must be run in a guild.")); diff --git a/ChaosBot/Discord/Services/CommandHandler.cs b/ChaosBot/Discord/Services/CommandHandler.cs index f430c19..5411e82 100644 --- a/ChaosBot/Discord/Services/CommandHandler.cs +++ b/ChaosBot/Discord/Services/CommandHandler.cs @@ -19,7 +19,6 @@ namespace ChaosBot.Discord.Services private readonly CommandService _commands; private readonly DiscordSocketClient _client; private readonly IServiceProvider _services; - private readonly ILogger _logger = Program.Logger; public CommandHandler(IServiceProvider services) { @@ -43,7 +42,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - _logger.Error($"CommandHandler.CommandHandler: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -84,7 +83,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - _logger.Error($"CommandHandler.MessageReceivedAsync: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -119,8 +118,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -180,8 +178,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - _logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } @@ -191,22 +188,22 @@ namespace ChaosBot.Discord.Services { if (!command.IsSpecified) { - _logger.Error($"Command failed to execute for [{context.User.Username}] <-> [{result.ErrorReason}]!"); + LoggingFacade.Error($"Command failed to execute for [{context.User.Username}] <-> [{result.ErrorReason}]!"); return; } if (result.IsSuccess) { - _logger.Info($"Command [{command.Value.Name}] executed for -> [{context.User.Username}]"); + LoggingFacade.Info($"Command [{command.Value.Name}] executed for -> [{context.User.Username}]"); return; } - _logger.Warn($"{context.User.Username} attempted to access {command.Value.Name} and was denied -> [{result}]"); + LoggingFacade.Warn($"{context.User.Username} attempted to access {command.Value.Name} and was denied -> [{result}]"); await context.Channel.SendMessageAsync($"Sorry, {context.User.Username}, that command won't work for you.!"); } catch (Exception ex) { - _logger.Error($"CommandHandler.CommandExecutedAsync: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } diff --git a/ChaosBot/Discord/Services/CustomCommandHandler.cs b/ChaosBot/Discord/Services/CustomCommandHandler.cs index 66c5e9c..55c0f8b 100644 --- a/ChaosBot/Discord/Services/CustomCommandHandler.cs +++ b/ChaosBot/Discord/Services/CustomCommandHandler.cs @@ -1,17 +1,13 @@ using System; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using ChaosBot.Models; using Discord.Commands; -using NLog; namespace ChaosBot.Discord.Services { public static class CustomCommandHandler { - private static readonly ILogger Logger = Program.Logger; - public static async Task CheckCommand(SocketCommandContext context, int argPos) { try @@ -39,7 +35,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } return false; } diff --git a/ChaosBot/Discord/Services/ExperienceHandler.cs b/ChaosBot/Discord/Services/ExperienceHandler.cs index 47be2eb..6030dc5 100644 --- a/ChaosBot/Discord/Services/ExperienceHandler.cs +++ b/ChaosBot/Discord/Services/ExperienceHandler.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Reflection; using ChaosBot.Discord.PreConditions; using ChaosBot.Models; using ChaosBot.Repositories; @@ -8,14 +7,11 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Microsoft.EntityFrameworkCore; -using NLog; namespace ChaosBot.Discord.Services { public class ExperienceHandler { - private static readonly ILogger Logger = Program.Logger; - public static async void AddXp(SocketCommandContext context) { try @@ -100,8 +96,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - Logger.Error( - $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } diff --git a/ChaosBot/Discord/Services/RoleReactionHandler.cs b/ChaosBot/Discord/Services/RoleReactionHandler.cs index 39c4802..6b6d0eb 100644 --- a/ChaosBot/Discord/Services/RoleReactionHandler.cs +++ b/ChaosBot/Discord/Services/RoleReactionHandler.cs @@ -1,18 +1,14 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using ChaosBot.Models; using Discord; using Discord.WebSocket; -using NLog; namespace ChaosBot.Discord.Services { public static class RoleReactionHandler { - private static readonly ILogger Logger = Program.Logger; - public static async void HandleReactionAdded(Cacheable cacheableMessage, ISocketMessageChannel socketMessageChannel, SocketReaction reaction) { Optional optionalUser = reaction.User; @@ -38,7 +34,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } @@ -68,9 +64,9 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } } } -} \ No newline at end of file +} diff --git a/ChaosBot/Discord/Services/TimerHandler.cs b/ChaosBot/Discord/Services/TimerHandler.cs index 0a0a06e..bf462cb 100644 --- a/ChaosBot/Discord/Services/TimerHandler.cs +++ b/ChaosBot/Discord/Services/TimerHandler.cs @@ -10,7 +10,6 @@ namespace ChaosBot.Discord.Services { public static class TimerHandler { - private static readonly ILogger _logger = Program.Logger; private static DiscordSocketClient _client; public static void Initialize(IServiceProvider services) @@ -31,7 +30,7 @@ namespace ChaosBot.Discord.Services SocketGuild guild = _client.GetGuild(Convert.ToUInt64(serverConfig.Key)); if (guild == null) { - _logger.Warn($"Guild {Convert.ToUInt64(serverConfig.Key)} not found"); + LoggingFacade.Warn($"Guild {Convert.ToUInt64(serverConfig.Key)} not found"); return; } @@ -39,7 +38,7 @@ namespace ChaosBot.Discord.Services guild.GetChannel(Convert.ToUInt64(lodestoneChannelSloganDescriptionId)); if (socketChannel == null) { - _logger.Warn( + LoggingFacade.Warn( $"Channel {Convert.ToUInt64(lodestoneChannelSloganDescriptionId)} not found in server {guild.Name}"); return; } @@ -47,7 +46,7 @@ namespace ChaosBot.Discord.Services ITextChannel channel = socketChannel as ITextChannel; if (channel == null) { - _logger.Warn($"Could not cast channel {socketChannel.Id} to ITextChannel"); + LoggingFacade.Warn($"Could not cast channel {socketChannel.Id} to ITextChannel"); return; } @@ -61,7 +60,7 @@ namespace ChaosBot.Discord.Services } catch (Exception ex) { - _logger.Error($"TimerHandler.UpdateChannelSloganDescription: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); } } diff --git a/ChaosBot/Logging.cs b/ChaosBot/Logging.cs index 8bd4a1e..0bf2450 100644 --- a/ChaosBot/Logging.cs +++ b/ChaosBot/Logging.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.Reflection; using Microsoft.Extensions.Configuration; using NLog; using NLog.Extensions.Logging; @@ -22,4 +24,4 @@ namespace ChaosBot } } } -} \ No newline at end of file +} diff --git a/ChaosBot/LoggingFacade.cs b/ChaosBot/LoggingFacade.cs new file mode 100644 index 0000000..c473255 --- /dev/null +++ b/ChaosBot/LoggingFacade.cs @@ -0,0 +1,59 @@ +using System; +using System.Diagnostics; +using System.Reflection; +using NLog; + +namespace ChaosBot +{ + public static class LoggingFacade + { + private static ILogger GetLogger() + { + return Program.GetLogger(); + } + + public static bool IsTraceEnabled => GetLogger().IsTraceEnabled; + public static bool IsDebugEnabled => GetLogger().IsDebugEnabled; + public static bool IsInfoEnabled => GetLogger().IsInfoEnabled; + public static bool IsWarnEnabled => GetLogger().IsWarnEnabled; + public static bool IsErrorEnabled => GetLogger().IsErrorEnabled; + public static bool IsFatalEnabled => GetLogger().IsFatalEnabled; + + public static void Trace(object value) + { + GetLogger().Trace(value); + } + + public static void Debug(object value) + { + GetLogger().Debug(value); + } + + public static void Info(object value) + { + GetLogger().Info(value); + } + + public static void Warn(object value) + { + GetLogger().Warn(value); + } + + public static void Error(object value) + { + GetLogger().Error(value); + } + + public static void Fatal(object value) + { + GetLogger().Fatal(value); + } + + public static void Exception(Exception ex) + { + MethodBase method = new StackFrame(1).GetMethod(); + Error($"{method?.ReflectedType?.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + Debug($"{method?.ReflectedType?.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.\n{ex.StackTrace}"); + } + } +} diff --git a/ChaosBot/Program.cs b/ChaosBot/Program.cs index 0860718..e9c18a8 100644 --- a/ChaosBot/Program.cs +++ b/ChaosBot/Program.cs @@ -10,7 +10,7 @@ namespace ChaosBot { internal class Program { - public static ILogger Logger; + private static ILogger _logger; public static IConfiguration AppSettingsHandler; private static string _appsettingsPath; @@ -21,6 +21,11 @@ namespace ChaosBot new Program().MainFunction().GetAwaiter().GetResult(); } + public static ILogger GetLogger() + { + return _logger; + } + private async Task MainFunction() { try @@ -33,7 +38,7 @@ namespace ChaosBot /* * Initialize the _logger for logging purposes */ - Logger = Logging.GenLog(configurationHandler); + _logger = Logging.GenLog(configurationHandler); /* * Set AppSettingsHandler on ConfigurationRepository @@ -43,7 +48,7 @@ namespace ChaosBot /* * Initialize the Discord Client and Login */ - Logger.Info($"Starting Up {AppSettingsHandler.GetValue("Bot:Name")} v{AppSettingsHandler.GetValue("Bot:Version")}"); + _logger.Info($"Starting Up {AppSettingsHandler.GetValue("Bot:Name")} v{AppSettingsHandler.GetValue("Bot:Version")}"); var discordBot = LoadDiscord(); @@ -52,7 +57,7 @@ namespace ChaosBot } catch (Exception ex) { - Logger.Error(ex, $"Program.MainFunction: Exception [{ex}] thrown, <[{ex.Message}]>."); + _logger.Error(ex, $"Program.MainFunction: Exception [{ex}] thrown, <[{ex.Message}]>."); } } @@ -73,4 +78,4 @@ namespace ChaosBot return DiscordConnect.StartUp(); } } -} \ No newline at end of file +} diff --git a/ChaosBot/Services/CheckPermissions.cs b/ChaosBot/Services/CheckPermissions.cs index f954c76..d644e9a 100644 --- a/ChaosBot/Services/CheckPermissions.cs +++ b/ChaosBot/Services/CheckPermissions.cs @@ -1,23 +1,19 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using ChaosBot.Models; using ChaosBot.Repositories; using Discord.Commands; using Discord.WebSocket; -using NLog; namespace ChaosBot.Services { public class CheckPermissions { - private static ILogger _logger = Program.Logger; - public static Boolean CheckPerms(ICommandContext context, string command, string defaultRole = "User") { // Debug information - _logger.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command}"); + LoggingFacade.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command}"); // If user is not SocketGuildUser, then return error if (!(context.User is SocketGuildUser gUser)) return false; @@ -76,11 +72,11 @@ namespace ChaosBot.Services return true; } else - _logger.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default"); + LoggingFacade.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default"); } // Permission denied return false; } } -} \ No newline at end of file +} diff --git a/ChaosBot/Services/LodestoneHttpProxy.cs b/ChaosBot/Services/LodestoneHttpProxy.cs index a6ca5fd..8603d5d 100644 --- a/ChaosBot/Services/LodestoneHttpProxy.cs +++ b/ChaosBot/Services/LodestoneHttpProxy.cs @@ -1,14 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; -using ChaosBot.Lodestone; using Newtonsoft.Json; -using NLog; -using NLog.Fluent; namespace ChaosBot.Services { @@ -29,7 +25,6 @@ namespace ChaosBot.Services static class LodestoneHttpConnection { - private static readonly ILogger _logger = Program.Logger; static HttpClient client = new HttpClient(); private static bool _firstRun = true; @@ -59,9 +54,9 @@ namespace ChaosBot.Services } catch (Exception ex) { - _logger.Error(ex, $"HttpProxy.fetch<{typeof(T)}>: Exception [{ex}] thrown, <[{ex.Message}]>."); + LoggingFacade.Exception(ex); throw; } } } -} \ No newline at end of file +} diff --git a/ChaosBot/Services/RestrictedConfig.cs b/ChaosBot/Services/RestrictedConfig.cs index 90d5d5f..88fc681 100644 --- a/ChaosBot/Services/RestrictedConfig.cs +++ b/ChaosBot/Services/RestrictedConfig.cs @@ -1,19 +1,10 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using ChaosBot.Models; -using ChaosBot.Repositories; -using Discord.Commands; -using Discord.WebSocket; -using NLog; namespace ChaosBot.Services { public class RestrictedConfig { - private static ILogger _logger = Program.Logger; - public static Boolean IsAllowed(string key) { // TODO: List populated from DB @@ -25,4 +16,4 @@ namespace ChaosBot.Services return true; } } -} \ No newline at end of file +} diff --git a/ChaosBot/Services/Timer.cs b/ChaosBot/Services/Timer.cs index 2300a17..b3a8c36 100644 --- a/ChaosBot/Services/Timer.cs +++ b/ChaosBot/Services/Timer.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; namespace ChaosBot.Services { @@ -114,4 +113,4 @@ namespace ChaosBot.Services } } } -} \ No newline at end of file +} diff --git a/ChaosBot/WebServer/App/DiscordController.cs b/ChaosBot/WebServer/App/DiscordController.cs index eddff4b..fa7a594 100644 --- a/ChaosBot/WebServer/App/DiscordController.cs +++ b/ChaosBot/WebServer/App/DiscordController.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; -using NLog; namespace ChaosBot.WebServer.App { @@ -18,7 +15,6 @@ namespace ChaosBot.WebServer.App { private static readonly AccessTokenCache Cache = WebServer.Cache; private static readonly HttpClient client = new HttpClient(); - private static readonly ILogger Logger = Program.Logger; [HttpGet] public async Task Index(string code = null) @@ -138,4 +134,4 @@ namespace ChaosBot.WebServer.App public int permissions { get; set; } public int permissions_new { get; set; } } -} \ No newline at end of file +} diff --git a/ChaosBot/WebServer/Startup.cs b/ChaosBot/WebServer/Startup.cs index 2e4b7cc..5ebac57 100644 --- a/ChaosBot/WebServer/Startup.cs +++ b/ChaosBot/WebServer/Startup.cs @@ -1,18 +1,14 @@ -using System.IO; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using NLog; namespace ChaosBot.WebServer { class Startup { - private readonly ILogger _logger = Program.Logger; - public IConfiguration Configuration { get; } public Startup(IConfiguration configuration) @@ -38,7 +34,7 @@ namespace ChaosBot.WebServer // This method gets called by the runtime. Use this method to configure the HTTP request pipeline public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - _logger.Info("Initializing Kestrel Startup and Configuration"); + LoggingFacade.Info("Initializing Kestrel Startup and Configuration"); if (Program.AppSettingsHandler.GetValue("WebServer:Debug", false)) app.UseDeveloperExceptionPage(); @@ -56,4 +52,4 @@ namespace ChaosBot.WebServer app.UseStaticFiles(); } } -} \ No newline at end of file +}