using Ninject;
using Serilog;
using VisionBuilder.UI.Common;
using VisionBuilder.UI.Common.Attributes;

namespace VisionBuilder.UI.Console
{
    [ModulePriority(100000)]
    public class VisionBuilderConsole: IVisionBuilderModule
    {
        private readonly VisionBuilderConsoleSettings _settings;

        public VisionBuilderConsole(VisionBuilderConsoleSettings settings)
        {
            _settings = settings;
        }

        public void InitializeModule()
        {
            if (_settings.CreateConsoleWindow)
            {
                WinConsole.Initialize();
            }
            // configure Serilog to use console
            if (_settings.UseConsole)
            {
                Serilog.Log.Logger = new Serilog.LoggerConfiguration()
                    .MinimumLevel.Debug()
                    .WriteTo.Console()
                    .CreateLogger();

                Log.Information("Console initialized");
            }

            
        }
    }
}
