Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Editor/UberLoggerEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ void DrawToolbar()
ShowTimes = showTimes;
}
DrawPos.x += elementSize.x;
var showChannels = ToggleClamped(ShowChannels, "Channels", EditorStyles.toolbarButton, out elementSize);
if (showChannels != ShowChannels)
{
MakeDirty = true;
ShowChannels = showChannels;
}
DrawPos.x += elementSize.x;
var collapse = ToggleClamped(Collapse, "Collapse", EditorStyles.toolbarButton, out elementSize);
if(collapse!=Collapse)
{
Expand Down Expand Up @@ -365,15 +372,19 @@ bool ShouldShowLog(System.Text.RegularExpressions.Regex regex, LogInfo log)
/// <summary>
/// Converts a given log element into a piece of gui content to be displayed
/// </summary>
GUIContent GetLogLineGUIContent(UberLogger.LogInfo log, bool showTimes)
GUIContent GetLogLineGUIContent(UberLogger.LogInfo log, bool showTimes, bool showChannels)
{
var showMessage = log.Message;
//Make all messages single line
showMessage = showMessage.Replace(UberLogger.Logger.UnityInternalNewLine, " ");
if(showTimes)
{
showMessage = log.GetRelativeTimeStampAsString() + ": " + showMessage;
}

showMessage = string.Format("{0}{1}{2}{3}{4}",
showChannels ? "[" + log.Channel + "]" : "",
showTimes && showChannels ? " " : "",
showTimes ? log.GetRelativeTimeStampAsString() : "",
showChannels || showTimes ? " : " : "",
showMessage
);

var content = new GUIContent(showMessage, GetIconForLog(log));
return content;
Expand Down Expand Up @@ -435,7 +446,7 @@ public void DrawLogList(float height)

foreach(var countedLog in collapsedLinesList)
{
var content = GetLogLineGUIContent(countedLog.Log, ShowTimes);
var content = GetLogLineGUIContent(countedLog.Log, ShowTimes, ShowChannels);
RenderLogs.Add(countedLog);
var logLineSize = logLineStyle.CalcSize(content);
LogListMaxWidth = Mathf.Max(LogListMaxWidth, logLineSize.x);
Expand All @@ -453,7 +464,7 @@ public void DrawLogList(float height)
{
if(ShouldShowLog(filterRegex, log))
{
var content = GetLogLineGUIContent(log, ShowTimes);
var content = GetLogLineGUIContent(log, ShowTimes, ShowChannels);
RenderLogs.Add(new CountedLog(log, 1));
var logLineSize = logLineStyle.CalcSize(content);
LogListMaxWidth = Mathf.Max(LogListMaxWidth, logLineSize.x);
Expand Down Expand Up @@ -507,7 +518,7 @@ public void DrawLogList(float height)
}

//Make all messages single line
var content = GetLogLineGUIContent(log, ShowTimes);
var content = GetLogLineGUIContent(log, ShowTimes, ShowChannels);
var drawRect = new Rect(logLineX, buttonY, contentRect.width, LogListLineHeight);
if(GUI.Button(drawRect, content, logLineStyle))
{
Expand Down Expand Up @@ -905,6 +916,7 @@ void ClearSelectedMessage()
Texture2D SmallWarningIcon;
Texture2D SmallMessageIcon;

bool ShowChannels = true;
bool ShowTimes = true;
bool Collapse = false;
bool ScrollFollowMessages = false;
Expand Down
76 changes: 76 additions & 0 deletions UberLoggerChannel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.Collections;
using System.Collections.Generic;
using UberLogger;
using UnityEngine;

/// <summary>
/// Wraps access to a named channel in a class so that it can be used without having to
/// type the channel name each time to enforcing channel name checking at compile-time.
/// </summary>
public class UberLoggerChannel
{
private string _channelName;
public UberLoggerChannel(string channelName)
{
_channelName = channelName;
}

/// <summary>
/// Gets or sets whether messages sent to this channel should actually be relayed to the logging system or not.
/// </summary>
public bool Mute { get; set; }

[StackTraceIgnore]
public void Log(string message, params object[] par)
{
if (!Mute)
{
UberDebug.LogChannel(_channelName, message, par);
}
}

[StackTraceIgnore]
public void Log(Object context, string message, params object[] par)
{
if (!Mute)
{
UberDebug.LogChannel(context, _channelName, message, par);
}
}

[StackTraceIgnore]
public void LogWarning(string message, params object[] par)
{
if (!Mute)
{
UberDebug.LogWarningChannel(_channelName, message, par);
}
}

[StackTraceIgnore]
public void LogWarning(Object context, string message, params object[] par)
{
if (!Mute)
{
UberDebug.LogWarningChannel(context, _channelName, message, par);
}
}

[StackTraceIgnore]
public void LogError(string message, params object[] par)
{
if (!Mute)
{
UberDebug.LogErrorChannel(_channelName, message, par);
}
}

[StackTraceIgnore]
public void LogError(Object context, string message, params object[] par)
{
if (!Mute)
{
UberDebug.LogErrorChannel(context, _channelName, message, par);
}
}
}
13 changes: 13 additions & 0 deletions UberLoggerChannel.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.