Howdy developers,

We made a v1.3.2 of the Asmodee.net Unity SDK. It focuses on prodiving nice logs everywhere in the plugin. This will especially prove helpful to debug the Scalable Server communications.

Let’s see what’s new:

  • Now every message to the Scalable Server (sent AND received) are logged with detailed content.
  • Analytics events are logged
  • Game events of the Sample project are logged

Ok ! But why is it different than an Unity log?

That’s because there is more info:

  • the UTC time of the log, very useful to compare user logs and server logs of the same time
  • the severity of the log
  • the “module” (or class or whatever) that made the log
  • a short message, hopefully easy to parse, with few (or no) dynamic parts
  • an arbitrary amount of contextual data (in JSON)

Here’s for example, a log of an OAuth token successfully retrieved:

[2017-02-02T18:33:41.4189540Z][Info][RestAPI.receiver] Authentication successful {"client_id":"usdk-app","uri":"https://api.asmodee.net/main/v2/oauth/token","grant_type":"client_credentials","scope":"public","expires_in":86400}

Note: sensible info, such as passwords or auth tokens are NEVER logged, and should NEVER be logged. This is not automatic though, so you must remember to exclude private info by hand.

How do you use it?

The logger syntax is simple, and has different shortcuts for different severities. For example:

AsmoLogger.Error("Game", "Game Started");
var details = new Hashtable() { { "total", 134 }, { "player", "Bob"} };
AsmoLogger.Info("ScoreSystem", "Score increase", details);

Great. How can I display more/less logs?

You can change the log level to increase or decrease the amount of logs that make it to the Unity console and log file:

AsmoLogger.LogLevel(AsmoLogger.Severity.Info);

By default, the severity level is Debug for debug builds, and Info otherwise. The severities are sorted from the least severe to the more severe:

public enum Severity
{
    // Uses UnityEngine.Debug.Log.
    // Should not appear in public release !
    Trace,

    // Uses UnityEngine.Debug.Log.
    // Ok, but usually not relevant in public release.
    Debug,

    // Uses UnityEngine.Debug.Log.
    // Useful for non critical info, checkpoints...
    Info,

    // Uses UnityEngine.Debug.Warning.
    // This start to get serious
    Notice,

    // Uses UnityEngine.Debug.Warning.
    // This is soon to be an error
    Warning,

    // Uses UnityEngine.Debug.Error.
    // A real error, but the program continues
    Error,

    // Uses UnityEngine.Debug.Error.
    // The program is dead, this are its last words...
    Fatal
}

Make sure you download and update your plugin.

For any request or question or comment, please send us an e-mail at support-dev@asmodee.net.

The Asmodee Digital team