Beispiel #1
0
        public static bool prepareStorage(string filename = "")
        {
            running = true;
            if (filename == "")
            {
                filename = "activity.dat";
                if (IxianHandler.isTestNet)
                {
                    filename = "testnet-activity.dat";
                }
            }
            ActivityStorage.filename = filename;
            if (!prepareStorageInternal())
            {
                running = false;
                return(false);
            }
            // Start thread
            TLC         = new ThreadLiveCheck();
            thread      = new Thread(new ThreadStart(threadLoop));
            thread.Name = "Activity_Storage_Thread";
            thread.Start();

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Initialize and start the logging thread.
        /// </summary>
        public static bool start(string path, int verbosity = 14)
        {
            if (running)
            {
                if (consoleOutput)
                {
                    Console.WriteLine("Logging already started.");
                }
                return(false);
            }
            try
            {
                Logging.verbosity = verbosity;

                // Obtain paths and cache them
                folderpath      = path;
                logfilepath     = Path.Combine(folderpath, logfilename);
                wildcard        = Path.GetFileNameWithoutExtension(logfilename) + "*" + Path.GetExtension(logfilename);
                logfilepathpart = Path.Combine(folderpath, Path.GetFileNameWithoutExtension(logfilename));

                // Roll the previous log
                roll(true);

                // Create the main log file
                byte[] logMessage = Encoding.UTF8.GetBytes("Ixian Log" + Environment.NewLine);
                logFileStream.Write(logMessage, 0, logMessage.Length);

                // Start thread
                TLC         = new ThreadLiveCheck();
                running     = true;
                thread      = new Thread(new ThreadStart(threadLoop));
                thread.Name = "Logging_Thread";
                thread.Start();
            }
            catch (Exception e)
            {
                // Ignore all exception and start anyway with console only logging.
                Console.WriteLine(String.Format("Unable to open log file. Error was: {0}. Logging to console only.", e.Message));
                return(false);
            }
            return(true);
        }