Jun 242015
 


Disable Logging
- disable logs in builds with 1-Click

1. Quick Start:
Don’t forget to remove the old version of the plugin before updating. See How to remove the plugin?

Import the plugin, then read the following instructions.

1.1 How to enable/disable logs in builds?
(1) Call DLog.Log() instead of Debug.Log().
(2) DLog.Log() is in the UnityEngine namespace, so add “using UnityEngine;” to the scripts which call the DLog.Log() if needed.
(3) Attach the DLogOption.cs to a game object.
(4) Set the options of DLogOption component.

DLogOption

- Log Info
This option can enable /disable “DLog.Log()”

- Log Warning
This option can enable / disable “DLog.LogWarning()”

- Log Error
This option can enable / disable “DLog.LogError()” and “DLog.LogException()”

- Enable All For Editor Mode
If you check this option, all the logs (info, warning, error, exception) will be outputted in the unity editor mode. Ignore settings of “Log Info“, “Log Warning” and “Log Error“.

- Enable All For Development Build
If you check this option, and set the build settings as a “Development Build”, then all the logs (info, warning, error, exception) will be outputted in the development build. Ignore settings of “Log Info“, “Log Warning” and “Log Error“.

But, how to set the build settings as a “Development Build”?
Unity menu, File > Build Settings…, check the option “Development Build”. That’s all.

1.2 How to output colored logs?
This plugin provides many simple APIs, which can help you output the colored logs easily.

1. Example effects (in Unity Console):

2. Example codes:
// Examples of DLog.Log()
DLog.Log(“Log a message”);
DLog.Log(“Log a message with a specific color “, Color.blue);
DLog.Log(“Log a message with a user-defined color”, new Color(0f, 0.5f, 0f));

// Examples of DLog.LogWarning()
DLog.LogWarning(“Log a warning message”);
DLog.LogWarning(“Log a warning message with a specific color”, Color.yellow);
DLog.LogWarning(“Log a warning message with a user-defined color”, new Color(1f, 0.5f, 0.25f));

// Examples of DLog.LogError()
DLog.LogError(“Log an error message”);
DLog.LogError(“Log an error message with a specific color”, Color.red);
DLog.LogError(“Log an error message with a user-defined color”, new Color(1f, 0f, 1f));

// Examples of DLog.LogException()
DLog.LogException(new System.Exception(“Log an exception message”));
DLog.LogException(new System.Exception(“Log an exception message with a specific color”), Color.red);
DLog.LogException(new System.Exception(“Log an exception message with a user-defined color”), new Color(1f, 0f, 1f));

1.3 Is there a demo?
(1) Open the Demo.unity, which is at: Assets\Tiinoo\DisableLogging\Demo\Demo.unity
(2) Find the Demo object in the hierarchy.
(3) Change the options of the component DLogOption(Script).
(4) Click the Log checkbox of the component Demo(Script). Then you will see the logs outputted in the unity console.

1.4 Can i change the name of DLog?
Yes, of course.
(1) Unzip DisableLogging_dll_src.zip, which is at: Assets\Tiinoo\DisableLogging\DisableLogging_dll_src.zip
(2) Rename the DLog.cs and modify all the related codes.
(3) Package the new codes into a dll, and use this dll to replace the DisableLogging.dll, which is at: Assets\Tiinoo\DisableLogging\Dlls\DisableLogging.dll
(4) Modify all calls to DLog in DLogOption.cs and Demo.cs
That’s all.

1.5 How to upgrade from the old version?
If you have used an old version of the plugin (version <= 2.0.0) in your project and want to upgrade it to the newest version of the plugin (version >= 2.1.0), please do the following steps:
(1) Remove the old version of the plugin.
(2) Attach DLogOption.cs to a game object. (Instead of LoggerOption.cs)
(3) Replace Logger with DLog in your codes.
(4) Delete using DisableLogging; in your codes.
Tips:
We can use the menu item in MonoDevelop to do the Step (3) and step (4).
(In MonoDevelop, use the menu item: Search > Replace in Files… )

1.6 How to remove the plugin?
To remove plugin (version <= 2.0.0)
(1)Delete the folder: Assets/DisableLogging
(2)Delete the file: Assets/Plugins/DisableLogging.dll

To remove plugin (version >= 2.1.0)
Delete the folder: Assets/Tiinoo/DisableLogging

2. Links:
Overview | Changelog | Unity Forum thread