/// <summary> /// This gets called by <see cref="Log"/> when it needs something logged. /// </summary> /// <param name="logging">The <see cref="Logging"/> instance containing logging information.</param> /// <remarks>This method is fed into a <see cref="System.Threading.Tasks.Task.Run(Action, System.Threading.CancellationToken)"/>.</remarks> public override void PerformLog(Logging logging) { ConsoleColor lastColor = Console.ForegroundColor; Console.ForegroundColor = GetColor(logging.Level); Console.WriteLine((string)logging); Console.ForegroundColor = lastColor; }
private void DoLogging(LogLevel level, string format, object[] args) { if (disposed) throw new ObjectDisposedException(nameof(Log)); else if (ReferenceEquals(format, null)) throw new ArgumentNullException(nameof(format)); else if (ReferenceEquals(format, null)) throw new ArgumentNullException(nameof(args)); Logging logging = new Logging() { Name = show ? name : null, Level = level, Message = string.Format(Translations.Phrases.Culture, format, args) }; lock(myLock) { foreach (BaseLogger logger in loggers.Where(logger => level >= logger.MinimumLevel)) Task.Run(() => logger.PerformLog(logging), CancellationToken.None); } }
/// <summary> /// This gets called by <see cref="Log"/> when it needs something logged. /// </summary> /// <param name="logging">The <see cref="Logging"/> instance containing logging information.</param> /// <remarks>This method is fed into a <see cref="System.Threading.Tasks.Task.Run(Action, System.Threading.CancellationToken)"/>.</remarks> public override void PerformLog(Logging logging) { lock(myLock) { fileWriter.WriteLine(logging); } }
/// <summary> /// This gets called by <see cref="Log"/> when it needs something logged. /// </summary> /// <param name="logging">The <see cref="Logging"/> instance containing logging information.</param> /// <remarks>This method is fed into a <see cref="System.Threading.Tasks.Task.Run(Action, System.Threading.CancellationToken)"/>.</remarks> public abstract void PerformLog(Logging logging);