Example #1
0
        public void SaveLogFile(string path, Log.ErrorLogType type, string message)
        {
            try
            {
                switch (type)
                {
                case Log.ErrorLogType.TXT:

                    WriteSimpleFormat(path, ConvertMessage(message, type));
                    break;

                case Log.ErrorLogType.CSV:
                    WriteSimpleFormat(path, ConvertMessage(message, type));
                    break;

                case Log.ErrorLogType.TSV:
                    WriteSimpleFormat(path, ConvertMessage(message, type));
                    break;

                case Log.ErrorLogType.XML:
                    WriteXmlFile(path, message);
                    break;
                }
            }
            catch (Exception)
            {
            }
        }
Example #2
0
        private string ConvertMessage(string message, Log.ErrorLogType type)
        {
            switch (type)
            {
            case Log.ErrorLogType.TXT:
                return(DateTime.Now.ToString() + " " + message);

                break;

            case Log.ErrorLogType.CSV:
                return("\"" + AddQuotes(DateTime.Now.ToString()) + "\",\"" + AddQuotes(message) + "\"");

                break;

            case Log.ErrorLogType.TSV:
                return("\"" + AddQuotes(DateTime.Now.ToString()) + "\"\t\"" + AddQuotes(message) + "\"");

                break;

            default:
                throw new InvalidCastException();
                break;
            }
        }