Exemple #1
0
        private void ShowLogOnTxtBox(string str)
        {
            LogEntity entity = new LogEntity();

            entity.LogMsg = str;
            txtLogMsg.AppendText(entity.ToString() + "\r\n");
        }
        public void SimpleTest()
        {
            LogEntityFactory logEntityFactory = new LogEntityFactory();
            LogEntity        logEntity        = logEntityFactory.GetRandomLogEntity();
            ILogParser       logParser        = new CommonLogParser();
            DateTime         now = DateTime.UtcNow;

            try
            {
                var response = logParser.Parse(logEntity.ToString(), now);

                Assert.AreEqual(logEntity.IpAddress, response.IpAddress, "ip address");
                Assert.AreEqual(logEntity.UserId, response.UserId, "user id");
                Assert.AreEqual(logEntity.ClientIdentity, response.ClientIdentity, "client identity");
                Assert.AreEqual(logEntity.Time.ToShortTimeString(), response.Time.ToShortTimeString(), "time");
                Assert.AreEqual(logEntity.HttpMethod, response.HttpMethod, "http method");
                Assert.AreEqual(logEntity.HttpPath, response.HttpPath, "http path");
                Assert.AreEqual(logEntity.HttpVersion, response.HttpVersion, "http version");
                Assert.AreEqual(logEntity.StatusCode, response.StatusCode, "status code");
                Assert.AreEqual(logEntity.ResponseSize, response.ResponseSize, "size");
                Assert.AreEqual(now, response.TimeReadFromFile, "read from file");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Exemple #3
0
        private static string JobLogException(ExceptionContext context, LogLevel logLevel, string type, string callerMemberName, string callerFilePath, int callerLineNumber)
        {
            var logEntity = new LogEntity(context, logLevel, null, type);

            UpdateLogInfo(context, logEntity, callerMemberName, callerFilePath, callerLineNumber);
            BackgroundJob.Enqueue(() => Write(logLevel, logEntity.ToString()));
            return(logEntity.Id);
        }
Exemple #4
0
        private static string JobLogMessage(string message, LogLevel level, string type, string callerMemberName, string callerFilePath, int callerLineNumber)
        {
            var logEntity = new LogEntity(message, level, type);

            UpdateLogInfo(logEntity, callerMemberName, callerFilePath, callerLineNumber);
            BackgroundJob.Enqueue(() => Write(level, logEntity.ToString()));
            return(logEntity.Id);
        }