예제 #1
0
        /// <summary>
        /// write a LogItem in logItems table
        /// </summary>
        /// <param name="module">current module</param>
        /// <param name="description">the event log description</param>
        /// <param name="type">the event log type. default TracerItemType.Info</param>
        public static void Write(PigeonCms.Module module, string description, TracerItemType type)
        {
            if (module.UseLog == Utility.TristateBool.True ||
                (module.UseLog == Utility.TristateBool.NotSet && LogProvider.AppUseLog))
            {
                var item = new LogItem();
                var man = new LogItemsManager();

                item.ModuleId = module.Id;
                item.Type = type;
                try
                {
                    //sometimes throw NullReferenceException
                    item.UserHostAddress = HttpContext.Current.Request.UserHostAddress;
                }
                catch { }
                try
                {
                    //sometimes throw NullReferenceException
                    item.SessionId = HttpContext.Current.Session.SessionID;
                }
                catch { }
                //item.Url = HttpContext.Current.Request.RawUrl;    //parte finale
                item.Url = Utility.Html.GetTextPreview(HttpContext.Current.Request.Url.AbsoluteUri, 495, ""); //all url
                item.Description = Utility.Html.GetTextPreview(description, 495, "");

                man.Insert(item);
            }
        }
예제 #2
0
        public static void Log(string message, TracerItemType type, params object[] arguments)
        {
            //#if TRACER
            DateTime now = DateTime.Now;
            List<TracerItem> items = GetLogs();
            int delta = items.Count == 0 ? 0 : (int)now.Subtract(items[items.Count - 1].Dated).TotalMilliseconds;
            int elasped = items.Count == 0 ? delta : items[items.Count - 1].Elapsed + delta;
            items.Add(new TracerItem(now, type, string.Format(message, arguments), elasped, delta));

            PigeonCms.Trace.Write("TRACER", message);
            //#endif
        }
예제 #3
0
 public TracerItem(DateTime dated, TracerItemType type, string message, int elapsed, int delta)
 {
     this.dated = dated;
     this.type = type;
     this.message = message;
     this.elapsed = elapsed;
     this.delta = delta;
 }