-
Notifications
You must be signed in to change notification settings - Fork 63
Utility class for logging to channel #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| 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; | ||
| Filter = Filters.None; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Filters for preventing display of certain message types. | ||
| /// </summary> | ||
| [System.Flags] | ||
| public enum Filters | ||
| { | ||
| None = 0, | ||
| HideLogs = 1, | ||
|
||
| HideWarnings = 2, | ||
| HideErrors = 4 | ||
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the current filters being applied to this channel. Messages that match the specified set of flags will be ignored. | ||
| /// </summary> | ||
| public Filters Filter { get; set; } | ||
|
|
||
| [StackTraceIgnore] | ||
| public void Log(string message, params object[] par) | ||
| { | ||
| if ((Filter & Filters.HideLogs) != Filters.HideLogs) | ||
| { | ||
| UberDebug.LogChannel(_channelName, message, par); | ||
| } | ||
| } | ||
|
|
||
| [StackTraceIgnore] | ||
| public void Log(Object context, string message, params object[] par) | ||
| { | ||
| if ((Filter & Filters.HideLogs) != Filters.HideLogs) | ||
|
||
| { | ||
| UberDebug.LogChannel(context, _channelName, message, par); | ||
| } | ||
| } | ||
|
|
||
| [StackTraceIgnore] | ||
| public void LogWarning(string message, params object[] par) | ||
| { | ||
| if ((Filter & Filters.HideWarnings) != Filters.HideWarnings) | ||
| { | ||
| UberDebug.LogWarningChannel(_channelName, message, par); | ||
| } | ||
| } | ||
|
|
||
| [StackTraceIgnore] | ||
| public void LogWarning(Object context, string message, params object[] par) | ||
| { | ||
| if ((Filter & Filters.HideWarnings) != Filters.HideWarnings) | ||
| { | ||
| UberDebug.LogWarningChannel(context, _channelName, message, par); | ||
| } | ||
| } | ||
|
|
||
| [StackTraceIgnore] | ||
| public void LogError(string message, params object[] par) | ||
| { | ||
| if ((Filter & Filters.HideErrors) != Filters.HideErrors) | ||
| { | ||
| UberDebug.LogErrorChannel(_channelName, message, par); | ||
| } | ||
| } | ||
|
|
||
| [StackTraceIgnore] | ||
| public void LogError(Object context, string message, params object[] par) | ||
| { | ||
| if ((Filter & Filters.HideErrors) != Filters.HideErrors) | ||
| { | ||
| UberDebug.LogErrorChannel(context, _channelName, message, par); | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly to my regret, the coding standard would be ChannelName for a private member variable that isn't shadowed by a property.