private static string _formatLogMSG(SAFLOGGER.LOGGEREventID loggerEventID, string appBASEid, string[] appMSGtext) { Process _thisProc = null; string result; try { _thisProc = Process.GetCurrentProcess(); result = string.Format("{0} [{1}] [{2}]", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), loggerEventID.ToString(), _thisProc.ProcessName) + " " + string.Join(" ", appMSGtext) + ((loggerEventID == SAFLOGGER.LOGGEREventID.EXCEPTION) ? string.Concat(new string[] { Environment.NewLine, SAFLOGGER._getMachineInfo(2)[0], Environment.NewLine, SAFLOGGER._getMachineInfo(2)[1], Environment.NewLine }) : ""); } catch { result = "... [ unable to format message ] ..."; } finally { if (_thisProc != null) { _thisProc.Dispose(); } _thisProc = null; } return(result); }
public static void Write(SAFLOGGER.LOGGEREventID loggerEventID, string appBASEid, string[] appMSGtext) { try { int _SAFDEPLOYTRACELevel; if (-9 == (_SAFDEPLOYTRACELevel = int.Parse("0" + ConfigurationManager.AppSettings.Get("SAFTRACE_LEVEL")))) { Debug.Write(SAFLOGGER._formatLogMSG(loggerEventID, appBASEid, appMSGtext)); if (loggerEventID != (SAFLOGGER.LOGGEREventID)(-1)) { return; } } if (loggerEventID <= (SAFLOGGER.LOGGEREventID)_SAFDEPLOYTRACELevel) { SAFLOGGER.writeToFile(appBASEid, SAFLOGGER._formatLogMSG(loggerEventID, appBASEid, appMSGtext)); } } catch (Exception ex) { SAFLOGGER.writeToEventLog(EventLogEntryType.Error, SAFLOGGER._formatLogMSG(SAFLOGGER.LOGGEREventID.EXCEPTION, "http://sfexpandsecure.logger.softfinanca.com/", new string[] { ex.ToString(), "unable to dump message log!!" }) + Environment.NewLine + SAFLOGGER._formatLogMSG(loggerEventID, appBASEid, appMSGtext)); } }
public static void dump(SAFLOGGER.LOGGEREventID loggerEventID, string appBASEid, string[] appMSGtext) { SAFLOGGER.writeToFile(appBASEid, SAFLOGGER._formatLogMSG(loggerEventID, appBASEid, appMSGtext)); }