/// <summary> /// Posts a log message to all registered loggers. /// </summary> /// <param name="message">The message to post.</param> /// <param name="messageKind">Optional. The kind of the message.</param> /// <param name="messagePriority">Optional. The priority of the message.</param> /// <exception cref="System.ArgumentNullException">Is thrown if message is null.</exception> public static void PostGlobalLogMessage(string message, LogMessageKind messageKind = LogMessageKind.None, LogMessagePriority messagePriority = LogMessagePriority.Low) { if (message == null) { throw new ArgumentNullException(nameof(message)); } lock (LoggersLocker) { foreach (var logger in Loggers) { logger.PostMessage(message, messageKind, messagePriority); } } }
/// <summary> /// Posts a message to the logger output. /// </summary> /// <param name="message">The message to post.</param> /// <param name="messageKind">Optional. The kind of the message.</param> /// <param name="messagePriority">Optional. The priority of the message.</param> /// <remarks> /// A message kind different from none will be indicated by a prefix in the output. /// If the message priority is smaller then the priority of the logger, the message will not be postet. /// </remarks> /// <exception cref="System.ArgumentNullException">Is thrown if message is null.</exception> public void PostMessage(string message, LogMessageKind messageKind = LogMessageKind.None, LogMessagePriority messagePriority = LogMessagePriority.Low) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (messagePriority >= Priority) { var messageParts = new List <string>(); if (IncludeTimeStamp) { messageParts.Add(string.Concat("[", DateTime.Now.ToString(TimestampFormat), "]")); } if (messageKind != LogMessageKind.None) { messageParts.Add(MessageKindStrings[messageKind]); } messageParts.Add(message); this.SendToOutput(string.Join(" ", messageParts)); } }
/// <summary> /// Posts a message to the logger output. /// </summary> /// <param name="message">The message to post.</param> /// <param name="messageKind">Optional. The kind of the message.</param> /// <param name="messagePriority">Optional. The priority of the message.</param> /// <remarks> /// A message kind different from none will be indicated by a prefix in the output. /// If the message priority is smaller then the priority of the logger, the message will not be postet. /// </remarks> /// <exception cref="System.ArgumentNullException">Is thrown if message is null.</exception> public void PostMessage(string message, LogMessageKind messageKind = LogMessageKind.None, LogMessagePriority messagePriority = LogMessagePriority.Low) { if (message == null) throw new ArgumentNullException(nameof(message)); if (messagePriority >= Priority) { var messageParts = new List<string>(); if (IncludeTimeStamp) messageParts.Add(string.Concat("[", DateTime.Now.ToString(TimestampFormat), "]")); if (messageKind != LogMessageKind.None) messageParts.Add(MessageKindStrings[messageKind]); messageParts.Add(message); this.SendToOutput(string.Join(" ", messageParts)); } }