Exemple #1
0
    /// <summary>
    /// Extra setup that needs to occur after Awake.
    /// </summary>
    void Start()
    {
        if (hasPlayer)
        {
            Lumos.Log("Using existing player " + playerId);
            LumosApp.Ping();
        }
        else
        {
            playerId = LumosUtil.GeneratePlayerId();
            Lumos.Log("Using new player " + playerId);
            LumosApp.Ping(true);
        }

        RunRoutine(SendQueuedRoutine());
    }
Exemple #2
0
    /// <summary>
    /// Records a log message.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <param name="stackTrace">Detailed list of message's origin.</param>
    /// <param name="type">
    /// The type of message (debug, warning, error, etc.).
    /// </param>
    public static void Record(string message, string stackTrace, LogType type)
    {
        if (!Lumos.servicesAvailable.Contains(Lumos.service.Logs))
        {
            return;
        }

        // Ignore messages logged by Lumos.
        if (message.StartsWith("[Lumos]"))
        {
            return;
        }

        // Only log message types that the user specifies.
        if ((type == LogType.Log && !Lumos.instance.recordLogs) ||
            (type == LogType.Warning && !Lumos.instance.recordWarnings) ||
            (type == LogType.Error && !Lumos.instance.recordErrors) ||
            (type == LogType.Exception && !Lumos.instance.recordErrors) ||
            type == LogType.Assert)               // Ignore asserts
        {
            return;
        }

        // Skip messages that the user explicitly says to ignore.
        if (toIgnore != null)
        {
            foreach (var ignoreMessage in toIgnore)
            {
                if (message.StartsWith(ignoreMessage))
                {
                    return;
                }
            }
        }

        foreach (var ignoreMessage in lumosIgnore)
        {
            if (message.StartsWith(ignoreMessage))
            {
                return;
            }
        }

        // If an identical message has been logged before increment its total.
        for (int i = 0; i < logs.Count; i++)
        {
            var log = logs[i];

            if ((string)log["type"] == typeLabels[type] &&
                (string)log["message"] == message &&
                (string)log["stack_trace"] == stackTrace)
            {
                log["total"] = (int)log["total"] + 1;
                return;
            }
        }

        // Otherwise create a new message dictionary
        var hash   = LumosUtil.MD5Hash(typeLabels[type], message, stackTrace);
        var newLog = new Dictionary <string, object>()
        {
            { "type", typeLabels[type] },
            { "message", message },
            { "stack_trace", stackTrace },
            { "level", Application.loadedLevelName },
            { "total", 1 },
            { "hash", hash }
        };

        logs.Add(newLog);
    }