示例#1
0
        /// <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());
        }
示例#2
0
 /// <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));
 }
示例#3
0
 /// <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));
 }
示例#4
0
        /// <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);
        }