public static Task Log(LogMessage message) { ShowMessage(); switch (message.Severity) { case LogSeverity.Critical: case LogSeverity.Error: Console.ForegroundColor = ConsoleColor.Red; break; case LogSeverity.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; case LogSeverity.Info: Console.ForegroundColor = ConsoleColor.White; break; case LogSeverity.Verbose: case LogSeverity.Debug: Console.ForegroundColor = ConsoleColor.DarkGray; break; default: throw new ArgumentOutOfRangeException(); } Console.WriteLine($"[{DateTime.Now,-19}] ({message.Severity}) {message.Source}: {message.Message} {message.Exception}"); Logging($"{DateTime.Now,-19} [{message.Severity,8}] {message.Source}: {message.Message} {message.Exception}"); Console.ResetColor(); return(Task.CompletedTask); }
public static LogMessage FromDiscordLogMessage(Discord.LogMessage message) => new LogMessage { Message = message.Message, Severity = message.Severity, Exception = message.Exception, Source = LogSources.Parse(message.Source) };
public async static Task Log(Discord.LogMessage arg) { if (arg.Severity > Discord.LogSeverity.Info) { return; } // log stuff to console // could also log to a file if needed later on Console.WriteLine(arg.ToString()); }
private Task DiscordClient_log(Discord.LogMessage arg) { Console.WriteLine($"[{DateTime.Now}] [{arg.Severity}] {arg.Source}: {arg.Message}"); if (arg.Exception != null) { Console.WriteLine($"Exception: {arg.Exception.Message}\nStacktrace:\n{arg.Exception.StackTrace}"); } return(Task.CompletedTask); }
private async Task ClientLog(Discord.LogMessage arg) { if (arg.Exception != null) { await Logger.Instance.WriteAsync(new LogException(arg.Exception, arg.Source, arg.Severity)); } else { await Logger.Instance.WriteAsync(new LogMessage(arg.Message, arg.Source, arg.Severity)); } }
private Task OnClientLog(Discord.LogMessage log) { if (log.Exception != null) { Logger.Error(log); } else { Logger.Info(log); } return(Task.CompletedTask); }
private async Task Client_Log(Discord.LogMessage msg) { await consolePrint(msg.Message); if (msg.Message == "Failed to resume previous session") { try { await consolePrint("Might need to restart client..."); } catch (Exception ex) { await consolePrint(ex.Message); } } }
private async Task commandMessageUpdated(SocketMessage arg) { // todo clean up copied and pasted code // Don't handle the command if it is a system message var message = arg as SocketUserMessage; if (message == null) { return; } // Mark where the prefix ends and the command begins int argPos = 0; // Determine if the message has a valid prefix, adjust argPos if (!(message.HasMentionPrefix(m_client.CurrentUser, ref argPos) || message.HasCharPrefix(GlobalConfiguration.CommandPrefix, ref argPos))) { return; } // Create a Command Context var context = new CommandContext(m_client, message); // Execute the Command, store the result try { var result = await _commands.ExecuteAsync(context, argPos, _services); // If the command failed if (!result.IsSuccess) { // log the error Discord.LogMessage errorMessage = new Discord.LogMessage(Discord.LogSeverity.Warning, "CommandHandler", result.ErrorReason); await Log(errorMessage); // don't actually reply back with the error // todo reply back with an error message that corresponds to the closest matching command name } } catch (Exception e) { var error = new LogMessage(LogSeverity.Error, "CommandHandler", "Caught exception", e); await Log(error); } }
public static void logHandler(EduLinkClient cl, EduLinkDLL.LogMessage m) { if (m.Severity == EduLinkDLL.LogSeverity.Debug && (m.Source == "Response" || m.Source == "Request")) { /*var path = Path.Combine(Program.BASE_PATH, "data", "logs", "edulink", cl.CurrentUser?.Username ?? cl.UserName ?? "nouser"); * if(!Directory.Exists(path)) * Directory.CreateDirectory(path); * path = Path.Combine(path, $"{DateTime.Now:yyyy-MM-dd}.txt"); * var id = Guid.NewGuid(); * var chr = m.Source == "Request" ? '>' : '<'; * var pad = new string(chr, 3); * string header = pad + id.ToString() + pad; * string full = header + "\r\n" + m.Message + "\r\n" + new string(chr, header.Length) + "\r\n"; * if (m.Source == "Response") * full += "\r\n"; * File.AppendAllText(path, full); * Program.LogMsg($"Logged as {id}", Discord.LogSeverity.Verbose, "EL:" + m.Source);*/ return; } var conv = new Discord.LogMessage((Discord.LogSeverity)m.Severity, $"EL:{(cl?.CurrentUser?.UserName ?? "")}:" + (m.Source ?? ""), m.Message, m.Exception); Program.LogMsg(conv); }
private async Task Log(Discord.LogMessage arg) { Console.WriteLine(arg.Message); }
private async Task _client_Log(Discord.LogMessage arg) { Console.WriteLine($"{DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")} - {Enum.GetName(typeof(Discord.LogSeverity), arg.Severity)}: {arg.Message} {arg.Exception?.ToString()}"); _loggingQueue.TryAdd(arg); }
public static LogMessage FromDiscordLogMessage(Discord.LogMessage message) => new LogMessage
private Task _client_Log(Discord.LogMessage arg) { Console.WriteLine(arg); return(Task.CompletedTask); }
public Task Log(Discord.LogMessage arg) { Console.WriteLine(arg); return(Task.CompletedTask); }
public async static Task Log(Discord.LogMessage arg) { // log stuff to console // could also log to a file here Console.WriteLine(arg.ToString()); }
private async Task _logAsync(Discord.LogMessage message) { Console.WriteLine(message.ToString()); await Task.FromResult(false); }
private Task Log(Discord.LogMessage arg) { Debug.Log(arg.Message); return(Task.CompletedTask); }
private static async Task Client_Log(Discord.LogMessage arg) { Console.WriteLine($"[{arg.Source}] {arg.Message}"); }
private async Task _client_Log(Discord.LogMessage arg) { Console.WriteLine(arg.ToString()); }
/// <summary> /// Discord log /// </summary> /// <param name="message">The message</param> /// <returns>Task result</returns> private static Task Log(DNET.LogMessage message) { Console.WriteLine(message.ToString()); return(Task.CompletedTask); }
private Task Log(Discord.LogMessage msg) { Console.WriteLine(msg.ToString()); return(Task.CompletedTask); }
public static void Log(Discord.LogMessage arg) { Console.WriteLine(arg.ToString()); }
public JuanMessage(Discord.LogMessage msg, string timestamp) { Severity = msg.Severity; Source = msg.Source; Message = msg.Message; Exception = msg.Exception; Timestamp = timestamp; }
private Task Client_Log(Discord.LogMessage arg) { Logger.Information($"Source: [{arg.Source}] => {arg.Message}"); return(Task.CompletedTask); }
internal static Task Sc_Log(Discord.LogMessage arg) { Program.Log(arg.Message, arg.Severity); return(Task.CompletedTask); }