public override void OnDisabled()
        {
            base.OnDisabled();

            UnregisterEvents();

            Log.Debug("Unpatching...");
            _instance.UnpatchAll();
            Log.Debug("Unpatching complete. Goodbye.");
        }
示例#2
0
 static void Main(string[] args)
 {
     _log.Debug("Debug message");
     _log.Info("Info message");
     _log.Warn("Warn message");
     _log.Error("Error message");
     _log.Flush();
     Console.WriteLine("Done");
 }
        private void ExecuteAlertMethod(object source, ElapsedEventArgs e)
        {
            try
            {
                _log.Debug("Alert Process started");

                // after initial execution, set timer to its repeating state
                alertTimer.Interval = _alertMinutes * 60 * 1000;

                PrintAvailable();
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
            finally
            {
            }
        }
示例#4
0
        private static void MainMenu()
        {
            OutMainMenu();
            string action = Console.ReadLine();

            logger.Debug(action + " selected by user");
            switch (action)
            {
            case "1": CreateBookService();
                break;

            case "2": service = new BookListService(logger);
                service.OpenFrom(storage);
                break;

            case "3": Console.WriteLine(service.PrintBooks());
                break;

            case "4": BooksMenu(AddBook);
                break;

            case "5": BooksMenu(RemoveBook);
                break;

            case "6": SortTagsMenu();
                break;

            case "7": FindTagsMenu();
                break;

            case "8": service.SaveTo(storage);
                break;

            case "0": Environment.Exit(0);
                break;

            default: Console.WriteLine("Invalid command");
                break;
            }
        }
        public override void OnEnabled()
        {
            base.OnEnabled();

            foreach (KeyValuePair <string, Language> defaultLanguage in Translation.Translation.DefaultLanguages)
            {
                this.RegisterTranslation(defaultLanguage.Value, defaultLanguage.Key);
            }

            Language t = this.LoadTranslation <Language>();

            Exiled.API.Features.Log.Debug(t.ContainDenied);
            Exiled.API.Features.Log.Debug(t.NotImplementedYet);
            Exiled.API.Features.Log.Debug(t.IntercomDenied);

            //Exiled.Events.Events.DisabledPatches.Add(new Tuple<Type, string>(typeof(RespawnManager), nameof(RespawnManager.Spawn)));
            //Exiled.Events.Events.Instance.ReloadDisabledPatches();

            try
            {
                Log = new Logger.Logger("GhostSpectator", Loader.ShouldDebugBeShown);

                Log.Info($"Attempting to set language to {Config.Lang}.");

                Translation.Translation.LoadTranslations();

                CultureInfo ci;

                try
                {
                    ci = CultureInfo.GetCultureInfo(Config.Lang);
                }
                catch (Exception e)
                {
                    ci = CultureInfo.GetCultureInfo("en");
                    Log.Error($"{Config.Lang} is not a valid language. Defaulting to English.");
                    Log.Error($"{e.Message}");
                }

                CultureInfo.DefaultThreadCurrentCulture   = ci;
                CultureInfo.DefaultThreadCurrentUICulture = ci;
                Log.Info($"Language set to {ci.DisplayName}.");
                Log.Debug($"Language test {Translation.Translation.GetText().DoorDenied}.");

                RegisterEvents();

                Log.Debug("Patching...");
                try
                {
                    //You must use an incrementer for the harmony instance name, otherwise the new instance will fail to be created if the plugin is reloaded.
                    _patchFixer++;
                    _instance = new Harmony($"ghostspectator.patches{_patchFixer}");
                    _instance.PatchAll();
                }
                catch (Exception exception)
                {
                    Log.Error($"Patching failed! {exception}");
                }

                //Timing.RunCoroutine(EventHandlers.SlowUpdate());

                Log.Info($"{Name} loaded. c:");
            }
            catch (Exception e)
            {
                Log.Error($"There was an error loading the plugin: {e}");
            }
        }