Skip to content

Instantly share code, notes, and snippets.

@randalfien
Last active February 10, 2019 18:00
Show Gist options
  • Save randalfien/ef404578d931ea55c60fb0ef8dff2b59 to your computer and use it in GitHub Desktop.
Save randalfien/ef404578d931ea55c60fb0ef8dff2b59 to your computer and use it in GitHub Desktop.
public static class MyLogger
{
public const int LOG_TYPE_1 = 1;
public const int LOG_TYPE_2 = 2;
public const int LOG_TYPE_3 = 4;
public static int Flags = 1; // Bit flags to turn individual log types on/off
[System.Diagnostics.Conditional("DEBUG")] // All calls to this method will be stripped when compiling without the DEBUG symbol
public static void Log(string msg, int type = 0)
{
if( tag == 0 || (Flags & tag) > 0 )
UnityEngine.Debug.Log(msg);
}
}
@randalfien
Copy link
Author

This is a simple custom logger for Unity. If you add this to your code with:
using static MyLogger;
You can then call it directly, like this:
Log("My Message", LOG_TYPE_1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment