Esempio n. 1
0
        private SiteLog StandardDBEntry()
        {
            SiteLog logEntry = new SiteLog();
            logEntry.TimeStamp = DateTime.UtcNow.AddHours(-5);

            if (HttpContext.Current != null && HttpContext.Current.Session != null)
                logEntry.SessionId = HttpContext.Current.Session.SessionID;

            try
            {

                if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.User != null && HttpContext.Current.User.Identity != null)
                    logEntry.Custom = "User="******", Host=" +
                                    HttpContext.Current.Request.UserHostName + ", URL=" +
                                    HttpContext.Current.Request.RawUrl + ", Form=" +
                                    HttpContext.Current.Request.Form.ToString() + ", Referrer=" +
                                    HttpContext.Current.Request.UrlReferrer;
            }
            catch (System.Web.HttpException e)
            {
                logEntry.Custom = "Abject object failure. Probably startup. Msg: " + e.Message;
            }

            logEntry.ThreadID = Thread.CurrentThread.ManagedThreadId.ToString();
            if (HttpContext.Current.User != null)
                logEntry.UserName = HttpContext.Current.User.Identity.Name;
            else
                logEntry.UserName = "";

            return logEntry;
        }
Esempio n. 2
0
 private void AddEntryToLog(SiteLog logEntry)
 {
     MakeStringsLenSafe(logEntry);
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 3
0
        private void SimpleLogTest(SiteLog logEntry)
        {
            TestTraceMessage("MLW In Trace: Lengths are: Custom=" + logEntry.Custom.Length);
            TestTraceMessage("MLW In Trace: Custom string is " + logEntry.Custom);
            TestTraceCustom(logEntry.Custom.Substring(0, Math.Min(100, logEntry.Custom.Length - 1)));

            TestTraceLevel(logEntry.Level);
            TestTraceSessionID(logEntry.SessionId);
            TestTraceTimeStamp(logEntry.TimeStamp);
            TestTraceThreadID(logEntry.ThreadID);
            TestTraceUserName(logEntry.UserName);
        }
Esempio n. 4
0
 public void TestTraceUserName(string user)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.UserName = user;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 5
0
 private static void MakeStringsLenSafe(SiteLog logEntry)
 {
     logEntry.ExceptionMsg = logEntry.ExceptionMsg.Truncate(EXMSG_MAX_LEN);
     logEntry.ExceptionStack = logEntry.ExceptionStack.Truncate(EXSTACK_MAX_LEN);
     logEntry.ExceptionType = logEntry.ExceptionType.Truncate(EXTYPE_MAX_LEN);
     logEntry.Custom = logEntry.Custom.Truncate(CUSTOM_MAX_LEN);
     logEntry.Message = logEntry.Message.Truncate(MESSAGE_MAX_LEN);
     logEntry.SessionId = logEntry.SessionId.Truncate(SESSIONID_MAX_LEN);
     logEntry.UserName = logEntry.UserName.Truncate(USERNAME_MAX_LEN);
     logEntry.Level = logEntry.Level.Truncate(LEVEL_MAX_LEN);
     logEntry.ThreadID = logEntry.ThreadID.Truncate(THREADID_MAX_LEN);
 }
Esempio n. 6
0
 public void TestTraceThreadID(string threadID)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.ThreadID = threadID;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 7
0
 public void TestTraceTimeStamp(DateTime? timeStamp)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.TimeStamp = timeStamp;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 8
0
 public void TestTraceMessage(string message)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.Message = message;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 9
0
 public void TestTraceSessionID(string sessionID)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.SessionId = sessionID;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 10
0
 public void TestTraceLevel(string lvl)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.Level = lvl;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 11
0
 public void TestTraceExceptionType(string exType)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.ExceptionType = exType;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 12
0
 public void TestTraceExceptionStack(string exStack)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.ExceptionStack = exStack;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 13
0
 public void TestTraceExceptionMsg(string exMsg)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.ExceptionMsg = exMsg;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }
Esempio n. 14
0
 public void TestTraceCustom(string custom)
 {
     SiteLog logEntry = new SiteLog();
     logEntry.Custom = custom;
     _db.SiteLogs.Add(logEntry);
     _db.SaveChanges();
 }