示例#1
0
        /// <summary>
        /// create an entry into the log with a string as a sender
        /// </summary>
        /// <param name="Msg">the message</param>
        /// <param name="type">the type of the entry</param>
        /// <param name="sender">the sender as a string</param>
        /// <returns>the message in the log format</returns>
        public static string logInput(string Msg, logType type, string sender)
        {
            if (sender != null)
            {
                logFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() +
                            " [" + type.ToString() + "] " +
                            " | " + sender + " ==> ";
            }
            else
            {
                logFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " ==> ";
            }

            sw.WriteLine(logFormat + " " + Msg);
            sw.Flush();

            //dispatch the message to the visual consol
            if (logMessageReceivedEventHandler != null)
            {
                logMessageReceivedEventHandler(sender, new LogMessageEvent(logFormat + " " + Msg));
            }
            Console.WriteLine(logFormat + " " + Msg);

            return(logFormat + " " + Msg);
        }
示例#2
0
        public static void Log(logType type, string text)
        {
            switch (type)
            {
            case logType.Info:
                Console.ForegroundColor = ConsoleColor.Cyan;
                break;

            case logType.Warning:
                Console.ForegroundColor = ConsoleColor.Yellow;
                break;

            case logType.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                break;
            }
            Console.WriteLine("[{0}-{1}] {2}", type.ToString().ToUpper(), DateTime.Now, text);
            Console.ResetColor();
        }
示例#3
0
        public static void WriteLogFile(logType type, string message, string extras = "")
        {
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (form != null)
            {
                if (type == logType.Debug)
                {
                    if (bool.Parse(config.AppSettings.Settings["DebugMode"].Value.ToString()))
                    {
                        form.LogOutput.Items.Add(DateTime.Now.ToString("HH:mm:ss") + ": ----" + type.ToString() + ":  " + message + "  " + extras);
                    }
                }
                else
                {
                    form.LogOutput.Items.Add(DateTime.Now.ToString("HH:mm:ss") + ": ----" + type.ToString() + ":  " + message + "  " + extras);
                }

                form.LogOutput.SelectedIndex = form.LogOutput.Items.Count - 1;
                form.LogOutput.SelectedIndex = -1;
            }
            else
            {
                return;
            }
        }
示例#4
0
        /// <summary>
        /// create an entry into the log with a string as a sender
        /// </summary>
        /// <param name="Msg">the message</param>
        /// <param name="type">the type of the entry</param>
        /// <param name="sender">the sender as a string</param>
        /// <returns>the message in the log format</returns>
        public static string logInput(string Msg, logType type, string sender)
        {
            if (sender != null)
            {
                logFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() +
                    " [" + type.ToString() + "] " +
                    " | " + sender + " ==> ";
            }
            else
            {
                logFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " ==> ";
            }

            sw.WriteLine(logFormat + " " + Msg);
            sw.Flush();

            //dispatch the message to the visual consol
            if (logMessageReceivedEventHandler != null) logMessageReceivedEventHandler(sender , new LogMessageEvent(logFormat + " " + Msg));
            Console.WriteLine(logFormat + " " + Msg);

            return logFormat + " " + Msg;
        }
示例#5
0
 public void ChangeLevel(logType level)
 {
     logLevel = level;
     Write("Change to " + logLevel.ToString(), logType.info, logConsole.show);
 }