InitCoreLoggers() static private method

static private InitCoreLoggers ( ) : void
return void
Example #1
0
        private static void InitCore(IReadOnlyCollection <string> args)
        {
            Directory.SetCurrentDirectory(SharedInfo.HomeDirectory);

            // Allow loading configs from source tree if it's a debug build
            if (Debugging.IsDebugBuild)
            {
                // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
                for (byte i = 0; i < 4; i++)
                {
                    Directory.SetCurrentDirectory("..");

                    if (Directory.Exists(SharedInfo.ConfigDirectory))
                    {
                        break;
                    }
                }

                // If config directory doesn't exist after our adjustment, abort all of that
                if (!Directory.Exists(SharedInfo.ConfigDirectory))
                {
                    Directory.SetCurrentDirectory(SharedInfo.HomeDirectory);
                }
            }

            // Parse pre-init args
            if (args != null)
            {
                ParsePreInitArgs(args);
            }

            Logging.InitCoreLoggers();
        }
Example #2
0
        private static async Task <bool> InitCore(IReadOnlyCollection <string> args)
        {
            Directory.SetCurrentDirectory(SharedInfo.HomeDirectory);

            // Allow loading configs from source tree if it's a debug build
            if (Debugging.IsDebugBuild)
            {
                // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
                for (byte i = 0; i < 4; i++)
                {
                    Directory.SetCurrentDirectory("..");

                    if (Directory.Exists(SharedInfo.ConfigDirectory))
                    {
                        break;
                    }
                }

                // If config directory doesn't exist after our adjustment, abort all of that
                if (!Directory.Exists(SharedInfo.ConfigDirectory))
                {
                    Directory.SetCurrentDirectory(SharedInfo.HomeDirectory);
                }
            }

            // Parse pre-init args
            if (args != null)
            {
                ParsePreInitArgs(args);
            }

            bool uniqueInstance = OS.RegisterProcess();

            Logging.InitCoreLoggers(uniqueInstance);

            if (!uniqueInstance)
            {
                ASF.ArchiLogger.LogGenericError(Strings.ErrorSingleInstanceRequired);
                await Task.Delay(5000).ConfigureAwait(false);

                return(false);
            }

            return(true);
        }
Example #3
0
        private static void Init()
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            TaskScheduler.UnobservedTaskException      += UnobservedTaskExceptionHandler;

            Logging.InitCoreLoggers();

            if (!Runtime.IsRuntimeSupported)
            {
                ArchiLogger.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!");
            }

            string homeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            if (!string.IsNullOrEmpty(homeDirectory))
            {
                Directory.SetCurrentDirectory(homeDirectory);

                // Allow loading configs from source tree if it's a debug build
                if (Debugging.IsDebugBuild)
                {
                    // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
                    for (byte i = 0; i < 4; i++)
                    {
                        Directory.SetCurrentDirectory("..");
                        if (!Directory.Exists(SharedInfo.ASFDirectory))
                        {
                            continue;
                        }

                        Directory.SetCurrentDirectory(SharedInfo.ASFDirectory);
                        break;
                    }

                    // If config directory doesn't exist after our adjustment, abort all of that
                    if (!Directory.Exists(SharedInfo.ConfigDirectory))
                    {
                        Directory.SetCurrentDirectory(homeDirectory);
                    }
                }
            }

            InitServices();

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                if (Directory.Exists(SharedInfo.DebugDirectory))
                {
                    Directory.Delete(SharedInfo.DebugDirectory, true);
                    Thread.Sleep(1000);                     // Dirty workaround giving Windows some time to sync
                }

                Directory.CreateDirectory(SharedInfo.DebugDirectory);

                DebugLog.AddListener(new Debugging.DebugListener());
                DebugLog.Enabled = true;
            }

            Logging.InitEnhancedLoggers();
        }