Beispiel #1
0
            /*
             * pushes a log message to the tray icon, as well as the
             * log window
             * 
             * @param le is the log event to be logged
             */
			static void SendLogEvent(LogEvent le) 
            {
				if (PushLogEvent != null)
				{
                    ti.AddLine(le);
					PushLogEvent(le);
                    WriteLogFile(le);
				}
			}
Beispiel #2
0
            /*
             * pushes log events to the event log file
             * Log\Event_<date>.log
             * 
             * These logs are purged by the cleanLogs() method.
             */
            private static void WriteLogFile(LogEvent le)
            {
                string currentdate = DateTime.Now.ToString("M-d-yyyy");
                string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                folder = folder + Path.DirectorySeparatorChar + "firebwall";
                if (!Directory.Exists(folder))
                    Directory.CreateDirectory(folder);
                folder = folder + Path.DirectorySeparatorChar + "Log";
                if (!Directory.Exists(folder))
                    Directory.CreateDirectory(folder);
                string filepath = folder;
                string filename = Path.DirectorySeparatorChar + "Event_" + currentdate + ".log";

                FileStream stream;
                // if the log event is not null
                if (le != null)
                {
                    // if the Log folder exists already
                    if (Directory.Exists(filepath))
                    {
                        // if the file exists, open in append and write to it
                        if (File.Exists(filepath + filename))
                            stream = new FileStream(filepath + filename, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                        else
                            stream = new FileStream(filepath + filename, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite);

                        StreamWriter m_streamWriter = new StreamWriter(stream);
                        m_streamWriter.WriteLine(le.time.ToString() + " " + le.Module + ": " + le.Message + "\r");
                        m_streamWriter.Close();
                        stream.Close();
                    }

                    // if the log path does not exist, create it and write out the log
                    if (!(Directory.Exists(filepath)))
                    {
                        Directory.CreateDirectory(filepath);
                        stream = new FileStream(filepath + filename, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite);
                        StreamWriter m_streamWriter = new StreamWriter(stream);
                        m_streamWriter.WriteLine(le.time.ToString() + " " + le.Module + ": " + le.Message + "\r");
                        m_streamWriter.Close();
                        stream.Close();
                    }
                }
            }
Beispiel #3
0
            // generates the LogEvent object and pushes it out to be logged
			public void Push(string Module, string Message) 
            {
				LogEvent le = new LogEvent(Module, Message);
                logQueue.Enqueue(le);
			}
Beispiel #4
0
        /// <summary>
        /// Adds a line to the display queue
        /// </summary>
        /// <param name="line"></param>
		public void AddLine(LogEvent line) 
        {
            // only display if checked AND the return type is to notify
            if (displayTrayLogs && line.PMR != null && ((line.PMR.returnType & FM.PacketMainReturnType.Popup) == FM.PacketMainReturnType.Popup))
            {
                popup.AddLogEvent(line);
            }
		}