static Tracer() { try { LoggingService = new LoggingService(); } catch (Exception e) { Ultities.EventLogException("Tracer constructor", e); } }
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); } }
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); } }
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); } }
private LogLevel GetNLogLevelFromSeverity(int severity) { LogLevel info = LogLevel.Info; try { info = LogLevel.FromOrdinal(severity); } catch (Exception e) { Ultities.EventLogException("LoggingService.GetNLogLevelFromSeverity", e); } return(info); }
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); } }
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); } }
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); } }