Exemplo n.º 1
0
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            bool savedFirstStart = AppSettings.FirstStart;

            if (savedFirstStart)
            {
                AppSettings.Upgrade();
// ReSharper disable ConditionIsAlwaysTrueOrFalse
                AppSettings.FirstStart = savedFirstStart;
// ReSharper restore ConditionIsAlwaysTrueOrFalse
            }

            ReconfigureLogger();
            ReconfigureLanguage(AppSettings.UseLanguage);

            Log.InfoFormat("Use Language: {0:s}", AppSettings.UseLanguage);
            Log.InfoFormat("VideoConvert v{0:s} started", AppSettings.GetAppVersion().ToString(4));
            Log.InfoFormat("OS-Version: {0:s}", Environment.OSVersion.VersionString);
            Log.InfoFormat("CPU-Count: {0:g}", Environment.ProcessorCount);
            Log.InfoFormat(".NET Version: {0:s}", Environment.Version.ToString(4));
            Log.InfoFormat("System Uptime: {0:s}", TimeSpan.FromMilliseconds(Environment.TickCount).ToString("c"));

            bool elevated = false;

            try
            {
                elevated = Processing.IsProcessElevated();
            }
            catch (Exception)
            {
                Log.Error("Could not determine process elevation status");
            }

            if (Environment.OSVersion.Version.Major >= 6)
            {
                Log.InfoFormat("Process Elevated: {0:s}", elevated.ToString(Cinfo));
            }

            Extensions supExt = new Extensions();

            CpuExtensions.GetExtensions(out supExt);
            InspectCpuExtensions(supExt);

            ReconfigureRenderMode();
        }
Exemplo n.º 2
0
        internal void ReconfigureLogger()
        {
            var logFile = Path.Combine(_configService.AppSettingsPath, "ErrorLog_");

            if (Log.Logger.Repository.Configured)
            {
                Log.Logger.Repository.Shutdown();
                Log.Logger.Repository.ResetConfiguration();
            }

            if (_clearLog)
            {
                try
                {
                    File.Delete(logFile);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                _clearLog = false;
            }

            var layout = new XmlLayoutSchemaLog4j(true);

            var filter = new LevelRangeFilter
            {
                LevelMin      = _configService.UseDebug ? Level.All : Level.Warn,
                AcceptOnMatch = true
            };

            layout.ActivateOptions();

            var fileAppender = new RollingFileAppender
            {
                PreserveLogFileNameExtension = true,
                StaticLogFileName            = false,
                DatePattern        = "yyyyMMdd'.xml'",
                RollingStyle       = RollingFileAppender.RollingMode.Date,
                ImmediateFlush     = true,
                File               = logFile,
                Encoding           = new UTF8Encoding(true),
                Layout             = layout,
                MaxSizeRollBackups = 60
            };

            fileAppender.AddFilter(filter);
            fileAppender.ActivateOptions();

            BasicConfigurator.Configure(fileAppender);

            Log.Info($"Use Language: {_configService.UseLanguage}");
            Log.Info($"VideoConvert v{AppConfigService.GetAppVersion().ToString(4)} started");
            Log.Info($"OS-Version: {Environment.OSVersion.VersionString}");
            Log.Info($"CPU-Count: {Environment.ProcessorCount:0}");
            Log.Info($".NET Version: {Environment.Version.ToString(4)}");
            Log.Info($"System Uptime: {TimeSpan.FromMilliseconds(Environment.TickCount).ToString("c")}");

            var elevated = false;

            try
            {
                elevated = _processingService.IsProcessElevated();
            }
            catch (Exception)
            {
                Log.Error("Could not determine process elevation status");
            }

            if (Environment.OSVersion.Version.Major >= 6)
            {
                Log.Info($"Process Elevated: {elevated}");
            }

            Extensions supExt;

            CpuExtensions.GetExtensions(out supExt);
            InspectCpuExtensions(supExt);

            if (_configService.UseDebug)
            {
                Log.Info("Debug information enabled");
            }
        }