BNS_ACT_Plugin.LogWriter.Initialize C# (CSharp) Метод

Initialize() публичный статический Метод

public static Initialize ( ) : void
Результат void
        public static void Initialize()
        {
            _stopThread = false;
            try
            {
                _thread = new Thread(new ThreadStart(Scan));

                string folderName = Path.Combine(Advanced_Combat_Tracker.ActGlobals.oFormActMain.AppDataFolder.FullName, @"BNSLogs\");

                if (!Directory.Exists(folderName))
                    Directory.CreateDirectory(folderName);

                _logFileName = Path.Combine(folderName, "combatlog_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log");

                File.AppendAllText(_logFileName, null);

                // update filename in ACT
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.LogFilePath = _logFileName;
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.OpenLog(false, false); // GetCurrentZone flag means it will scan for the zone regex in the log file.

                _thread.Start();
            }
            catch (Exception ex)
            {
                BNS_ACT_Plugin.LogParserMessage("Error [BNS_Log.Initialize] " + ex.ToString().Replace(Environment.NewLine, " "));
                _stopThread = true;
            }
        }

Usage Example

Пример #1
0
        public void InitPlugin(System.Windows.Forms.TabPage pluginScreenSpace, System.Windows.Forms.Label pluginStatusText)
        {
            // store a reference to plugin's status label
            lblStatus = pluginStatusText;

            try
            {
                // Configure ACT for updates, and check for update.
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.UpdateCheckClicked += new Advanced_Combat_Tracker.FormActMain.NullDelegate(UpdateCheckClicked);
                if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed())
                {
                    Thread updateThread = new Thread(new ThreadStart(UpdateCheckClicked));
                    updateThread.IsBackground = true;
                    updateThread.Start();
                }

                // Update the listing of columns inside ACT.
                UpdateACTTables();

                // Configure ACT Wrapper
                LogParse.Initialize(new ACTWrapper());

                pluginScreenSpace.Controls.Add(this); // Add this UserControl to the tab ACT provides
                this.Dock = DockStyle.Fill;           // Expand the UserControl to fill the tab's client space

                // character name cannot be parsed from logfile name
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.LogPathHasCharName = false;
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.LogFileFilter      = "*.log";

                // Default Timestamp length, but this can be overridden in parser code.
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.TimeStampLen = DateTime.Now.ToString("HH:mm:ss.fff").Length + 1;

                // Set Date time format parsing.
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.GetDateTimeFromLog = new Advanced_Combat_Tracker.FormActMain.DateTimeLogParser(LogParse.ParseLogDateTime);

                // Set primary parser delegate for processing data
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.BeforeLogLineRead += LogParse.BeforeLogLineRead;

                // Hard-code zone name
                Advanced_Combat_Tracker.ActGlobals.oFormActMain.ChangeZone("Blade and Soul");

                // Initialize logging thread
                LogWriter.Initialize();

                lblStatus.Text = "BnS Plugin Started.";
            }
            catch (Exception ex)
            {
                LogParserMessage("Exception during InitPlugin: " + ex.ToString().Replace(Environment.NewLine, " "));
                lblStatus.Text = "InitPlugin Error.";
            }
        }