Ejemplo n.º 1
0
        public static Config GetDefaultConfig()
        {
            var c1 = new Connection()
            {
                ConnectionAddress = "us-east.stratum.grinmint.com", ConnectionPort = 13416, Login = "******", Password = "******", Ssl = false
            };
            var c2 = new Connection()
            {
                ConnectionAddress = "backup_pooladdress", ConnectionPort = 13416, Login = "******", Password = "******", Ssl = false
            };
            var logOptions = new LogOptions()
            {
                ConsoleMinimumLogLevel = LogLevel.INFO, FileMinimumLogLevel = LogLevel.WARNING, KeepDays = 1, DisableLogging = false
            };
            List <GPUOption> gpuOptions = new List <GPUOption>()
            {
                new GPUOption()
                {
                    DeviceID = 0, Enabled = true, GPUType = WorkerType.NVIDIA, PlatformID = 0
                }
            };

            return(new Config()
            {
                PrimaryConnection = c1,
                SecondaryConnection = c2,
                ReconnectToPrimary = 0,
                CPUOffloadValue = 0,
                GPUOptions = gpuOptions,
                LogOptions = logOptions
            });
        }
Ejemplo n.º 2
0
        public static void Log(LogLevel level, string msg)
        {
            try
            {
                if (logOptions == null)
                {
#if DEBUG
                    logOptions = new LogOptions()
                    {
                        FileMinimumLogLevel = LogLevel.DEBUG, ConsoleMinimumLogLevel = LogLevel.DEBUG, KeepDays = 1, DisableLogging = false
                    };
#else
                    logOptions = new LogOptions()
                    {
                        FileMinimumLogLevel = LogLevel.ERROR, ConsoleMinimumLogLevel = LogLevel.INFO, KeepDays = 1, DisableLogging = false
                    };
#endif
                }

                if (level == LogLevel.ERROR && criticalErrors.Count < 1000)
                {
                    criticalErrors.Enqueue(msg);
                }

                if (level >= logOptions.FileMinimumLogLevel && !logOptions.DisableLogging)
                {
                    lock (lock1)
                    {
                        //prevent overloading log
                        if (level != LogLevel.ERROR || (level == LogLevel.ERROR && OverloadCheck(msg)))
                        {
                            File.AppendAllText(LogPath, $"{DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssK")}    {level.ToString()},     {msg}{Environment.NewLine}");
                        }
                    }
                }

                if (level >= logOptions.ConsoleMinimumLogLevel)
                {
                    msg = msg.Trim();
                    pushMessage($"{level.ToString(),-8}{msg}");

                    if (consoleMode == ConsoleOutputMode.ROLLING_LOG)
                    {
                        if ((level == LogLevel.ERROR) || (level == LogLevel.WARNING))
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                        }

                        Console.WriteLine($"{level.ToString(),-8}{msg}");
                        Console.ResetColor();
                    }
                }
            }
            catch { } //epic fail
        }
Ejemplo n.º 3
0
 public static void SetLogOptions(LogOptions options)
 {
     logOptions = options;
 }