示例#1
0
        public static async void RunLogThread()
        {
            while (ServerContext.ServerRunning)
            {
                //Run the log expire function every 10 minutes
                if (ServerContext.ServerClock.ElapsedMilliseconds - _lastLogExpiredCheck > 600000)
                {
                    _lastLogExpiredCheck = ServerContext.ServerClock.ElapsedMilliseconds;
                    LogExpire.ExpireLogs();
                }

                // Check if the day has changed, every minute
                if (ServerContext.ServerClock.ElapsedMilliseconds - _lastDayCheck > 60000)
                {
                    _lastDayCheck = ServerContext.ServerClock.ElapsedMilliseconds;
                    if (ServerContext.Day != LunaTime.Now.Day)
                    {
                        LunaLog.LogFilename = Path.Combine(LunaLog.LogFolder, $"lmpserver {LunaTime.Now:yyyy-MM-dd HH-mm-ss}.log");
                        LunaLog.WriteToLog($"Continued from logfile {LunaTime.Now:yyyy-MM-dd HH-mm-ss}.log");
                        ServerContext.Day = LunaTime.Now.Day;
                    }
                }

                await Task.Delay(250);
            }
        }
示例#2
0
        public static async void RunLogThread()
        {
            if (LogSettings.SettingsStore.ExpireLogs > 0 && LogSettings.SettingsStore.EnableLogging)
            {
                //Set day for log change
                ServerContext.Day = (byte)LunaNetworkTime.Now.Day;

                while (ServerContext.ServerRunning)
                {
                    //Run the log expire function every 10 minutes
                    if (ServerContext.ServerClock.ElapsedMilliseconds - _lastLogExpiredCheck > 600000)
                    {
                        _lastLogExpiredCheck = ServerContext.ServerClock.ElapsedMilliseconds;
                        LogExpire.ExpireLogs();
                    }

                    // Check if the day has changed, every minute
                    if (ServerContext.ServerClock.ElapsedMilliseconds - _lastDayCheck > 60000)
                    {
                        _lastDayCheck = ServerContext.ServerClock.ElapsedMilliseconds;
                        if (ServerContext.Day != LunaNetworkTime.Now.Day)
                        {
                            LunaLog.LogFilename = Path.Combine(LunaLog.LogFolder, $"lmpserver {LunaNetworkTime.Now:yyyy-MM-dd HH-mm-ss}.log");
                            LunaLog.Info($"Continued from logfile {LunaNetworkTime.Now:yyyy-MM-dd HH-mm-ss}.log");
                            ServerContext.Day = (byte)LunaNetworkTime.Now.Day;
                        }
                    }

                    await Task.Delay(250);
                }
            }
        }