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()); }
public void Add(CLogLevel level, CTag tag, string line) { CConsoleViewCellEntry entry = new CConsoleViewCellEntry(line); entry.level = level; entry.tag = tag; Add(entry); }
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); }
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; }
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); }
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); }
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); } }
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; } }
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); }
public static extern int SetProducerLogLevel(HandleRef producer, CLogLevel level);
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; } }
public static extern int SetProducerLogLevel(IntPtr producer, CLogLevel level);
public static extern int SetPushConsumerLogLevel(IntPtr consumer, CLogLevel level);
public static void Log(string name, object value, CLogLevel level = CLogLevel.Info) { _log(name + " -> " + value.ToString(), level); }
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);
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); }
private void OnLogMessage(CLogLevel level, CTag tag, string message, string stackTrace) { Add(level, tag, message, stackTrace); }
public static void Log(object thing, CLogLevel level = CLogLevel.Info) { _log(thing.ToString(), level); }