Ejemplo n.º 1
0
        public static void NewInstance(string dsn, SentryConfig sentryConfig = null, RavenOptionType option = null)
        {
            if (m_instance == null)
            {
                GameObject obj = new GameObject("RavenObj");
                obj.AddComponent <Unity3DRavenCS>();
                m_instance = obj.GetComponent <Unity3DRavenCS>();

                m_instance.m_dsn = new DSN(dsn);
                if (!m_instance.m_dsn.isValid)
                {
                    m_instance.m_valid = false;
                    Debug.Log("Unity3DRavenCS is disabled because the DSN is invalid.");
                }
                else
                {
                    m_instance.m_valid = true;
                }

                m_instance.m_option       = option == null ? new RavenOptionType() : option;
                m_instance.m_sentryConfig = sentryConfig == null ? new SentryConfig() : sentryConfig;

                m_instance.Init();

                DontDestroyOnLoad(obj);
            }
        }
Ejemplo n.º 2
0
    void Start()
    {
        // Create a new Unity3DRavenCS instance before using it.
        Unity3DRavenCS.Unity3DRavenCS.NewInstance("http://*****:*****@192.168.1.109:9000/2");

        m_client = Unity3DRavenCS.Unity3DRavenCS.instance;

        // Create some tags that need to be sent with log messages.
        m_tags = new Dictionary <string, string>();
        m_tags.Add("Device-Model", SystemInfo.deviceModel);
        m_tags.Add("Device-Name", SystemInfo.deviceName);
        m_tags.Add("OS", SystemInfo.operatingSystem);
        m_tags.Add("MemorySize", SystemInfo.systemMemorySize.ToString());


        // =========================================================================================================
        // Capture message
        m_client.CaptureMessage("Hello, world!", LogType.Log, m_tags);
        // Capture message with System.Diagnostics.StackTrace
        m_client.CaptureMessageWithSysStack("Stack Trace.", LogType.Log, null, new System.Diagnostics.StackTrace(true));

        // Capture exception
        try
        {
            ExceptionCall();
        }
        catch (Exception e)
        {
            m_client.CaptureException(e);
        }


        // =========================================================================================================
        // You can register a log handler to handle all logs including exceptions.
        // See LogHandler(), OnEnable() and OnDisable().
        // The following logs will be sent to sentry server automatically.
        Debug.Log("Info log");
        Debug.LogWarning("Warning log");
        Debug.LogError("Error log");
        // The following function call throws an exception. An error log with stack trace will be sent
        // to sentry server automatically.
        ExceptionCall();
    }