示例#1
0
        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);
        }
示例#2
0
 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));
     }
 }
示例#3
0
 private static void writeToEventLog(EventLogEntryType evtLogType, string evtLogText)
 {
     try
     {
         if (!EventLog.SourceExists("SAFLOGGER", "."))
         {
             EventLog.CreateEventSource(new EventSourceCreationData("SAFLOGGER", "SAFLOGGER"));
         }
         new EventLog("SAFLOGGER", ".", "SAFLOGGER").WriteEntry(evtLogText, evtLogType);
     }
     catch (Exception ex)
     {
         Debug.Write(SAFLOGGER._formatLogMSG(SAFLOGGER.LOGGEREventID.EXCEPTION, "http://sfexpandsecure.logger.softfinanca.com/", new string[]
         {
             "unable to write on EventLOG",
             ex.ToString()
         }));
         Debug.Write(evtLogText);
     }
 }
		private static void _logger(SAFLOGGER.LOGGEREventID loggerEventID, string modName, string[] arrayMessages)
		{
			SAFLOGGER.Write(loggerEventID, modName, arrayMessages);
			SAFInternalEvents.Export(APPEVENTSDeff.GENERIC_EVENTS, (int)loggerEventID, "SAFBUSINESS", arrayMessages);
		}
示例#5
0
 public static void dump(SAFLOGGER.LOGGEREventID loggerEventID, string appBASEid, string[] appMSGtext)
 {
     SAFLOGGER.writeToFile(appBASEid, SAFLOGGER._formatLogMSG(loggerEventID, appBASEid, appMSGtext));
 }
示例#6
0
        private static void writeToFile(string fileBaseName, string _logMessage)
        {
            int    _filelockDelay = 0;
            string _baseFilePath  = null;

            try
            {
                string _fileFormater;
                if (null == (_fileFormater = ConfigurationManager.AppSettings.Get("SAFTRACE_FILENAMEFORMATER")))
                {
                    _fileFormater = "yyyyMMddHH";
                }
                string _filePathName;
                if (null == (_filePathName = ConfigurationManager.AppSettings.Get("SAFTRACE_FILEPATH")))
                {
                    _filePathName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                }
                _baseFilePath = Path.Combine(_filePathName, string.Format(fileBaseName.Trim() + "{0}.LOG", DateTime.Now.ToString(_fileFormater)));
                int.TryParse("0" + ConfigurationManager.AppSettings.Get("SAFTRACE_FILELOCKDELAY"), out _filelockDelay);
            }
            catch (Exception ex)
            {
                Debug.Write(SAFLOGGER._formatLogMSG(SAFLOGGER.LOGGEREventID.WARNING, "http://sfexpandsecure.logger.softfinanca.com/", new string[]
                {
                    "unable to write message!",
                    ex.ToString()
                }));
                Debug.Write(_logMessage);
                return;
            }
            if (Monitor.TryEnter(SAFLOGGER.s_Lock, (_filelockDelay < 1000) ? 1000 : _filelockDelay))
            {
                try
                {
                    object obj;
                    Monitor.Enter(obj = SAFLOGGER.s_Lock);
                    try
                    {
                        if (SAFLOGGER.s_Writer == null)
                        {
                            if (!File.Exists(_baseFilePath))
                            {
                                SAFLOGGER.s_Writer = File.CreateText(_baseFilePath);
                                string[] _fileHeaders = SAFLOGGER._getMachineInfo(1);
                                SAFLOGGER.s_Writer.WriteLine(_fileHeaders[0] + Environment.NewLine + _fileHeaders[1] + Environment.NewLine);
                            }
                            else
                            {
                                SAFLOGGER.s_Writer = File.AppendText(_baseFilePath);
                            }
                        }
                        SAFLOGGER.s_Writer.WriteLine(_logMessage);
                        SAFLOGGER.s_Writer.Flush();
                        SAFLOGGER.s_Writer.Close();
                    }
                    finally
                    {
                        Monitor.Exit(obj);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Write(SAFLOGGER._formatLogMSG(SAFLOGGER.LOGGEREventID.WARNING, "http://sfexpandsecure.logger.softfinanca.com/", new string[]
                    {
                        "unable to write message!",
                        ex.ToString()
                    }));
                    Debug.Write(_logMessage);
                }
                finally
                {
                    SAFLOGGER.s_Writer = null;
                    Monitor.Exit(SAFLOGGER.s_Lock);
                }
            }
            else
            {
                SAFLOGGER.writeToEventLog(EventLogEntryType.Error, SAFLOGGER._formatLogMSG(SAFLOGGER.LOGGEREventID.EXCEPTION, "http://sfexpandsecure.logger.softfinanca.com/", new string[]
                {
                    "Timeout; could not obtain lock to log file!"
                }) + Environment.NewLine + _logMessage);
                Debug.Write(SAFLOGGER._formatLogMSG(SAFLOGGER.LOGGEREventID.WARNING, "http://sfexpandsecure.logger.softfinanca.com/", new string[]
                {
                    "Timeout; could not obtain lock to log file!"
                }));
            }
        }
示例#7
0
		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;
		}
示例#8
0
		public static void dump(SAFLOGGER.LOGGEREventID loggerEventID, string appBASEid, string[] appMSGtext)
		{
			SAFLOGGER.writeToFile(appBASEid, SAFLOGGER._formatLogMSG(loggerEventID, appBASEid, appMSGtext));
		}
示例#9
0
		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));
			}
		}