Exemple #1
0
        private string CreateHeader(string description, string data, bool withTime, bool input)
        {
            string text = "";

            // ----- Show time -----
            if (withTime)
            {
                if (ShowTimeDate)
                {
                    text = LastLogTime.ToShortDateString() + "  ";
                }
                if (ShowTimeMs)
                {
                    text += LastLogTime.ToString("HH:mm:ss.fff") + "  ";
                }
                else
                {
                    text += LastLogTime.ToString("HH:mm:ss") + "  ";
                }
            }

            // ----- Show direction array -----
            if (ShowDirection)
            {
                if (input)
                {
                    text += ">>  ";
                }
                else
                {
                    text += "<<  ";
                }
            }

            // ----- Add description ------
            if (description != "")
            {
                text += description;
                if (data != "")
                {
                    text += ": ";
                }
            }

            // ----- Add data ------
            //text += data;

            return(text);
        }
Exemple #2
0
        public ExceptionLog(string fileName, string message, Exception exception)
        {
            string timeStr = DateTime.Now.ToString("MM_dd_yyyy__hh_mm_ss");

            if (LastLogTime.AddSeconds(1) > DateTime.Now)
            {
                timeStr = DateTime.Now.ToString("MM_dd_yyyy__hh_mm_ss_ms");
            }
            Initialize(fileName + "_" + timeStr);
            Write(message);
            Write("Exception type: " + exception.GetType());
            Write(exception.ToString());
            Write(exception.Message);
            Write(exception.StackTrace);
            ERRORS_RECORDED++;
        }