/// <summary> /// Writes the logevent to the Windows EventLog. /// </summary> /// <param name="args">The log event arguments.</param> /// <returns>A Task object that can be used to listen for completion of the work.</returns> public Task OnLogEventAsync(LogArgs args) { return Task.Run(() => { Log(args); }); }
private void Debug_Logged(object sender, LogArgs e) { string depth = string.Empty; switch (e.Depth) { case LogDepth.Default: Console.ForegroundColor = colors.Default; break; case LogDepth.Warning: Console.ForegroundColor = colors.Warning; depth = "[WARNING]"; break; case LogDepth.Critical: Console.ForegroundColor = colors.Critical; depth = "[CRITICAL]"; break; case LogDepth.Error: Console.ForegroundColor = colors.Error; depth = "[ERROR]"; break; case LogDepth.Attention: Console.ForegroundColor = colors.Attention; depth = "[ATTENTION]"; break; } Console.WriteLine("[{0}]{1} {2}", e.Time.ToShortTimeString(), depth, e.Message); File.AppendAllText(LOG_FILENAME, "[" + e.Time.ToShortTimeString() + "]" + depth + " " + e.Message + Environment.NewLine); }
private void Log_Notify(object sender, LogArgs e) { if (NotificationRequested != null) { NotificationRequested.Invoke(sender, e); } }
/// <summary> /// Writes the logevent to the log file async. /// </summary> /// <param name="args">The log event arguments.</param> /// <exception cref="System.IO.IOException">Thrown if unable to write to file.</exception> /// <returns>A Task object that can be used to listen for completion of the work.</returns> public async Task OnLogEventAsync(LogArgs args) { using (StreamWriter sw = new StreamWriter(this.Filename, true, Encoding.UTF8)) { await sw.WriteLineAsync(args.ToString()); } }
/// <summary> /// Handle massage from server (only log messebe) /// </summary> /// <param name="sender">server</param> /// <param name="e">params</param> public void HandleMessage(object sender, TCPEventArgs message) { int commandId = message.CommandID; try { if (commandId.Equals((int)CommandEnum.LogCommand)) { List <JObject> temp = JsonConvert.DeserializeObject <List <JObject> >(message.Args); foreach (JObject log in temp) { string logType = (string)log["logType"]; string logInfo = (string)log["logInfo"]; LogArgs toInsert = new LogArgs(logType, logInfo); App.Current.Dispatcher.Invoke(new Action(() => { AllLogs.Add(toInsert); })); } foreach (var data in AllLogs) { Console.WriteLine(data.logType + " " + data.logInfo); } } } catch (Exception e) { Console.WriteLine("exception: " + e.Message); } }
public Task Log(LogArgs args) { if (args.IsBadLocateArgs(ClientSpanLocateMode.ForCurrent)) { return(Task.FromResult(0)); } return(_commandQueue.Enqueue(LogCommand.Create(args))); }
public void Logui(LogArgs a) { Dispatcher.BeginInvoke(new Action <LogArgs>((LogArgs arg) => { SolidColorBrush messagecolor = new SolidColorBrush(); switch (arg.type) { case LogType.Debug: messagecolor = Brushes.Purple; break; case LogType.Error: messagecolor = Brushes.Red; break; case LogType.Fatal: messagecolor = Brushes.DarkRed; break; case LogType.Warn: messagecolor = Brushes.DarkGoldenrod; break; case LogType.Info: messagecolor = Brushes.Black; break; case LogType.Shell: messagecolor = Brushes.DarkSlateGray; break; default: break; } Run logmessage = new Run(arg.message) { Foreground = messagecolor, }; string LogHeader = "[" + DateTime.Now.ToLongTimeString() + " " + Enum.GetName(typeof(LogType), arg.type).ToUpper() + " ]: "; logmessage.Text = LogHeader + logmessage.Text; if (LogParagraph.Inlines.Count > 100) { for (int i = 0; i < 50; i++) { LogParagraph.Inlines.Remove(LogParagraph.Inlines.FirstInline); } } if (LogParagraph.Inlines.Count > 0) { ((Run)LogParagraph.Inlines.LastInline).Text += '\n'; } LogParagraph.Inlines.Add(logmessage); LogNewlines++; }), a); }
public void WriteToLog(string _Title, string _Message) { LogArgs logArgs = new LogArgs { Title = _Title, Message = _Message }; OnLog(logArgs); }
protected CoverageService() { coverageLogging = new LogArgs { Info = LoggingService.Info, Warn = LoggingService.Warn, Error = LoggingService.Error, Echo = LoggingService.Echo }; }
/// <summary> /// Fires a new log event to all observers, if they have an appropiate log level. /// </summary> /// <param name="args">The arguments to provide to the observers.</param> public void Log(LogArgs args) { foreach (ILogObserver observer in _observers) { if (observer.Level >= args.Level) { observer.OnLogEventAsync(args); } } }
protected void ExcuteOnLog(LoggerLevels loggerLevels, object message) { if (OnLog == null) return; var e = new LogArgs() { loggerLevels = loggerLevels, Message = message }; OnLog(null, e); }
public Task Log(LogArgs args) { var isOk = CheckApiStatusOkSmart(); if (!isOk) { return(_nullApiProxy.Log(args)); } return(SafeInvokeTask(Proxy.Log(args))); }
/// <summary> /// Handle gotten logs from server /// </summary> /// <param name="sender">server</param> /// <param name="message">logs list</param> public void HandleLogMessage(object sender, TCPEventArgs message) { try { List <JObject> temp = JsonConvert.DeserializeObject <List <JObject> >(message.Args); AllLogs.Clear(); foreach (JObject log in temp) { string logType = (string)log["logType"]; string logInfo = (string)log["logInfo"]; LogArgs toInsert = new LogArgs(logType, logInfo); AllLogs.Add(toInsert); } } catch (Exception) { } }
/// <summary> /// Writes the logevent to the database. /// </summary> /// <param name="args">The log event arguments.</param> /// <exception cref="System.Data.SqlException">Thrown if an error occured while saving to the database.</exception> /// <returns>A Task object that can be used to listen for completion of the work.</returns> /// <remarks> /// The SQL database the provider ConnectionString connects to, should contain an ArachneLog table. /// The table should have 5 columns: INT id NOT NULL, VARCHAR(10) level NOT NULL, DATETIME timstamp NOT NULL, VARCHAR(MAX) message NOT NULL, VARCHAR(MAX) exception /// </remarks> public async Task OnLogEventAsync(LogArgs args) { string connectionString = ConfigurationManager.ConnectionStrings[_connectionStringName].ConnectionString; using (SqlConnection con = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand("INSERT INTO ArachneLog (level, timestamp, message, exception) VALUES (@lvl, @time, @msg, @ex)", con)) { cmd.Parameters.AddWithValue("@lvl", Enum.GetName(typeof(LogLevel), args.Level)); cmd.Parameters.AddWithValue("@time", args.Timestamp); cmd.Parameters.AddWithValue("@msg", args.Message); cmd.Parameters.AddWithValue("@ex", args.Exception); await con.OpenAsync(); await cmd.ExecuteNonQueryAsync(); } } }
private static void OnLog(LogArgs args) { args.Text = "TUI: " + args.Text; if (args.Type == LogType.Success) { TShock.Log.ConsoleInfo(args.Text); } else if (args.Type == LogType.Info) { TShock.Log.ConsoleInfo(args.Text); } else if (args.Type == LogType.Warning) { TShock.Log.ConsoleError(args.Text); } else if (args.Type == LogType.Error) { TShock.Log.ConsoleError(args.Text); } }
public void EventLog(object sender, LogArgs log) { if (richTxt.Created) { richTxt.BeginInvoke(new Action(() => { var text = $"{DateTime.Now.ToString(_formatDateTime, CultureInfo.InvariantCulture)}{Environment.NewLine}"; switch (log.ElementType) { case Core.Enumerator.EventLog.ReadFile: text += $"Arquivo: {log.ElementName}"; _fileName = log.ElementName; break; case Core.Enumerator.EventLog.ReadSheet: text += $"Planilha: {log.ElementName}"; break; case Core.Enumerator.EventLog.BeforeSaveFile: text += "Gerando arquivo..."; break; case Core.Enumerator.EventLog.AfterSaveFile: text += $"Arquivo gerado: {log.ElementName}"; break; default: break; } text += $"{Environment.NewLine}"; text += $"{Environment.NewLine}"; richTxt.AppendText(text); })); } }
/// <summary> /// Write to the Windows EventLog /// </summary> /// <param name="args">The log event arguments</param> private void Log(LogArgs args) { EventLogEntryType type; switch (args.Level) { case LogLevel.Verbose: case LogLevel.Info: type = EventLogEntryType.Information; break; case LogLevel.Warning: type = EventLogEntryType.Warning; break; case LogLevel.Error: case LogLevel.Fatal: type = EventLogEntryType.Error; break; default: type = EventLogEntryType.Information; break; } EventLog.WriteEntry(this._source, args.Message, type); }
private void LogOnPassLogs(LogArgs args) { string message; if (args.level == Log.LogLevel.EXCEPTIONS) { args.message = $"{args.except.Message}\n{args.except.StackTrace}"; } if (args.context != null) { message = $"-- {args.context.GetType()} -- {args.message}"; } else { message = args.message; } switch (args.level) { case Log.LogLevel.NONE: GD.PrintErr(message); break; case Log.LogLevel.ASSERTS: GD.PrintErr($"AST {message}"); break; case Log.LogLevel.ERRORS: GD.PrintErr($"ERR {message}"); break; case Log.LogLevel.EXCEPTIONS: GD.PrintErr($"EXP {message}"); break; case Log.LogLevel.WARNINGS: GD.Print($"WARN {message}"); break; case Log.LogLevel.LOGS: GD.Print($"LOG {message}"); break; case Log.LogLevel.VERBOSE: GD.Print($"VER {message}"); break; case Log.LogLevel.ALL: GD.Print($"ALL {message}"); break; default: throw new ArgumentOutOfRangeException(); } }
// method to log an event in the service log private void LogEntry(object sender, LogArgs args) { EventLogEntryType msgType; switch (args.MsgType) { case Logging.Type.INFO: msgType = EventLogEntryType.Information; break; case Logging.Type.ERROR: msgType = EventLogEntryType.Error; break; case Logging.Type.WARNING: msgType = EventLogEntryType.Warning; break; default: msgType = EventLogEntryType.Information; break; } eventLog.WriteEntry(args.Msg, msgType, eventId++); }
public Task LogTest([FromQuery] LogArgs args) { return(_logApi.Log(args)); }
public async Task Log(LogArgs args) { await _clientTracerBridge.Log(args); }
/// <summary> /// Raise a Logger event with the specified message /// </summary> private void Log(string message) { var logArgs = new LogArgs(message); Logger?.Invoke(this, logArgs); }
public void LogHandler(object a, LogArgs e) { writer.Custom(e.Message, e.MessageColor); logger.LogCustom(e.Message); }
public Task Log(LogArgs args) { var requestUri = _config.GetRequestUri(nameof(Log)); return(_webApiHelper.PostAsJson(requestUri, args)); }
private void LogNotifier(object sender, LogArgs e) { NotificationRequested?.Invoke(sender, e); }
protected virtual void OnLog(LogArgs e) { Log?.Invoke(this, e); }
public Task Log(LogArgs args) { return(Task.FromResult(0)); }
public void Log(object s, LogArgs e) { tbLog.AppendText(e.Msg + "\r\n"); }
/// <summary> /// Writes the logevent to memory. /// </summary> /// <param name="args">The log event arguments.</param> /// <returns>A Task object that can be used to listen for completion of the work.</returns> public Task OnLogEventAsync(LogArgs args) { _log.Add(args); return Task.Run(() => {}); }
public Task Log(LogArgs args) { return(_clientTracerApi.Log(args)); }
private void Logger_OnLog( LogArgs LogArgs ) { byte[] b = Encoding.UTF8.GetBytes( LogArgs.LogLine + "\n" ); LogFile.Write( b, 0, b.Length ); LogFile.Flush(); }
public Task Log(LogArgs args) { return(_logApi.Log(args)); }