Beispiel #1
0
        /// <summary>
        /// Inserts a log item
        /// </summary>
        /// <param name="logLevel">Log level</param>
        /// <param name="shortMessage">The short message</param>
        /// <param name="fullMessage">The full message</param>
        /// <param name="user">The customer to associate log record with</param>
        /// <returns>A log item</returns>
        public virtual Log InsertLog(LogLevel logLevel, string shortMessage, string fullMessage = "", User user = null)
        {
            //check ignore word/phrase list?
            if (IgnoreLog(shortMessage) || IgnoreLog(fullMessage))
            {
                return(null);
            }

            var log = new Log
            {
                LogLevel     = logLevel,
                ShortMessage = shortMessage,
                FullMessage  = fullMessage,
                IpAddress    = _webHelper.GetCurrentIpAddress(),
                User         = user,
                PageUrl      = _webHelper.GetSiteUrl(true),
                ReferrerUrl  = _webHelper.GetUrlReferrer(),
                CreatedOnUtc = DateTime.UtcNow
            };

            _logRepository.Insert(log);

            return(log);
        }