Exemplo n.º 1
0
        protected virtual void Log(LogItem item)
        {
            if (!this.EnableLogging)
            {
                return;
            }

            try
            {
                string mainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

                string logpath;
                switch (item.Type)
                {
                case LogType.BuildItem:
                    logpath = mainFolder + "\\ItemBuildLog.csv";
                    break;

                case LogType.BuildShip:
                    logpath = mainFolder + "\\ShipBuildLog.csv";
                    break;

                case LogType.ShipDrop:
                    logpath = mainFolder + "\\DropLog.csv";
                    break;

                default:
                    return;
                }
                if (!File.Exists(logpath))
                {
                    using (var w = File.AppendText(logpath))
                    {
                        w.WriteLine(item.CsvTitle());
                    }
                }
                using (var w = File.AppendText(logpath))
                {
                    w.WriteLine(item.ToCsv());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }