Example #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="logEntry">New log entry.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>logEntry</b> is null.</exception>
        public WriteLogEventArgs(LogEntry logEntry)
        {
            if(logEntry == null){
                throw new ArgumentNullException("logEntry");
            }

            m_pLogEntry = logEntry;
        }
Example #2
0
        /// <summary>
        /// Writes specified log entry to log file.
        /// </summary>
        /// <param name="file">Log file.</param>
        /// <param name="e">Log entry to write.</param>
        public static void WriteLog(string file,LogEntry e)
        {
            try{
                using(TextDb db = new TextDb('\t')){
                    db.OpenOrCreate(file);

                    //db.AppendComment("Fields: ID Time RemoteEndPoint AuthenticatedUser LogType LogText");
                    
                    string logText = "";
                    if(e.Text != null){
                        logText = e.Text.Replace("\r","");
                        if(logText.EndsWith("\n")){
                            logText = logText.Substring(0,logText.Length - 1);
                        }
                    }

                    string logType = "";
                    if(e.EntryType == LogEntryType.Text){
                        logType = "xxx";
                    }
                    else if(e.EntryType == LogEntryType.Read){
                        logType = "<<<";
                    }
                    else if(e.EntryType == LogEntryType.Write){
                        logType = ">>>";
                    }

                    foreach(string logLine in logText.Split('\n')){
                        db.Append(new string[]{
                            e.ID,
                            DateTime.Now.ToString(),
                            e.RemoteEndPoint != null ? e.RemoteEndPoint.ToString() : "",
                            e.UserIdentity != null ? e.UserIdentity.Name : "",
                            logType,
                            logLine
                        });
                    }                    
                }
            }
            catch(Exception x){
                Error.DumpError(x,new System.Diagnostics.StackTrace());
            }
        }
Example #3
0
 /// <summary>
 /// Raises WriteLog event.
 /// </summary>
 /// <param name="entry">Log entry.</param>
 private void OnWriteLog(LogEntry entry)
 {
     if(this.WriteLog != null){
         this.WriteLog(this,new WriteLogEventArgs(entry));
     }
 }