コード例 #1
0
ファイル: Log.cs プロジェクト: dsstest/SiennaCore
        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);
        }
コード例 #2
0
ファイル: Log.cs プロジェクト: Easun/ChameleonProject
        public static bool InitLog(string LogConf, string LogsDir, string fileName)
        {
            try
            {
                LogConfig Conf = new LogConfig(0);
                Conf.FileName = fileName;
                Conf.LogFolder = LogsDir;

                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;
        }
コード例 #3
0
ファイル: Log.cs プロジェクト: Easun/ChameleonProject
        public static void InitInstance(LogConfig Config)
        {
            try
            {
                if (Config == null)
                    Config = new LogConfig();

                if (!Config.LogFolder.StartsWith("/"))
                    Config.LogFolder = "/" + Config.LogFolder;

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

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

                }

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

                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)
            {
                lock (Console.Out)
                    Console.WriteLine("Log : Log file already in use.");

                if (Config != null)
                    Config.Info.Dump = false;
            }
        }
コード例 #4
0
ファイル: Log.cs プロジェクト: Easun/ChameleonProject
 public static void Init(LogConfig Config)
 {
     InitInstance(Config);
 }
コード例 #5
0
 static public void Init(LogConfig Config)
 {
     InitInstance(Config);
 }
コード例 #6
0
        static public void InitInstance(LogConfig Config)
        {
            try
            {
                if (Config == null)
                {
                    Config = new LogConfig();
                }

                if (!Config.LogFolder.StartsWith("/"))
                {
                    Config.LogFolder = "/" + Config.LogFolder;
                }

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

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

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

                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)
            {
                lock (Console.Out)
                    Console.WriteLine("Log : Log file already in use.");

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