Exemplo n.º 1
0
        static void http_OnLogAccess(object sender, LogAccessEventArgs e)
        {
            LogAccess data = e.Data;

            Console.WriteLine(data.Date + "\t" + data.ClientIP + "\t" + data.Method + "\t" + data.RawUrl);
            Console.WriteLine(data.UserAgent);
            Console.WriteLine("------------------------------------------------------------");
        }
Exemplo n.º 2
0
        public LogModule() : base("Log")
        {
            Get["/"] = x => View["Grid"];

            Post["/PostQuery"] = r =>
            {
                QueryCondition condition = this.Bind <QueryCondition>();
                return(Response.AsJson(LogAccess.Query(condition)));
            };
        }
Exemplo n.º 3
0
 public void GetNullLoggerTest()
 {
    Logger first, second;
    first = LogAccess.GetNullLogger();
    second = LogAccess.GetNullLogger();
    Assert.IsNotNull(first);
    Assert.IsNotNull(second);
    Assert.AreEqual(first, second);
    TryLogger(first);
 }
Exemplo n.º 4
0
 public void GetLoggerTest()
 {
    string Category1 = "Some cat";
    string Category2 = "Another cat";
    Logger first, second, third, nullLog;
    first = LogAccess.GetLogger(Category1);
    second = LogAccess.GetLogger(Category2);
    third = LogAccess.GetLogger(Category1);
    nullLog = LogAccess.GetNullLogger();
    Assert.IsNotNull(first);
    Assert.IsNotNull(second);
    Assert.AreNotEqual(first, nullLog);
    Assert.AreNotEqual(second, nullLog);
    Assert.AreNotEqual(first, second);
    Assert.AreEqual(first, third);
    TryLogger(first);
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            LogAccess.GetLogger("main");

            int parse;

            if (args.Length >= 2)
            {
                if (int.TryParse(args[0], out parse))
                {
                    if (parse > 0)
                    {
                        threadCount = parse;
                    }
                }
                if (int.TryParse(args[1], out parse))
                {
                    if (parse > 0)
                    {
                        messageCount = parse;
                    }
                }
            }

            Console.WriteLine("Regular test");
            Console.WriteLine("Elapsed {0} miliseconds\n", runThreads(CountFlood));


            if (args.Length < 3)
            {
                Thread.Sleep(5000);

                //Console.WriteLine("ID test");
                //LogAccess.FilterAddID(3);
                //Console.WriteLine("Elapsed {0} miliseconds\n", runThreads(IdFlood));

                Console.WriteLine("Nlog test");
                Console.WriteLine("Elapsed {0} miliseconds\n", runThreads(NlogFlood));
                Console.ReadKey();
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            string pwd    = Directory.GetCurrentDirectory();
            string dbName = "LoggerTest";

            CreateSqlDatabase(pwd, dbName);
            string connectionString =
                string.Format(@"Data Source=(LocalDb)\v11.0;Initial Catalog={0};AttachDBFilename={1}\{2}.mdf"
                              , dbName, pwd, dbName);

            IOptions options = new Options(connectionString, dbName + ".dbo.LogOptions", OptionsReaderType.Database);

            options["LogWriteTarget"]      = "Database";
            options["LogConnectionString"] = connectionString;
            options["LogWriteTable"]       = dbName + ".dbo.LogOutput";
            options["LogDaysToKeep"]       = "1";
            LogAccess.Init(options);
            options.Save();

            var logger = LogAccess.GetLogger("alogger");

            for (int n = 0; n < 30; n++)
            {
                try
                {
                    Console.Write(submain(0));
                }
                catch (Exception ex)
                {
                    logger.Error("happy error", ex);
                }
            }
            for (int n = 0; n < 10000; n++)
            {
                logger.Info("info" + n, new int[] { n, 2, 3 });
            }
            Console.ReadKey();
        }
Exemplo n.º 7
0
 private void WriteLogFalse(string type, Exception e)
 {
     LogAccess.Write_Exp(type + e + GetLogContent());
 }
Exemplo n.º 8
0
 private void WriteLog(string type)
 {
     LogAccess.Write(type + GetLogContent());
 }
Exemplo n.º 9
0
 protected override void WriteDeleteProtectedLog(string type)
 {
     LogAccess.Write(type + GetLogContent() + '\t' + "该部门下还有员工");
 }
Exemplo n.º 10
0
 protected override void WriteDeleteProtectedLog(string type)
 {
     LogAccess.Write(type + GetLogContent() + '\t' + "该员工存该月存在打卡记录,不能删除");
 }
Exemplo n.º 11
0
 public static int Delete(DateTime keepDate)
 {
     return(LogAccess.Delete(keepDate));
 }
Exemplo n.º 12
0
 public static Page <Sys_Log> GetList(long pageIndex, long pageSize, DateTime limitDate, string keyWord, string level)
 {
     return(LogAccess.GetList(pageIndex, pageSize, limitDate, keyWord, level));
 }
Exemplo n.º 13
0
 protected override void WriteDeleteProtectedLog(string type)
 {
     LogAccess.Write("该宿舍还有成员");
 }
Exemplo n.º 14
0
 protected override void WriteDeleteProtectedLog(string type)
 {
     LogAccess.Write("该岗位还有员工,无法删除");
 }
Exemplo n.º 15
0
        /// <summary>
        /// Insert New Access
        /// </summary>
        /// <param name="userAdmin"></param>
        /// <param name="userIp"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public Message InsertNewAccess(string stSession, string userAdmin, string userIp)
        {
            Message msg = null;
            try
            {
                LogAccess myLog = new LogAccess();
                myLog.Id = Guid.NewGuid();
                myLog.SessionId = stSession;
                myLog.UserIp = userIp;
                myLog.UserAdmin = userAdmin;
                myLog.DatetimeAccess = DateTime.Now;
                dbContext.LogAccesses.InsertOnSubmit(myLog);
                dbContext.SubmitChanges();

                // success message
                msg = new Message(MessageConstants.I0001, MessageType.Info, "Log access", "added");
            }
            catch
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }