コード例 #1
0
        /// <summary>
        /// Write log
        /// </summary>
        /// <param name="message">Usage mode: ex.ToString()</param>
        /// <param name="typeError">Error type enum </param>
        public void WriteLog(ErrorTypeEnum ErrorType, int idEvento, string message)
        {
            string logFilePath = System.Configuration.ConfigurationManager.AppSettings["LogFileNamePath"] ?? "";
            string logMapping  = System.Configuration.ConfigurationManager.AppSettings["LogMapping"].ToLower() ?? "all";

            logFilePath = logFilePath.Replace(".txt", string.Format("{0}{1}{2}.txt", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year));

            // Verifica el nivel de Log a registrar
            if (System.String.Compare(logMapping.ToLower(), "none", System.StringComparison.Ordinal) == 0)
            {
            }
            else
            {
                if (System.String.Compare(logMapping.ToLower(), "all", System.StringComparison.Ordinal) == 0) // Registra todos los Logs
                {
                    WriteToLogFile(logFilePath, ErrorType.ToString() + " " + idEvento + ": " + message);
                }
                else
                {
                    // Registra unicamente el nivel indicado
                    if (System.String.Compare(ErrorType.ToString().ToLower(), logMapping, System.StringComparison.Ordinal) == 0)
                    {
                        WriteToLogFile(logFilePath, ErrorType.ToString() + " " + idEvento + ": " + message);
                    }
                }
            }
        }
コード例 #2
0
 public override string ToString()
 {
     return("[DataspinError] while executing " + ((request != null) ? request.DataspinMethod.ToString() : "NO_METHOD") + ", Error type: " + errorType.ToString() +
            " - " + message + ((stackTrace == null) ? "" : ", Stack Trace: " + stackTrace));
 }