Beispiel #1
0
        private string FormatLine(string line, CLogLevel level, CTag tag, string stackTrace)
        {
            StringBuilder lineBuffer = new StringBuilder();

            string coloredLine = CEditorSkin.SetColors(line);

            string filename = CEditorStackTrace.ExtractFileName(stackTrace);

            if (level != null)
            {
                lineBuffer.Append("[");
                lineBuffer.Append(level.ShortName);
                lineBuffer.Append("]: ");
            }

            if (filename != null)
            {
                lineBuffer.Append(CStringUtils.C("[" + filename + "]: ", CEditorSkin.GetColor(CColorCode.Plain)));
            }

            if (tag != null)
            {
                lineBuffer.Append("[");
                lineBuffer.Append(tag.Name);
                lineBuffer.Append("]: ");
            }

            lineBuffer.Append(coloredLine);

            return(lineBuffer.ToString());
        }
Beispiel #2
0
        public void Add(CLogLevel level, CTag tag, string line)
        {
            CConsoleViewCellEntry entry = new CConsoleViewCellEntry(line);

            entry.level = level;
            entry.tag   = tag;
            Add(entry);
        }
Beispiel #3
0
 private string[] FormatTable(string[] table, CLogLevel level, CTag tag, string stackTrace)
 {
     for (int i = 0; i < table.Length; ++i)
     {
         table[i] = CEditorSkin.SetColors(table[i]);
     }
     return(table);
 }
Beispiel #4
0
        public virtual void Add(CLogLevel level, CTag tag, string[] table, string stackTrace)
        {
            CConsoleViewCellEntry entry = new CConsoleViewCellEntry(table);

            entry.level      = level;
            entry.tag        = tag;
            entry.stackTrace = stackTrace;
            Add(entry);
        }
        public CConsoleViewCellEntry(string line, float width = 0, float height = 0)
        {
            this.value  = line;
            this.width  = width;
            this.height = height;
            this.flags  = Flags.Plain;

            this.data       = null;
            this.tag        = null;
            this.level      = null;
            this.stackTrace = null;
        }
        public CConsoleViewCellEntry(Exception e, string message, float width = 0, float height = 0)
        {
            this.value = message != null?CStringUtils.TryFormat("{0} ({1})", message, e.Message) : e.Message;

            this.width  = width;
            this.height = height;
            this.flags  = Flags.Plain;

            this.data       = null;
            this.tag        = null;
            this.level      = CLogLevel.Exception;
            this.stackTrace = e.StackTrace;
        }
Beispiel #7
0
        bool Execute(string[] args)
        {
            if (level != null)
            {
                CLogLevel logLevel = FromString(level);
                if (logLevel == null)
                {
                    PrintError("Unexpected log level: '{0}'", level);
                    PrintUsage();
                    return(false);
                }

                CLog.Level = logLevel;

                PrintLogLevel();
                return(true);
            }

            // TODO: add actions
            if (args.Length == 1)
            {
                string arg = args[0];
                if (arg == "enable" || arg == "on" || arg == "1")
                {
                    if (m_lastLogLevel != null)
                    {
                        CLog.Level = m_lastLogLevel;
                    }

                    PrintLogLevel();
                    return(true);
                }
                if (arg == "disable" || arg == "off" || arg == "0")
                {
                    m_lastLogLevel = CLog.Level;
                    CLog.Level     = null;

                    PrintLogLevel();
                    return(true);
                }
            }

            PrintLogLevel();
            return(true);
        }
Beispiel #8
0
        private static void LogToFile(string msg, CLogLevel level)
        {
            string typeText;

            switch (level)
            {
            case CLogLevel.Warning:
                typeText = "WARNING: ";
                break;

            case CLogLevel.Error:
                typeText = "ERROR: ";
                break;

            default:
                typeText = "INFO: ";
                break;
            }

            File.AppendAllText(inst.logFilePath, typeText + msg);
        }
        public CConsoleViewCellEntry(string[] lines, float width = 0, float height = 0)
        {
            if (lines.Length == 1)
            {
                this.value = lines[0];
                this.data  = null;
                this.flags = Flags.Plain;
            }
            else
            {
                this.data  = lines;
                this.value = null;
                this.flags = Flags.Table;
            }
            this.width  = width;
            this.height = height;

            this.tag        = null;
            this.level      = null;
            this.stackTrace = null;
        }
        public bool SetFilterLogLevel(CLogLevel level)
        {
            if (level != null && level != CLogLevel.Verbose) // no need to filter on verbose
            {
                if (m_levelFilter == null)
                {
                    m_levelFilter = new CConsoleViewLogLevelFilter(level);
                    bool shouldAppend = this.HasFilters; // not the first filter

                    AddFilter(m_levelFilter);

                    return(shouldAppend ? AppendFilter(m_levelFilter) : ApplyFilter(m_levelFilter));
                }

                CLogLevel oldLevel = m_levelFilter.Level;
                m_levelFilter.Level = level;

                if (oldLevel.Priority < level.Priority) // can only decrease filtered items count: e.g. 'debug' -> 'error'
                {
                    return(AppendFilter(m_levelFilter));
                }

                if (oldLevel.Priority > level.Priority) // can increase filtered items count: e.g. 'error' -> 'debug'
                {
                    return(ApplyFilter(this));
                }
            }
            else if (m_levelFilter != null) // remove existing filter
            {
                RemoveFilter(m_levelFilter);
                m_levelFilter = null;

                return(ApplyFilter(this));
            }

            return(false);
        }
Beispiel #11
0
        private static void _log(string msg, CLogLevel level)
        {
            if (Application.isEditor)
            {
                switch (level)
                {
                case CLogLevel.Warning:
                    Debug.LogWarning(msg);
                    break;

                case CLogLevel.Error:
                    Debug.LogError(msg);
                    break;

                default:
                    Debug.Log(msg);
                    break;
                }
            }
            else
            {
                LogToFile(msg, level);
            }
        }
Beispiel #12
0
    private static void DoLog(string szMsg, CLogLevel emLevel)
    {
        if (LogLevel > emLevel)
        {
            return;
        }
        szMsg = string.Format("[{0}]{1}\n\n=================================================================\n\n", DateTime.Now.ToString("HH:mm:ss.ffff"), szMsg);

        switch (emLevel)
        {
        case CLogLevel.Warning:
        case CLogLevel.Trace:
            UnityEngine.Debug.LogWarning(szMsg);
            break;

        case CLogLevel.Error:
            UnityEngine.Debug.LogError(szMsg);
            break;

        default:
            UnityEngine.Debug.Log(szMsg);
            break;
        }
    }
Beispiel #13
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (radioButtonDebug.Checked)
            {
                mLogLevel = CLogLevel.cllDebug;
            }
            if (radioButtonError.Checked)
            {
                mLogLevel = CLogLevel.cllError;
            }
            if (radioButtonFatal.Checked)
            {
                mLogLevel = CLogLevel.cllFatal;
            }
            if (radioButtonPanic.Checked)
            {
                mLogLevel = CLogLevel.cllPanic;
            }
            if (radioButtonQuiet.Checked)
            {
                mLogLevel = CLogLevel.cllQuiet;
            }
            if (radioButtonVerbose.Checked)
            {
                mLogLevel = CLogLevel.cllVerbose;
            }
            if (radioButtonWarning.Checked)
            {
                mLogLevel = CLogLevel.cllWarning;
            }

            mLogPath = textBoxLogPath.Text;
            if (radioButtonIdle.Checked)
            {
                mThreadPrority = CThreadPriority.ctpIdle;
            }
            if (radioButtonLower.Checked)
            {
                mThreadPrority = CThreadPriority.ctpLower;
            }
            if (radioButtonLowest.Checked)
            {
                mThreadPrority = CThreadPriority.ctpLowest;
            }
            if (radioButtonNormal.Checked)
            {
                mThreadPrority = CThreadPriority.ctpNormal;
            }
            try
            {
                mThreadCount = int.Parse(textBoxThreadCount.Text);
            }
            catch (System.Exception ex)
            {
                mThreadCount = 1;
            }

            mPreview = radioButtonPreview.Checked;

            DialogResult = DialogResult.OK;
        }
        public void SetFilterLogLevel(CLogLevel level)
        {
            bool needReload = m_filteredDelegate.SetFilterLogLevel(level);

            SetFilteredDelegate(m_filteredDelegate, needReload);
        }
Beispiel #15
0
 public static extern int SetProducerLogLevel(HandleRef producer, CLogLevel level);
Beispiel #16
0
    private static void DoLog(string szMsg, CLogLevel emLevel)
    {
        if (LogLevel > emLevel)
            return;
        szMsg = string.Format("[{0}]{1}\n\n=================================================================\n\n", DateTime.Now.ToString("HH:mm:ss.ffff"), szMsg);

        switch (emLevel)
        {
            case CLogLevel.Warning:
            case CLogLevel.Trace:
                UnityEngine.Debug.LogWarning(szMsg);
                break;
            case CLogLevel.Error:
                UnityEngine.Debug.LogError(szMsg);
                break;
            default:
                UnityEngine.Debug.Log(szMsg);
                break;
        }
    }
Beispiel #17
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (radioButtonDebug.Checked)
            {
                mLogLevel = CLogLevel.cllDebug;
            }
            if (radioButtonError.Checked)
            {
                mLogLevel = CLogLevel.cllError;
            }
            if (radioButtonFatal.Checked)
            {
                mLogLevel = CLogLevel.cllFatal;
            }
            if (radioButtonPanic.Checked)
            {
                mLogLevel = CLogLevel.cllPanic;
            }
            if (radioButtonQuiet.Checked)
            {
                mLogLevel = CLogLevel.cllQuiet;
            }
            if (radioButtonVerbose.Checked)
            {
                mLogLevel = CLogLevel.cllVerbose;
            }
            if (radioButtonWarning.Checked)
            {
                mLogLevel = CLogLevel.cllWarning;
            }

            mLogPath = textBoxLogPath.Text;
            if (radioButtonIdle.Checked)
            {
                mThreadPrority = CThreadPriority.ctpIdle;
            }
            if (radioButtonLower.Checked)
            {
                mThreadPrority = CThreadPriority.ctpLower;
            }
            if (radioButtonLowest.Checked)
            {
                mThreadPrority = CThreadPriority.ctpLowest;
            }
            if (radioButtonNormal.Checked)
            {
                mThreadPrority = CThreadPriority.ctpNormal;
            }
            try
            {
                mThreadCount = int.Parse(textBoxThreadCount.Text);
            }
            catch (System.Exception ex)
            {
                mThreadCount = 1;
            }

            mPreview = radioButtonPreview.Checked;

            DialogResult = DialogResult.OK;
        }
Beispiel #18
0
 public static extern int SetProducerLogLevel(IntPtr producer, CLogLevel level);
Beispiel #19
0
 public static extern int SetPushConsumerLogLevel(IntPtr consumer, CLogLevel level);
Beispiel #20
0
 public static void Log(string name, object value, CLogLevel level = CLogLevel.Info)
 {
     _log(name + " -> " + value.ToString(), level);
 }
Beispiel #21
0
        public override void Add(CLogLevel level, CTag tag, string text, string stackTrace)
        {
            string formattedText = FormatLine(text, level, tag, stackTrace);

            base.Add(level, tag, formattedText, stackTrace);
        }
 public CConsoleViewLogLevelFilter(CLogLevel level)
     : base(2)
 {
     this.Level = level;
 }
 public static extern int SetPushConsumerLogLevel(HandleRef consumer, CLogLevel level);
Beispiel #24
0
 public override void Add(CLogLevel level, CTag tag, string[] table, string stackTrace)
 {
     string[] formattedTable = FormatTable(table, level, tag, stackTrace);
     base.Add(level, tag, formattedTable, stackTrace);
 }
Beispiel #25
0
 private void OnLogMessage(CLogLevel level, CTag tag, string message, string stackTrace)
 {
     Add(level, tag, message, stackTrace);
 }
Beispiel #26
0
 public static void Log(object thing, CLogLevel level = CLogLevel.Info)
 {
     _log(thing.ToString(), level);
 }