Blaze.Server.Log.WriteAway C# (CSharp) Method

WriteAway() public static method

public static WriteAway ( ) : void
return void
        public static void WriteAway()
        {
            String stringToWrite = _writeString.ToString();
            _writeString.Length = 0;

            StreamWriter _logWriter = new StreamWriter(_fileName, true);

            _logWriter.Write(stringToWrite);
            _logWriter.Flush();
            _logWriter.Close();
        }

Usage Example

Example #1
0
        static void Main(string[] args)
        {
            Log.Initialize("Blaze.Server.log");
            Log.Info("Starting Blaze.Server...");

            Time.Initialize();

            try
            {
                Configuration.Load("Blaze.Server.yml");

                if (Configuration.Users == null)
                {
                    Log.Error("Users configuration was not found.");
                    return;
                }
            }
            catch (IOException)
            {
                Log.Error(string.Format("Could not open the configuration file {0}.", "Blaze.Server.yml"));
                return;
            }

            BlazeHubServer.Start();
            BlazeServer.Start();

            while (true)
            {
                try
                {
                    Log.WriteAway();
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }

                Thread.Sleep(1000);
            }
        }