/// <inheritdoc/> public void SendObject( string leftMessage, object rightObject, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } if (string.IsNullOrWhiteSpace(leftMessage)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(leftMessage)); } if (rightObject is null) { throw new ArgumentNullException(nameof(rightObject)); } try { _traceDictionary[messageLevel] .SendObject(leftMessage, rightObject); } catch (ArgumentOutOfRangeException) { } }
/// <inheritdoc/> public void SendToTraceWindow( string key, string leftMessage, string rightMessage, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(key)); } if (string.IsNullOrWhiteSpace(leftMessage)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(leftMessage)); } if (string.IsNullOrWhiteSpace(rightMessage)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(rightMessage)); } if (_traceWindowDictionary.TryGetValue(key, out var traceWindow)) { try { _windowDictionary[messageLevel](traceWindow) .Send(leftMessage, rightMessage); } catch (ArgumentOutOfRangeException) { } } }
/// <inheritdoc/> public void SendDump( string leftMessage, string shortTitle, byte[] address, int count, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } if (address is null) { throw new ArgumentNullException(nameof(address)); } if (string.IsNullOrWhiteSpace(leftMessage)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(leftMessage)); } if (string.IsNullOrWhiteSpace(shortTitle)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(shortTitle)); } try { _traceDictionary[messageLevel] .SendDump(leftMessage, shortTitle, address, count); } catch (ArgumentOutOfRangeException) { } }
/// <summary> /// Specialised constructor for use only by derived class. /// </summary> /// <param name="sender"> Source of the event. </param> /// <param name="message"> The message. </param> /// <param name="messageLevel"> The message level. </param> /// <param name="callerFile"> The caller file. </param> /// <param name="methodName"> Name of the method. </param> /// <param name="lineNumber"> The line number. </param> protected BaseMessage( object sender, string message, MessageLevelEnum messageLevel, string callerFile = null, string methodName = null, int lineNumber = 0) : base(sender) { if (string.IsNullOrWhiteSpace(callerFile)) { throw new ArgumentException(nameof(callerFile)); } if (string.IsNullOrWhiteSpace(methodName)) { throw new ArgumentException(nameof(methodName)); } if (lineNumber <= 0) { throw new ArgumentException(nameof(lineNumber)); } Message = message; MessageLevel = messageLevel; ClassName = Path.GetFileNameWithoutExtension(callerFile); MethodName = methodName; LineNumber = lineNumber; }
/// <inheritdoc /> public void SendToTraceWindow <T>( string traceWindowKey, string leftMessage, T rightMessage, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }
/// <inheritdoc/> public void ExitMethod( string leftMessage, string rightMessage, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } if (string.IsNullOrWhiteSpace(leftMessage)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(leftMessage)); } if (string.IsNullOrWhiteSpace(rightMessage)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(rightMessage)); } try { _traceDictionary[messageLevel] .ExitMethod(leftMessage, rightMessage); } catch (ArgumentOutOfRangeException) { } }
static public void Write(MessageLevelEnum _level, string _tag, string _message) { foreach (Logger log in _List) { log.Write(_level, _tag, _message); } }
/// <inheritdoc /> public void SendDump( string leftMessage, string shortTitle, byte[] address, int count, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }
public void Write(MessageLevelEnum _level, string _tag, string _message) { if (!ShowPerLevel[(int)_level]) { return; } InternalWrite(_level, _tag, _message); }
protected override void InternalWrite(MessageLevelEnum _level, string _tag, string _message) { using (StreamWriter writer = new StreamWriter(Filename, true)) { WriteHeader(writer, _level, _tag); writer.WriteLine(_message); } }
public LogMessage(string _tag, string _message, MessageLevelEnum _level = MessageLevelEnum.Information) { Tag = _tag; Message = _message; Time = DateTime.Now; Color = Color.Black; Level = _level; }
/// <inheritdoc /> public void SendDumpToTraceWindow( string traceWindowKey, string leftMessage, string shortTitle, byte[] memoryDump, short count, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }
public LanguageChangedMessage( [JetBrains.Annotations.NotNull] object source, LanguageEnum payload, [JetBrains.Annotations.NotNull] string message, MessageLevelEnum messageLevel = MessageLevelEnum.Verbose, [CallerFilePath] string callerFile = null, [CallerMemberName] string methodName = null, [CallerLineNumber] int lineNumber = 0) : base(source, payload, message, messageLevel, callerFile, methodName, lineNumber) { }
void WriteHeader(StreamWriter _writer, MessageLevelEnum _level, string _tag) { string header = "[ " + _level.ToString(); if (!String.IsNullOrEmpty(_tag)) { header += ", " + _tag; } if (_WriteEllapsedTime) { TimeSpan ts = DateTime.Now - _StartTime; header += ", " + ts.ToString(@"hh\:mm\:ss\.ff"); } _writer.WriteLine(header + " ]"); }
/// <summary> /// Constructor. /// </summary> /// <param name="source"> Source for the. </param> /// <param name="payload"> The payload. </param> /// <param name="message"> The message. </param> /// <param name="messageLevel"> The message level. </param> /// <param name="callerFile"> The caller file. </param> /// <param name="methodName"> Name of the method. </param> /// <param name="lineNumber"> The line number. </param> protected PayloadMessage( [NotNull] object source, [NotNull] T payload, [NotNull] string message, MessageLevelEnum messageLevel, string callerFile = null, string methodName = null, int lineNumber = 0) : base(source, message, messageLevel, callerFile, methodName, lineNumber) { if (payload is null) { throw new ArgumentNullException(nameof(payload)); } Payload = payload; }
/// <inheritdoc/> public void SendToTraceWindow <T>( string key, string leftMessage, T rightMessage, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } try { SendToTraceWindow(key, leftMessage, rightMessage.ToString(), messageLevel); } catch (ArgumentOutOfRangeException) { } }
/// <inheritdoc/> public void Log( string header, string message, MessageLevelEnum level, LoggingTargetEnum outputTarget = LoggingTargetEnum.LogFile | LoggingTargetEnum.TraceTool | LoggingTargetEnum.OutputPanel, bool shouldLogHeader = true, bool isHeaderResourceKey = false) { Debug.Assert(!string.IsNullOrWhiteSpace(header), DevConstants.ValueCannotBeNullOrWhitespace); Debug.Assert(!string.IsNullOrWhiteSpace(message), DevConstants.ValueCannotBeNullOrWhitespace); var logToOutputPanel = (outputTarget & LoggingTargetEnum.OutputPanel) == LoggingTargetEnum.OutputPanel; var messageToLog = message; if (shouldLogHeader || logToOutputPanel) { var headerToLog = isHeaderResourceKey ? _localisationService.GetLocalisedString(header) : header; if (shouldLogHeader) { messageToLog = $"{headerToLog}: {message}"; } if (logToOutputPanel) { var watchLookup = new WatchLookup(headerToLog, message, _dateTimeService.Now, level); var outputMessage = _messageFactory.CreateOutputMessage(this, watchLookup, messageLevel: level); _messengerService.Send(outputMessage); } } if ((outputTarget & LoggingTargetEnum.LogFile) == LoggingTargetEnum.LogFile) { _logActionDictionary[level](messageToLog); } if (_traceService.IsEnabled && (outputTarget & LoggingTargetEnum.TraceTool) == LoggingTargetEnum.TraceTool) { _traceService.Send(messageToLog, level); } }
protected override void InternalWrite(MessageLevelEnum _level, string _tag, string _message) { string title = _level.ToString(); if (!String.IsNullOrEmpty(_tag)) { title += ", " + _tag; } MessageBoxIcon icon = MessageBoxIcon.Warning; if (_level == MessageLevelEnum.Error || _level == MessageLevelEnum.FatalError) { icon = MessageBoxIcon.Error; } else if (_level == MessageLevelEnum.Information) { icon = MessageBoxIcon.Information; } MessageBox.Show(_message, title, MessageBoxButtons.OK, icon); }
/// <summary> /// Constructor. /// </summary> /// /// <exception cref="ArgumentException"> Thrown when one or more arguments have unsupported or illegal values. </exception> /// /// <param name="header"> The Message Header. This cannot be null or whitespace. </param> /// <param name="message"> The Message Contents. This cannot be null or whitespace. </param> /// <param name="time"> The Date/Time. </param> /// <param name="messageLevel"> The message level. </param> public WatchLookup( [JetBrains.Annotations.NotNull] string header, [JetBrains.Annotations.NotNull] string message, DateTime time, MessageLevelEnum messageLevel) { if (string.IsNullOrWhiteSpace(header)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(header)); } if (string.IsNullOrWhiteSpace(message)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(message)); } Header = header; Message = message; Time = time; MessageLevel = messageLevel; }
/// <inheritdoc/> public void SendBackgroundColor( string leftMessage, int colour, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } if (string.IsNullOrWhiteSpace(leftMessage)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(leftMessage)); } try { _traceDictionary[messageLevel] .SendBackgroundColor(leftMessage, colour); } catch (ArgumentOutOfRangeException) { } }
/// <inheritdoc/> public void SendDumpToTraceWindow( string key, string leftMessage, string shortTitle, byte[] memoryDump, short count, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { if (!IsEnabled) { return; } if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(key)); } if (string.IsNullOrWhiteSpace(leftMessage)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(leftMessage)); } if (string.IsNullOrWhiteSpace(shortTitle)) { throw new ArgumentException(DevConstants.ValueCannotBeNullOrWhitespace, nameof(shortTitle)); } if (_traceWindowDictionary.TryGetValue(key, out var traceWindow)) { try { _windowDictionary[messageLevel](traceWindow) .SendDump(leftMessage, shortTitle, memoryDump, count); } catch (ArgumentOutOfRangeException) { } } }
protected override void InternalWrite(MessageLevelEnum _level, string _tag, string _message) { _Messages.Add(new LogMessage(_tag, _message, _level)); SendChangedEvent(); }
protected abstract void InternalWrite(MessageLevelEnum _level, string _tag, string _message);
/// <inheritdoc /> public void SendBackgroundColor( string leftMessage, int colour, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }
/// <inheritdoc /> public void SendObject( string leftMessage, object rightObject, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }
/// <inheritdoc /> public void Send( string leftMessage, string rightMessage, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }
/// <inheritdoc /> public void ExitMethod( string leftMessage, MessageLevelEnum messageLevel = MessageLevelEnum.Debug) { }