Updated Logger and Created Command to change settings variables
This commit is contained in:
@@ -138,7 +138,13 @@ internal class CommandHandler
|
||||
argsClean = string.Join(' ', split, 1, split.Length - 1).Split(' ');
|
||||
|
||||
DBCommandExecutingArguments cmd = new(context, cleanMessage, split[0], argsClean);
|
||||
|
||||
|
||||
Config.Logger.Log(
|
||||
message: $"User ({context.User.Username}) from Guild \"{context.Guild.Name}\" executed command \"{cmd.cleanContent}\"",
|
||||
source: typeof(CommandHandler),
|
||||
type: LogType.INFO
|
||||
);
|
||||
|
||||
if (context.Channel is SocketDMChannel)
|
||||
plugin.ExecuteDM(cmd);
|
||||
else plugin.ExecuteServer(cmd);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Config
|
||||
|
||||
_isLoaded = true;
|
||||
|
||||
await Logger.Log(message: "Config initialized", source: typeof(Config));
|
||||
Logger.Log(message: "Config initialized", source: typeof(Config));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ internal interface ILogger
|
||||
bool OutputToFile { get; init; }
|
||||
|
||||
event EventHandler<Log> OnLog;
|
||||
Task Log(
|
||||
void Log(
|
||||
string message = "", string outputFile = "", Type? source = default, LogType type = LogType.INFO,
|
||||
DateTime throwTime = default);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public sealed class Logger : ILogger
|
||||
(UseShortVersion ? logMessage : logMessage.AsLongString()) + "\n");
|
||||
}
|
||||
|
||||
public async Task Log(string message = "", string outputFile = "", Type? source = default, LogType type = LogType.INFO, DateTime throwTime = default)
|
||||
public async void Log(string message = "", string outputFile = "", Type? source = default, LogType type = LogType.INFO, DateTime throwTime = default)
|
||||
{
|
||||
if (!IsEnabled) return;
|
||||
|
||||
@@ -53,5 +53,17 @@ public sealed class Logger : ILogger
|
||||
if (source == default) source = typeof(Log);
|
||||
|
||||
await Log(new Log(message, outputFile, source, type, throwTime));
|
||||
|
||||
}
|
||||
|
||||
public async void Log(Exception exception, LogType logType = LogType.ERROR, Type? source = null)
|
||||
{
|
||||
if (!IsEnabled) return;
|
||||
|
||||
if (logType < LowestLogLevel) return;
|
||||
|
||||
await Log(new Log(exception.Message,
|
||||
Config.AppSettings["LogFolder"] + "/" + DateTime.Now.ToString("yyyy-MM-dd") + ".log",
|
||||
source, logType, DateTime.Now));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user