コード例 #1
0
 /// <summary>
 /// Logs the provided Exception as Error Output
 ///
 /// TO BE USED TO LOG Exceptions ONLY
 /// </summary>
 /// <param name="e">Exception to output</param>
 /// <returns>True if log successful</returns>
 public static bool Error(Exception e)
 {
     lock (Threads.GenericThreadSafeLock)
     {
         Directories.DirectoryPrepare("./Logs/");
         Directories.DirectoryPrepare("./Logs/ErrorLogs/");
         string LogFile = "./Logs/ErrorLogs/" + OYS_DateTime.ToOYSLongDateTime(TimeStarted).ReplaceAll("/", "_").ReplaceAll(" ", "_").ReplaceAll(":", "_") + ".html";
         Files.PrepareHTMLLog(LogFile);
         System.Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", "./Debug/");
         var    st     = new StackTrace(e, true);
         var    frame  = st.GetFrame(0);
         string output = "";
         output += "&cMESSAGE:      &e" + e.Message + "\n";
         output += "&cSTART TRACE:  \n";
         foreach (StackFrame Frame in st.GetFrames())
         {
             output += "&c    METHOD:       &e" + frame.GetMethod() + "\n";
             output += "&c        LINENUMBER:   &e" + frame.GetFileLineNumber() + "\n";
             output += "&c        COLUMNNUMBER: &e" + frame.GetFileColumnNumber() + "\n";
         }
         output += "&cEND TRACE.\n";
         output += "\n";
         List <string> MessagesOut = new List <string>();
         foreach (string Line in output.Split('\n'))
         {
             MessagesOut.Add(String.Format("{0}: {1}", OYS_DateTime.ToOYSLongDateTime(DateTime.Now), Line));
         }
         Files.FileHTMLAppend(LogFile, MessagesOut.ToArray());
     }
     return(true);
 }
コード例 #2
0
        /// <summary>
        /// Logs the provided string as Console Output
        ///
        /// TO BE USED TO LOG CONSOLE OUTPUT ONLY
        /// </summary>
        /// <param name="Input">String to output</param>
        /// <returns>True if log successful</returns>
        public static bool ConsoleOutput(string Input, params object[] args)
        {
            if (args == null)
            {
                args = new object[0];
            }
            if (args.Length > 0)
            {
                try
                {
                    Input = String.Format(Input, args);
                }
                catch (Exception e)
                {
                    Input = e.StackTrace + "\n" + Input;
                }
            }

            lock (Threads.GenericThreadSafeLock)
            {
                Directories.DirectoryPrepare("./Logs/");
                Directories.DirectoryPrepare("./Logs/ConsoleLogs/");
                string LogFile = "./Logs/ConsoleLogs/" + OYS_DateTime.ToOYSLongDateTime(TimeStarted).ReplaceAll("(", "_").ReplaceAll(" ", "_").ReplaceAll(")", "_") + ".html";
                Files.PrepareHTMLLog(LogFile);
                string[] MessageOut = { String.Format("{0}: {1}", OYS_DateTime.ToOYSLongDateTime(DateTime.Now), Input) };
                Files.FileHTMLAppend(LogFile, MessageOut);
            }
            return(true);
        }
コード例 #3
0
 /// <summary>
 /// Logs the provided string as a debug message
 ///
 /// TO BE USED TO LOG DEBUGGING OUTPUT ONLY
 /// (WHEN DEBUGGING WITH OPENYS PARTICIPANTS AND NOT ON LOCAL SYSTEM.)
 ///
 /// ****
 ///
 /// TO DEBUG ON LOCAL SYSTEM, USE INSTEAD DEBUG.WRITELINE() AND
 /// THE MESSAGE WILL BE OUTPUT TO VISUAL STUDIO OUTPUT FEED!
 ///
 /// ****
 /// </summary>
 /// <param name="Out">String to output</param>
 /// <returns>True if log successful</returns>
 public static bool Debug(string Out, params object[] args)
 {
     if (args == null)
     {
         args = new object[0];
     }
     if (args.Length > 0)
     {
         try
         {
             Out = String.Format(Out, args);
         }
         catch (Exception e)
         {
             Out = e.StackTrace + "\n" + Out;
         }
     }
     lock (Threads.GenericThreadSafeLock)
     {
         Directories.DirectoryPrepare("./Logs/");
         Directories.DirectoryPrepare("./Logs/DebuggingLogs/");
         string LogFile = "./Logs/DebuggingLogs/" + OYS_DateTime.ToOYSLongDateTime(TimeStarted).ReplaceAll("/", "_").ReplaceAll(" ", "_").ReplaceAll(":", "_") + ".html";
         Files.PrepareHTMLLog(LogFile);
         List <string> MessagesOut = new List <string>();
         MessagesOut.Add(String.Format("{0}: {1}", OYS_DateTime.ToOYSLongDateTime(DateTime.Now), Out));
         Files.FileHTMLAppend(LogFile, MessagesOut.ToArray());
     }
     return(true);
 }
コード例 #4
0
 /// <summary>
 /// Logs the provided string as a Data Dump
 ///
 /// TO BE USED TO LOG DATA DUMPS FROM THE /DUMP COMMAND ONLY
 /// </summary>
 /// <param name="Out">String to output</param>
 /// <returns>True if log successful</returns>
 public static bool DataDump(string Input)
 {
     lock (Threads.GenericThreadSafeLock)
     {
         Directories.DirectoryPrepare("./Logs/");
         Directories.DirectoryPrepare("./Logs/DumpLogs/");
         string LogFile = "./Logs/DumpLogs/" + OYS_DateTime.ToOYSLongDateTime(DumpTime).ReplaceAll("/", "_").ReplaceAll(" ", "_").ReplaceAll(":", "_") + ".html";
         Files.PrepareHTMLLog(LogFile);
         String[] MessageOut = { String.Format("{0}: {1}", OYS_DateTime.ToOYSLongDateTime(DumpTime), Input) };
         Files.FileHTMLAppend(LogFile, MessageOut);
     }
     return(true);
 }
コード例 #5
0
 /// <summary>
 /// Logs the provided Packets List as a Packet Log.
 ///
 /// TO BE USED TO LOG PACKETS ONLY
 /// </summary>
 /// <param name="Out">String to output</param>
 /// <returns>True if log successful</returns>
 public static bool Packets(List <string> Out)
 {
     lock (Threads.GenericThreadSafeLock)
     {
         Directories.DirectoryPrepare("./Logs/");
         Directories.DirectoryPrepare("./Logs/PacketLogs/");
         string LogFile = "./Logs/PacketLogs/" + OYS_DateTime.ToOYSLongDateTime(DateTime.Now).ReplaceAll("/", "_").ReplaceAll(" ", "_").ReplaceAll(":", "_") + ".html";
         Files.PrepareHTMLLog(LogFile);
         List <string> MessagesOut = new List <string>();
         foreach (string ThisString in Out)
         {
             MessagesOut.Add(String.Format("{0}: {1}", OYS_DateTime.ToOYSLongDateTime(DateTime.Now), ThisString));
         }
         Files.FileHTMLAppend(LogFile, MessagesOut.ToArray());
     }
     return(true);
 }