Fail() private method

private Fail ( string message ) : void
message string
return void
Exemplo n.º 1
0
        public static void FailRelease(string format, params object[] args)
        {
            string message = String.Format(format, args);

            MyLog.Default.WriteLine("Assert Fail: " + message);
            SystemTrace.Fail(message);
        }
Exemplo n.º 2
0
        public void Init(string logFileName, StringBuilder appVersionString)
        {
            lock (m_lock)
            {
                try
                {
                    m_filepath        = Path.IsPathRooted(logFileName) ? logFileName : Path.Combine(MyFileSystem.UserDataPath, logFileName);
                    m_stream          = MyFileSystem.OpenWrite(m_filepath);
                    m_streamWriter    = new StreamWriter(m_stream);
                    m_normalWriter    = new Action <string>(WriteLine);
                    m_closedLogWriter = new Action <string>((s) => File.AppendAllText(m_filepath, s + Environment.NewLine));
                    m_enabled         = true;
                }
                catch (Exception e)
                {
                    SystemTrace.Fail("Cannot create log file: " + e.ToString());
                }

                m_indentsByThread = new Dictionary <int, int>();
                m_indents         = new Dictionary <MyLogIndentKey, MyLogIndentValue>();

                int timezone = (int)Math.Round((DateTime.Now - DateTime.UtcNow).TotalHours);

                WriteLine("Log Started");
                WriteLine(String.Format("Timezone (local - UTC): {0}h", timezone));
                WriteLine("App Version: " + appVersionString);
            }
        }
Exemplo n.º 3
0
        public void Log(MyLogSeverity severity, StringBuilder builder)
        {
            if (m_enabled)
            {
                lock (m_lock)
                {
                    if (m_enabled)
                    {
                        WriteDateTimeAndThreadId();

                        StringBuilder sb = m_stringBuilder;
                        sb.Clear();

                        sb.AppendFormat("{0}: ", severity);
                        sb.AppendStringBuilder(builder);
                        sb.Append('\n');

                        WriteStringBuilder(sb);

                        if ((int)severity >= (int)AssertLevel)
                        {
                            SystemTrace.Fail(sb.ToString());
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// This "assert" is executed in DEBUG and RELEASE modes. Use it in code that that won't suffer from more work (e.g. loading), not in frequently used loops
 /// </summary>
 /// <param name="condition"></param>
 public static void AssertRelease(bool condition, string assertMessage)
 {
     if (condition == false)
     {
         MyLog.Default.WriteLine("Assert: " + assertMessage);
         SystemTrace.Fail(assertMessage);
     }
 }
Exemplo n.º 5
0
        public void Log(MyLogSeverity severity, StringBuilder builder)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}: ", severity);
            sb.AppendStringBuilder(builder);
            sb.Append('\n');

            WriteStringBuilder(sb);

            if ((int)severity >= (int)AssertLevel)
            {
                SystemTrace.Fail(sb.ToString());
            }
        }
Exemplo n.º 6
0
        public void Log(MyLogSeverity severity, string format, params object[] args)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}: ", severity);
            sb.AppendFormat(format, args);
            sb.Append('\n');

            WriteStringBuilder(sb);

            if ((int)severity >= (int)AssertLevel)
            {
                SystemTrace.Fail(sb.ToString());
            }
        }
Exemplo n.º 7
0
        private static void LoadPlugins(Assembly assembly)
        {
            var pluginInterfaceClasses = assembly.GetTypes().Where(s => s.GetInterfaces().Contains(typeof(IPlugin)));

            foreach (var pluginClass in pluginInterfaceClasses)
            {
                try
                {
                    // Log may not be available yet (DS?)
                    //MyLog.Default.WriteLine("Creating instance of: " + pluginClass.FullName);
                    m_plugins.Add((IPlugin)Activator.CreateInstance(pluginClass));
                }
                catch (Exception e)
                {
                    // Log may not be available yet (DS?)
                    SystemTrace.Fail("Cannot create instance of '" + pluginClass.FullName + "': " + e.ToString());
                    //MyLog.Default.WriteLine("Error instantiating plugin class: " + pluginClass);
                    //MyLog.Default.WriteLine(e);
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Logs the message on release and also displays a message on DEBUG.
 /// </summary>
 /// <param name="message"></param>
 public static void FailRelease(string message)
 {
     MyLog.Default.WriteLine("Assert Fail: " + message);
     SystemTrace.Fail(message);
 }