/// <summary> /// Log the silent message /// </summary> /// <param name="message">the message</param> /// <param name="level">the status level</param> public virtual void LogSilentMessage(string message, StatusLevel level) { lock (Lock) { LogSilentMessageExtraAction(level); var s = string.Format("{0} [{1}]>", DateTimeOffset.Now.ToString("dd-MMM-yyyy HH:mm:ss.fffffff zzz"), LocalizedDescriptionAttribute.GetEnumDescription(level)); //on calcule la plus grande longueur de texte //ça rend le texte plus lisible quand tout est aligné. s = s.PadRight(_maxStatusLevelWidth); // on rajoute des espaces pour aligner le paragraphe lorsque le message a plusieurs lignes. s += message.Replace("\n", "\n" + new string(' ', s.Length)); LogSilentMessageAppendLog(s); AppendLogFile(s + Environment.NewLine); } }
/// <summary> /// Initializes a new instance of the <see cref="LogMessageBase" /> class. /// </summary> /// <param name="applicationLogPath">the application log path</param> public LogMessageBase(string applicationLogPath) { _maxStatusLevelWidth = 44 + Math.Max(Math.Max(LocalizedDescriptionAttribute.GetEnumDescription(StatusLevel.Error).Length, LocalizedDescriptionAttribute.GetEnumDescription(StatusLevel.Warning).Length), Math.Max(LocalizedDescriptionAttribute.GetEnumDescription(StatusLevel.Success).Length, LocalizedDescriptionAttribute.GetEnumDescription(StatusLevel.Information).Length)); _applicationLogPath = applicationLogPath; }