示例#1
0
文件: Log.cs 项目: dzikun/WarEmu
 static public bool InitLog(LogInfo Info, string PrefileName)
 {
     LogConfig Config = new LogConfig(Info);
     Config.PreFileName = PrefileName;
     Log.Init(Config);
     return true;
 }
示例#2
0
文件: Log.cs 项目: dzikun/WarEmu
        static public void InitInstance(LogConfig Config)
        {
            try
            {
                if (Config == null)
                    Config = new LogConfig();

                string FileDir = Directory.GetCurrentDirectory() + Config.LogFolder;
                string BackDir = Directory.GetCurrentDirectory() + Config.LogFolder + "/Backup";

                try
                {
                    Directory.CreateDirectory(FileDir);
                    Directory.CreateDirectory(BackDir);
                }
                catch (Exception)
                {

                }

                FileDir += "/" + Config.PreFileName + Config.FileName;
                BackDir += "/" + Config.PreFileName + "." + DateTime.Now.Hour + "h." + DateTime.Now.Minute + "m." + DateTime.Now.Second + "s" + Config.FileName;

                if (DumpFile == null)
                {
                    DumpFile = new FileInfo(FileDir);
                    if (DumpFile.Exists)
                        DumpFile.MoveTo(BackDir);

                    DumpFile = new FileInfo(FileDir);

                    if (FSDump != null)
                        FSDump.Close();

                    FSDump = DumpFile.Create();
                }

                if (Config != null)
                    _config = Config;

            }
            catch (Exception)
            {
                Console.WriteLine("Log : Log file already in use.");

                if (Config != null)
                    Config.Info.Dump = false;
            }
        }
示例#3
0
文件: Log.cs 项目: dzikun/WarEmu
        static public bool InitLog(string LogConf, string PrefileName)
        {
            try
            {
                LogConfig Conf = new LogConfig(0);
                Conf.PreFileName = PrefileName;

                if (LogConf.Length > 0)
                    Conf.LoadInfoFromFile(LogConf);

                Log.Init(Conf);
            }
            catch (Exception e)
            {
                Log.Error("InitLog", "Error : " + e.ToString());
                return false;
            }

            Log.Notice("InitLog", "Logger initialized");
            return true;
        }
示例#4
0
        public static bool InitLog(string LogConf, string PrefileName)
        {
            try
            {
                LogConfig Conf = new LogConfig(0);
                Conf.PreFileName = PrefileName;

                if (LogConf.Length > 0)
                {
                    Conf.LoadInfoFromFile(LogConf);
                }

                Init(Conf);
            }
            catch (Exception e)
            {
                Error("InitLog", "Error : " + e);
                return(false);
            }

            Notice("InitLog", "Logger initialized");
            return(true);
        }
示例#5
0
        public static void InitInstance(LogConfig Config)
        {
            try
            {
                if (Config == null)
                {
                    Config = new LogConfig();
                }

                string FileDir = Directory.GetCurrentDirectory() + Config.LogFolder;
                string BackDir = Directory.GetCurrentDirectory() + Config.LogFolder + "/Backup";

                try
                {
                    Directory.CreateDirectory(FileDir);
                    Directory.CreateDirectory(BackDir);
                }
                catch (Exception)
                {
                }

                FileDir += "/" + Config.PreFileName + Config.FileName;
                BackDir += "/" + Config.PreFileName + "." + DateTime.UtcNow.Hour + "h." + DateTime.UtcNow.Minute + "m." + DateTime.UtcNow.Second + "s" + Config.FileName;

                if (DumpFile == null)
                {
                    DumpFile = new FileInfo(FileDir);
                    if (DumpFile.Exists)
                    {
                        DumpFile.MoveTo(BackDir);
                    }

                    DumpFile = new FileInfo(FileDir);

                    if (FSDump != null)
                    {
                        FSDump.Close();
                    }

                    FSDump = DumpFile.Create();
                }

                if (Config != null)
                {
                    _config = Config;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Log : Log file already in use.");

                if (Config != null)
                {
                    Config.Info.Dump = false;
                }
            }

            _thread = new Thread(threadStart);
            _thread.IsBackground = true; // Detach the thread so it won't block exit
            _thread.Priority     = ThreadPriority.BelowNormal;
            _thread.Start();
        }
示例#6
0
 public static void Init(LogConfig Config)
 {
     InitInstance(Config);
 }
示例#7
0
文件: Log.cs 项目: dsstest/RiftEMU
 public static void Init(LogConfig Config)
 {
     InitInstance(Config);
 }