/// <summary> /// Raises a log message received event. /// </summary> /// <param name="e"> /// The event args. /// </param> private void OnLogMessageReceived(LogMessageEventArgs e) { if (this.LogMessageReceived != null) { this.LogMessageReceived(this, e); } }
/// <summary> /// Handles a log message being recieved. /// </summary> /// <param name="sender"> /// The sender of the event. /// </param> /// <param name="e"> /// The arguments of the event. /// </param> public void LogMessageReceived(object sender, LogMessageEventArgs e) { if (this.InvokeRequired) { this.Invoke(new Action(() => this.LogMessageReceived(sender, e))); } else { this.logList.Items.Add(e); this.logList.SelectedIndex = this.logList.Items.Count - 1; } }
public void Warning_MessageFormat() { LogManager.RegisterDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; log.Warning("log message {0}", 1); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Warning, eventArgs.LogEvent); Assert.AreEqual("[System.Int32] log message 1", eventArgs.Message); }
public void Error_Message() { LogManager.RegisterDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; log.Error("log message"); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Error, eventArgs.LogEvent); Assert.AreEqual("[System.Int32] log message", eventArgs.Message); }
private void WriteLog(object sender, LogMessageEventArgs logmsg) { switch (logmsg.LogType) { case MqLogType.ConsumerCancelled: _logger.LogWarning("RabbitMQ consumer cancelled. --> " + logmsg.Reason); break; case MqLogType.ConsumerRegistered: _logger.LogInformation("RabbitMQ consumer registered. --> " + logmsg.Reason); break; case MqLogType.ConsumerUnregistered: _logger.LogWarning("RabbitMQ consumer unregistered. --> " + logmsg.Reason); break; case MqLogType.ConsumerShutdown: _isHealthy = false; _logger.LogWarning("RabbitMQ consumer shutdown. --> " + logmsg.Reason); break; case MqLogType.ConsumeError: _logger.LogError("Kafka client consume error. --> " + logmsg.Reason); break; case MqLogType.ServerConnError: _isHealthy = false; _logger.LogCritical("Kafka server connection error. --> " + logmsg.Reason); break; case MqLogType.ExceptionReceived: _logger.LogError("AzureServiceBus subscriber received an error. --> " + logmsg.Reason); break; case MqLogType.InvalidIdFormat: _logger.LogError("AmazonSQS subscriber delete inflight message failed, invalid id. --> " + logmsg.Reason); break; case MqLogType.MessageNotInflight: _logger.LogError("AmazonSQS subscriber change message's visibility failed, message isn't in flight. --> " + logmsg.Reason); break; default: throw new ArgumentOutOfRangeException(); } }
public void WritesMessagesWithIndent() { LogManager.AddDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; log.Indent(); log.Info("Indented message"); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent); Assert.AreEqual(" Indented message", eventArgs.Message); }
public void Info_ExceptionWithMessage() { LogManager.AddDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; var exception = new ArgumentNullException("log test"); log.Info(exception, "additional message"); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent); Assert.AreEqual(string.Format("additional message | {0} (Parameter 'log test')", ArgumentNullExceptionText), eventArgs.Message); }
public void Debug_ExceptionWithMessage() { LogManager.RegisterDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; var exception = new ArgumentNullException("log test"); log.Debug(exception, "additional message"); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Debug, eventArgs.LogEvent); Assert.AreEqual(string.Format("[System.Int32] additional message | {0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message); }
public void Error_ExceptionWithMessageFormat() { LogManager.AddDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; var exception = new ArgumentNullException("log test"); log.Error(exception, "additional message {0}", 1); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Error, eventArgs.LogEvent); Assert.AreEqual(string.Format("additional message 1 | {0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message); }
public void Warning_Exception() { LogManager.AddDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; var exception = new ArgumentNullException("log test"); log.Warning(exception); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Warning, eventArgs.LogEvent); Assert.AreEqual(string.Format("{0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message); }
//print out logs - could also be done after all is said and done, ignoring this event private static void ClientOnLogMessageReceived(object sender, LogMessageEventArgs eventArgs) { Console.WriteLine(""); Console.WriteLine("Log messages:"); foreach (var msg in eventArgs.ReadMessages()) { Console.WriteLine(msg); } Console.WriteLine(""); if (null != eventArgs.LastLogPollingException) { Console.WriteLine(@"Error at {0} on {1} as: {2}", eventArgs.LastLogPollingExceptionTime, eventArgs.LastLogPollingExceptionServer, eventArgs.LastLogPollingException); Console.WriteLine(""); } }
void ListViewSelectionChanged(object sender, EventArgs e) { logView.Clear(); int row = listView.SelectedRow; if (row < 0) { return; } LogMessageEventArgs logMessage = listStore.GetValue(row, logMessageField); if (logMessage != null) { logView.WriteText(null, logMessage.Message); } }
private Task OnExceptionReceived(ExceptionReceivedEventArgs args) { var context = args.ExceptionReceivedContext; var exceptionMessage = $"- Endpoint: {context.Endpoint}" + Environment.NewLine + $"- Entity Path: {context.EntityPath}" + Environment.NewLine + $"- Executing Action: {context.Action}" + Environment.NewLine + $"- Exception: {args.Exception}"; var logArgs = new LogMessageEventArgs { LogType = MqLogType.ExceptionReceived, Reason = exceptionMessage }; OnLog?.Invoke(null, logArgs); return(Task.CompletedTask); }
public static void Log(object sender, LogMessageEventArgs e) { string consoleMsg = $"[{ e.Severity }] [{e.Source}] {e.Message}"; if (e.Message == "Disconnected") { Program.isConnected = false; } if (e.Message == "Connected" && Program.isConnected) { Program._client.FindServers(Definitions.ServerDefinitions.ServerName.GetStringValue()) .FirstOrDefault().TextChannels .SingleOrDefault(x => x.Name.Contains(Definitions.TextChannels.ChatNChill.GetStringValue())) .SendMessage(consoleMsg); } Console.WriteLine(consoleMsg); }
public void WorksWithoutData() { LogManager.AddDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; log.InfoWithData("log message", null); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent); Assert.AreEqual("log message", eventArgs.Message); var logData = eventArgs.LogData; Assert.IsNull(logData); }
public void PublishLogMessage(object sender, LogMessageEventArgs e) { Color color = e.GetMessageColor; string message = e.PrintedMessage; if (richTextBoxLogger.InvokeRequired) { DelegateLog d = new DelegateLog(PublishLogMessage); this.Invoke(d, new object[] { sender, e }); } else { richTextBoxLogger.SelectionStart = richTextBoxLogger.TextLength; richTextBoxLogger.SelectionLength = 0; richTextBoxLogger.SelectionColor = color; richTextBoxLogger.AppendText(message); richTextBoxLogger.SelectionStart = richTextBoxLogger.Text.Length; richTextBoxLogger.ScrollToCaret(); } }
public void LogMessageEvent() { LogManager.ClearListeners(); var listener = new DebugLogListener(); LogManager.AddListener(listener); LogMessageEventArgs eventArgs = null; LogManager.LogMessage += (sender, e) => eventArgs = e; var log = LogManager.GetLogger(typeof(LogManager)); log.Info("hello there"); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent); Assert.AreEqual("hello there", eventArgs.Message); }
public static void OnDiscordLog(object sender, LogMessageEventArgs args) { ConsoleColor messageColor = ConsoleColor.White; switch (args.Severity) { case LogSeverity.Error: messageColor = ConsoleColor.Red; break; case LogSeverity.Warning: messageColor = ConsoleColor.Yellow; break; case LogSeverity.Debug: messageColor = ConsoleColor.DarkCyan; break; } Log(args.Message, args.Severity.ToString(), messageColor); }
public void Error_Exception_Aggregated() { LogManager.AddDebugListener(); var log = new Log(typeof(int)); LogMessageEventArgs eventArgs = null; log.LogMessage += (sender, e) => eventArgs = e; var exception = new AggregateException("log test", new[] { new ArgumentNullException("arg1"), new ArgumentNullException("arg2"), }); log.Error(exception); Assert.IsNotNull(eventArgs); Assert.AreEqual(log, eventArgs.Log); Assert.AreEqual(LogEvent.Error, eventArgs.LogEvent); Assert.AreEqual("[AggregateException] System.AggregateException: log test ---> System.ArgumentNullException: Value cannot be null.\r\nParameter name: arg1\r\n --- End of inner exception stack trace ---\r\n---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.\r\nParameter name: arg1<---\r\n\r\n---> (Inner Exception #1) System.ArgumentNullException: Value cannot be null.\r\nParameter name: arg2<---\r\n", eventArgs.Message); }
private void WriteLog(object sender, LogMessageEventArgs logmsg) { switch (logmsg.LogType) { case MqLogType.ConsumerCancelled: _logger.LogWarning("RabbitMQ consumer cancelled. --> " + logmsg.Reason); break; case MqLogType.ConsumerRegistered: _logger.LogInformation("RabbitMQ consumer registered. --> " + logmsg.Reason); break; case MqLogType.ConsumerUnregistered: _logger.LogWarning("RabbitMQ consumer unregistered. --> " + logmsg.Reason); break; case MqLogType.ConsumerShutdown: _isHealthy = false; _logger.LogWarning("RabbitMQ consumer shutdown. --> " + logmsg.Reason); break; case MqLogType.ConsumeError: _logger.LogError("Kafka client consume error. --> " + logmsg.Reason); break; case MqLogType.ServerConnError: _isHealthy = false; _logger.LogCritical("Kafka server connection error. --> " + logmsg.Reason); break; case MqLogType.ExceptionReceived: _logger.LogError("AzureServiceBus subscriber received an error. --> " + logmsg.Reason); break; default: throw new ArgumentOutOfRangeException(); } }
void Logging_LogMessage(object sender, LogMessageEventArgs e) { Helper.MessageType t = Helper.MessageType.General; switch (e.type) { case MessageType.Error: t = Helper.MessageType.Error; break; case MessageType.Info: t = Helper.MessageType.Info; break; case MessageType.Server: t = Helper.MessageType.Server; break; case MessageType.Warning: t = Helper.MessageType.Warning; break; } try { if (Application.Current != null) { Application.Current.Dispatcher.BeginInvoke(new Action <CWSRestart.Helper.LogMessage>((m) => LogControl.Messages.Add(m)), new CWSRestart.Helper.LogMessage(e.message, t)); } } catch (NullReferenceException) { if (Debugger.IsAttached) { Debugger.Break(); } } }
private async Task ConsumeMessages(IAsyncEnumerable <RedisStream[]> streamsSet, RedisValue position) { await foreach (var set in streamsSet) { foreach (var stream in set) { foreach (var entry in stream.Entries) { if (entry.IsNull) { return; } try { var message = RedisMessage.Create(entry, _groupId); OnMessageReceived?.Invoke((stream.Key.ToString(), _groupId, entry.Id.ToString()), message); } catch (Exception ex) { _logger.LogError(ex.Message, ex); var logArgs = new LogMessageEventArgs { LogType = MqLogType.ConsumeError, Reason = ex.ToString() }; OnLog?.Invoke(entry, logArgs); } finally { var positionName = position == StreamPosition.Beginning ? nameof(StreamPosition.Beginning) : nameof(StreamPosition.NewMessages); _logger.LogDebug($"Redis stream entry [{entry.Id}] [position : {positionName}] was delivered."); } } } } }
public ICollection <string> FetchTopics(IEnumerable <string> topicNames) { if (topicNames == null) { throw new ArgumentNullException(nameof(topicNames)); } var regexTopicNames = topicNames.Select(Helper.WildcardToRegex).ToList(); try { var config = new AdminClientConfig(_kafkaOptions.MainConfig) { BootstrapServers = _kafkaOptions.Servers }; using var adminClient = new AdminClientBuilder(config).Build(); adminClient.CreateTopicsAsync(regexTopicNames.Select(x => new TopicSpecification { Name = x })).GetAwaiter().GetResult(); } catch (CreateTopicsException ex) when(ex.Message.Contains("already exists")) { } catch (Exception ex) { var logArgs = new LogMessageEventArgs { LogType = MqLogType.ConsumeError, Reason = $"An error was encountered when automatically creating topic! -->" + ex.Message }; OnLog?.Invoke(null, logArgs); } return(regexTopicNames); }
private void WriteLog(object sender, LogMessageEventArgs logmsg) { switch (logmsg.EventType) { case EventType.ConsumerCancelled: _logger.LogWarning("RabbitMQ consumer cancelled. --> " + logmsg.Reason); break; case EventType.ConsumerRegistered: _logger.LogInformation("RabbitMQ consumer registered. --> " + logmsg.Reason); break; case EventType.ConsumerUnregistered: _logger.LogWarning("RabbitMQ consumer unregistered. --> " + logmsg.Reason); break; case EventType.ConsumerShutdown: _logger.LogWarning("RabbitMQ consumer shutdown. --> " + logmsg.Reason); break; default: throw new ArgumentOutOfRangeException(); } }
void LogDispatcherOnMessageLogged(object sender, LogMessageEventArgs logMessageEventArgs) { if (logMessageEventArgs.Level == "Trace" && logMessageEventArgs.Message.StartsWith("Messages loaded: #")) { this.Text = logMessageEventArgs.Message; return; } var date = DateTime.Now.ToString(CultureInfo.InvariantCulture); lvwLog.BeginInvoke((Action)(() => { var item = lvwLog.Items.Add ( new ListViewItem ( new[] { date, logMessageEventArgs.Level, logMessageEventArgs.Message } ) ); lvwLog.EnsureVisible(item.Index); })); }
void AddLogMessage(LogMessageEventArgs e) { int row = 0; if (listStore.RowCount == 0) { row = listStore.AddRow(); } else { row = listStore.InsertRowBefore(0); } listStore.SetValues( row, iconField, GetIcon(e.Level), logMessageTypeField, GetTypeName(e.Level), logMessageTextField, GetListMessage(e.Message), logMessageField, e); }
void HandleLogMessage(LogMessageEventArgs args) { ShowChatText(args.Message); }
private void Log(object sender, LogMessageEventArgs e) { Console.WriteLine($"[{e.Source}] [{e.Message}]"); }
/// <summary> /// Log the message e.MessageRaises the log message event. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event arguments.</param> public void OnLogMessage (Object sender, LogMessageEventArgs e) { if (e.Level <= logLevel) { if (logFile != null) { // Create log entry logFile.WriteLine (engine.CreateLogMessage (e.Message)); } } }
/// <summary> /// Log the message e.MessageRaises the log message event. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event arguments.</param> public void OnLogMessage (Object sender, LogMessageEventArgs args) { if (args.Level <= logLevel) { // TODO: Remove Console.WriteLine (engine.CreateLogMessage (args.Message)); if (logFile != null) { // Create log entry logFile.WriteLine (engine.CreateLogMessage (args.Message)); } } }
private void WFCoreAdapter_LogMessageRequested(object sender, LogMessageEventArgs e) { LogDebug(String.Format("[{0}]: {1}", e.Level, e.Message), e.Level); }
/// <summary> /// Handles a log message being recieved. /// </summary> /// <param name="sender"> /// The sender of the event. /// </param> /// <param name="e"> /// The arguments of the event. /// </param> private void OnLogMessageReceived(object sender, LogMessageEventArgs e) { // Cache the messages in a list until the controller has been initialised. // Then the message can be sent directly to the view. if (!this.initialised) { this.Log.Add(e); } else { this.OnLogMessageReceived(e); } }
//public void Log(object sender, LogMessageEventArgs e) //{ // Console.WriteLine($"[{e.Severity}] [{e.Source}] {e.Message}"); //} public void Log(object sender, LogMessageEventArgs e) { Console.WriteLine("Log disabled"); }
private void OnLogListenerLogMessage(object sender, LogMessageEventArgs e) { LogMessage.SafeInvoke(this, e); }
private static void HandleLogMessage(object sender, LogMessageEventArgs e) { try { if (e != null) { //Create log item string logItem; DateTime now = DateTime.Now; string message = ""; if (e.Exception != null) message = string.Format("EXCEPTION:{0}{1}{0}Source: {2}{0}Message: {3}{0}Stack trace: {4}{0}{1}", System.Environment.NewLine, "-----------------------------------------------------------------------------", e.Exception.Source, e.Exception.Message, e.Exception.StackTrace); else message = e.Message; if (sender is IUnique) { IUnique unique = (IUnique)sender; logItem = string.Format("{0} ({1}-{2}): {3}", AddinManager.CurrentLocalizer.GetString(e.LogLevel.ToString()), now, unique.Key, message); } else logItem = string.Format("{0} ({1}): {2}", AddinManager.CurrentLocalizer.GetString(e.LogLevel.ToString()), now, message); //Show in console Console.WriteLine(logItem); //Write to file WriteLogItem(logItem, now); } } catch { } }
private void realCore_LogMessageGenerated(object sender, LogMessageEventArgs e) { if (LogMessageGenerated != null) { LogMessageGenerated(this, e); } }
private void Ui_MessageLogged(object sender, LogMessageEventArgs e) { this.Log(e.Level, e.Message); }
/// <summary> /// Raises the log message event. /// </summary> /// <param name="sender">Sender of event.</param> /// <param name="args">Log message event arguments.</param> public void OnLogMessage(object sender, LogMessageEventArgs args) { this.LogMessage(args.Level, args.Message); }
private void Log(object sender, LogMessageEventArgs e) { Console.WriteLine(e.Message); }
private void OnLogMessage(object sender, LogMessageEventArgs e) => _ui.LogMessage(e.message, e.type);
//Helper methods private void LogMessage(string message, bool forVerboseOnly) { LogMessageEventArgs e = new LogMessageEventArgs(); e.errorMessage = message; e.verboseMessage = forVerboseOnly; e.kinectID = kinectID; if (LogMessageGenerated != null) { LogMessageGenerated(this, e); } }
private void LogHandler(object sender, LogMessageEventArgs logMessageEventArgs) { Console.WriteLine(logMessageEventArgs.Message + " (" + logMessageEventArgs.Severity + ") [" + logMessageEventArgs.Source + "]"); }
private void OnLogMessage(object sender, LogMessageEventArgs e) { _dispatcherService.BeginInvoke(() => { var traceEntries = TraceEntries; if (traceEntries != null) { var traceEntry = new TraceEntry(new LogEntry(e)); TraceEntries.Add(traceEntry); } }); }
public void HandleLogMessage(object sender, LogMessageEventArgs logEvent) { _log.Write(logEvent.Severity.ToLogLevel(), "Discord Client: {0}", logEvent.Message); }
/// <summary> /// Handles the receipt of a log message. /// </summary> /// <param name="sender"> /// The sender of the event. /// </param> /// <param name="e"> /// The arguments of the event. /// </param> private void OnLogMessage(object sender, LogMessageEventArgs e) { this.Invoke(new Action(() => this.log.TopIndex = this.log.Items.Add(e.ToString()))); }