Logger

Logger

 100

You need to own this item to leave a rating.

0 ratings

A log de-throttler. This is a library script to be used in combination with other scripts. It uses the Reflective capabilities for maximum efficiency. It can be implemented as an optional library. The interface is identical to the internal Log class. You may put this script in any object of any type anywhere on the scene for it to work. What it will do is capture logging sent to it and ease the resulting speed at which the Log messages are relayed to the real logging. This will insure every message you write to the logs gets there and prevent things like this "134 Log.Write()s were skipped due to throttle during the last minute." from showing up in your logs. This can be crucial if you are trying to debug something complex and you simply need to log a lot of information. This script will most likely become an optional component of all my future scripts.
The parameters for the script are tuned to handle the current log throttling in place. There is a simple enable switch as well that would do the same thing as not having the script.
The interface:
public interface ILogger
{
void Write(string message);
void Write(LogLevel level, string message);
void Write(string tag, string message);
void Write(LogLevel level, string tag, string message);
}

Recommended Initiialization
Add this private ILogger Logger = null;
Then in your Init()
Add something like this
Logger = ScenePrivate.FindReflective<ILogger>("GindLog.Logger").FirstOrDefault();
You can of course add more to verify it finds it and delays before trying to find it.
Which I can assist with if requested.
Then later in your script just call it nearly identically to how you would the existing Log.
Example
Logger.Write(LogLevel.Error, FileName, "Failed to find user");