/// <summary> /// Formatta una messaggio per scrittura log con la specifica del formato data e scrittura thread /// </summary> /// <param name="dateFromat"></param> /// <param name="writeThreadId"></param> /// <param name="msgIn"></param> /// <param name="args"></param> /// <returns></returns> public static string FormatLogTextMessage(string dateFromat, bool writeThreadId, string msgIn, params object[] args) { StringBuilder sbLogMsg = new StringBuilder(); //DataOra sbLogMsg.Append(DateTime.Now.ToString(dateFromat)); //Thread if (writeThreadId) { sbLogMsg.Append(LoggerBase.getLogThreadInfo()); } //Cattura eventuali errori di formattazione try { sbLogMsg.AppendFormat(msgIn, args); } catch (Exception e) { sbLogMsg.Append(msgIn); if (args != null) { sbLogMsg.Append(@" - Args: "); for (int i = 0; i < args.Length; i++) { sbLogMsg.Append(args[i]); sbLogMsg.Append(@", "); } } sbLogMsg.Append(e.Message); } //Ritorna return(sbLogMsg.ToString()); }
/// <summary> /// Scrive informazioni su eccezione /// </summary> /// <param name="e"></param> /// <param name="includeStack"></param> public override void LogException(Exception e, bool includeStack) { this.writeDataToFile(LoggerBase.FormatLogTextException(this.DateFormat, this.WriteThreadId, e, includeStack)); }
/// <summary> /// Scrive Messaggio Log /// </summary> /// <param name="msgIn"></param> /// <param name="args"></param> public override void LogMessage(string msgIn, params object[] args) { this.writeDataToFile(LoggerBase.FormatLogTextMessage(this.DateFormat, this.WriteThreadId, msgIn, args)); }
/// <summary> /// Scrive Messaggio Log /// </summary> /// <param name="msgIn"></param> /// <param name="args"></param> public override void LogMessage(string msgIn, params object[] args) { string s = LoggerBase.FormatLogTextMessage(msgIn, args, this.DateFormat, this.WriteThreadId); this.appendLogData(ref s); }