Esempio n. 1
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			static public bool AppendLogFile()
         *	\brief		Writes new logs into a file
         *	\details	This writes individual logs into the file specified by the loggerPath variable.
         *	If there is an error, it throws an exception to a new log.
         *	\exception	From FileStream and StreamWriter
         *	\see		LogIt()
         *	\return		bool    appendSuccess    A value indicating whether the file write threw an exception.
         *
         * ---------------------------------------------------------------------------------------------------- */
        static public bool AppendLogFile(TMSLog newLog)
        {
            bool appendSuccess = true;

            try
            {
                /// Open the filestream to append to the file.
                FileStream   fileStream = new FileStream(TMSLogger.LogFilePath, FileMode.Append, FileAccess.Write);
                StreamWriter fileWriter = new StreamWriter(fileStream);

                /// Add each log entry from the working list to the file as a BSV
                fileWriter.WriteLine(newLog.BSV);
                fileWriter.Flush();

                /// Close the file
                fileWriter.Close(); fileStream.Close();
            }
            /// If an exception is thrown here, catch it
            catch (Exception e)
            {
                /// This could become problematic if it calls itself
                LogIt("|" + thisFileDir + "/AdminClasses.cs" + "|" + "TMSLogger" + "|" + "AppendLogFile" + "|" + "Exception" + "|" + e.Message + "|");
                appendSuccess = false;
            }

            return(appendSuccess);
        }
Esempio n. 2
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			static public void LogIt(string newLogString)
         *	\brief		This creates a new log object
         *	\details	This creates a new log object, adds it to the local list, then appends it to the
         *	external file
         *	\param[in]	string  newLogString    This is the unparsed BSV string to create the file.
         *	\see		TMSLog(), logs.Add(), AppendLogFile()
         *	\return		void
         *
         * ---------------------------------------------------------------------------------------------------- */
        static public void LogIt(string newLogString)
        {
            TMSLog myLog = new TMSLog(newLogString);

            logs.Add(myLog);
            if (AppendLogFile(myLog) == false)
            {
                /// Error writing to Log File: Try once again
                AppendLogFile(myLog);
            }
            ;

            try
            {
                LogStatusEvent(myLog);
            }
            catch (Exception e)
            {
                TMSLogger.NewLog(" | " + "AdminClasses.cs" + " | " + "TMSLogger" + " | " + "LogIt" + " | " + e.GetType().ToString() + " | " + e.Message + " | ");
                //megan look here
            }
        }
Esempio n. 3
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			static public void NewLog(string newLogString)
         *	\brief		This creates a new log object
         *	\details	This creates a new log object, and adds it to the local list. This exists so that the
         *	function ReadExistingLogFile doesn't call recursively.
         *	\param[in]	string  newLogString    This is the unparsed BSV string to create the file.
         *	\see		TMSLog(), logs.Add()
         *	\return		void
         *
         * ---------------------------------------------------------------------------------------------------- */
        static public void NewLog(string newLogString)
        {
            TMSLog myLog = new TMSLog(newLogString);

            logs.Add(myLog);
        }