Пример #1
0
 static Tracer()
 {
     try
     {
         LoggingService = new LoggingService();
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer constructor", e);
     }
 }
Пример #2
0
 public static void TraceDebug(string message, params object[] parameters)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         TraceMessage(LogLevel.Debug, message + FormatParams(parameters), null, fullName, null, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceDebug", e);
     }
 }
Пример #3
0
 public static void Trace(LogLevel severity, string message)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         TraceMessage(severity, message, null, fullName, null, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.Trace", e);
     }
 }
Пример #4
0
 public static void TraceError(string errorMessage, int errorNumber = 0)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         TraceMessage(LogLevel.Error, errorMessage, null, fullName, null, errorNumber, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceError", e);
     }
 }
Пример #5
0
        private LogLevel GetNLogLevelFromSeverity(int severity)
        {
            LogLevel info = LogLevel.Info;

            try
            {
                info = LogLevel.FromOrdinal(severity);
            }
            catch (Exception e)
            {
                Ultities.EventLogException("LoggingService.GetNLogLevelFromSeverity", e);
            }
            return(info);
        }
Пример #6
0
 private static void TraceException(LogLevel severity, Exception exception, string message = null)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         if (!string.IsNullOrEmpty(message))
         {
             TraceMessage(severity, message, null, fullName, null, 0, false);
         }
         TraceMessage(severity, null, null, fullName, exception, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceException", e);
     }
 }
Пример #7
0
        public static void TraceDataSet(LogLevel severity, DataSet dataset)
        {
            string fullName = Assembly.GetCallingAssembly().FullName;

            try
            {
                if (dataset == null)
                {
                    TraceMessage(LogLevel.Error, "TraceDataSet called with a null dataset", null, fullName, null, 0, false);
                }
                else
                {
                    string tempFileName = Path.GetTempFileName();
                    dataset.WriteXml(tempFileName);
                    TraceMessage(severity, "The DataSet file was written to:" + tempFileName, null, fullName, null, 0, false);
                }
            }
            catch (Exception e)
            {
                Ultities.EventLogException("Tracer.TraceDataSet", e);
            }
        }
Пример #8
0
        private static void TraceFunc(string functionName, bool enterFunc = false, params object[] parameters)
        {
            string fullName = Assembly.GetCallingAssembly().FullName;

            string isEnterStr = enterFunc ? "TraceEnterFunc" : "TraceExitFunc";

            try
            {
                if (string.IsNullOrEmpty(functionName))
                {
                    TraceMessage(LogLevel.Error, isEnterStr + " called with a null function name.", null, fullName, null,
                                 0, false);
                }
                else
                {
                    TraceMessage(LogLevel.Trace, isEnterStr + functionName + FormatParams(parameters), null, fullName,
                                 null, 0, false);
                }
            }
            catch (Exception e)
            {
                Ultities.EventLogException("Tracers.Tracer." + isEnterStr, e);
            }
        }