コード例 #1
0
        //public ConsoleLogVM(ConsoleLog ConsoleLog)
        //{
        //    this.Entry = ConsoleLog.Entry;
        //    this.TSUTC = ConsoleLog.TSUTC;
        //    this.TSLocal = TSUTC.ToLocalTime();
        //    ProcessEntry();
        //}

        public ConsoleLogVM(LogStruct Log)
        {
            this.Entry   = Log.LogEntry;
            this.TSUTC   = Log.TimeStampInUTC;
            this.TSLocal = TSUTC.ToLocalTime();
            ProcessEntry();
        }
コード例 #2
0
    private void OnLog(string condition, string stackTrace, LogType type)
    {
        if (type == LogType.Exception || type == LogType.Error)
        {
            var log = new LogStruct
            {
                Version    = _version,
                UserId     = _userId,
                Type       = type.ToString(),
                Message    = condition,
                StackTrace = stackTrace.Substring(0, Mathf.Min(stackTrace.Length, 200)),
                Date       = DateTime.UtcNow.ToString("dd/MM/yyyy H:mm:ss")
            };

            _logs.Logs.Add(log);

            if (_panelRoot != null)
            {
                _panelRoot.SetActive(true);
                _userIdText.text  = _userId;
                _versionText.text = _version;
                _messageText.text = condition;
            }
            else
            {
                SendError();
            }
        }
    }
コード例 #3
0
ファイル: Debug.cs プロジェクト: wannasaynone/3DGamePractice
        public static void Log(LogStruct log)
        {
            if (string.IsNullOrEmpty(log.className))
            {
                log.className = "NoClassNameInfo";
            }
            if (string.IsNullOrEmpty(log.methodName))
            {
                log.methodName = "NoMethodName";
            }
            string _message = string.Format("[{0}][{1}] {2}", log.className, log.methodName, log.message);

            switch (log.level)
            {
            case Level.Normal:
            {
                UnityEngine.Debug.Log(_message);
                break;
            }

            case Level.Warning:
            {
                UnityEngine.Debug.LogWarning(_message);
                break;
            }

            case Level.Error:
            {
                UnityEngine.Debug.LogError(_message);
                break;
            }
            }
        }
コード例 #4
0
    public void AnalyticsImplement(LogStruct lastexception)
    {
//		AnalyticsTracker.Instance.SendEvent("Exception", GetFirstFunctionName(lastexception),
//			new Dictionary<string, object>{
//				{"condition", lastexception.condition},
//				{"trace", lastexception.stacktrace}
//			});
    }
コード例 #5
0
    IEnumerator SendDebugToFile(LogStruct lastexception)
    {
        Debug.Log("SendDebugToFile");

        ScreenShotRoutine((attachmentPath) => {
            WriteFileLog(BufferToText(), lastexception.stacktrace, lastexception.type == LogType.Exception);
            FinalWorking();
        });
        yield return(null);
    }
コード例 #6
0
 public void RecordLog(LogStruct log)
 {
     lock (((ICollection)histories).SyncRoot) {
         while (histories.Count > 0 && _historySize <= histories.Count)
         {
             histories.Dequeue();
         }
         histories.Enqueue(log);
         OnLogOutput?.Invoke(log);
     }
 }
コード例 #7
0
    void SendDebugToGoogleAnalytics(LogStruct lastexception)
    {
        if (m_bCrashCatched != true)
        {
            m_bCrashCatched = true;

            UnityEngine.Debug.Log("send crash report to google");
            AnalyticsImplement(lastexception);

            Routine(SendDebugToFile(lastexception));
        }
    }
コード例 #8
0
    void AddThreadBuffer(LogStruct st)
    {
        lock ( m_listLogBufferThread )
        {
            m_listLogBufferThread.Add(st);

            while (m_listLogBufferThread.Count > m_iMaxLogCount)
            {
                m_listLogBufferThread.RemoveAt(0);
            }
        }
    }
コード例 #9
0
ファイル: LogViewer.cs プロジェクト: emreboyrazz/TinyCodes
 /*
  *      - Controll If there is unCatched errors in update
  *      - Limit instantiated objects
  *      - Add Clear Button To clear list
  */
 void PrintLogs(List <Logs> logList)
 {
     Debug.Log("PrintLogs");
     DestroyInstantiatedObbjects();
     for (int i = 0; i < logList.Count; i++)
     {
         GameObject instantiated = Instantiate(LogTextFieldPrefab, LogTextContainer);
         logStruct = instantiated.GetComponent <LogStruct> ();
         logStruct.LogText.text          = logList[i].value;
         logStruct.Collapsedcounter.text = logList[i].counter.ToString();
     }
 }
        public void AddEvent(LogImportance importance, string TestName, string entry)
        {
            LogStruct ls = new LogStruct();

            ls.importance = importance;
            ls.LogEntry   = entry;
            ls.TestName   = TestName;
            LogList.Add(ls);
            if (this.OnEventLog != null)
            {
                OnEventLog((IUPnPTestGroup)this, ls);
            }
        }
        private void grabLogEntry(string testname, XmlElement logElement)
        {
            string importance = logElement.GetAttribute("importance");
            string message    = logElement.InnerText;

            LogStruct log = new LogStruct();

            log.TestName   = testname;
            log.importance = Util.StringToLogImportance(importance);
            log.LogEntry   = message;

            LogList.Add(log);
        }
コード例 #12
0
    IEnumerator WaitServerInfoRefresh()
    {
        while (m_bUpdateWaitServerInfo == true)
        {
            yield return(null);
        }
        if (m_eWriteMode == eCrashWriteType.EWRITEMAIL ||
            m_eWriteMode == eCrashWriteType.EWRITESERVER)
        {
            string stackPath = "";
            string bodyPath  = "";
                        #if UNITY_ANDROID || UNITY_IPHONE
            stackPath = Path.Combine(Application.persistentDataPath, "exceptiontrace.txt");
            bodyPath  = Path.Combine(Application.persistentDataPath, "unityexceptions.txt");
                        #else
            stackPath = Path.Combine(Application.dataPath, "exceptiontrace.txt");
            bodyPath  = Path.Combine(Application.dataPath, "unityexceptions.txt");
                        #endif

            if (File.Exists(stackPath) && File.Exists(bodyPath))
            {
                LogStruct st = new LogStruct {
                    type       = LogType.Exception, buffer = File.ReadAllText(bodyPath),
                    stacktrace = File.ReadAllText(stackPath), condition = ""
                };

                switch (m_eWriteMode)
                {
                case eCrashWriteType.EWRITESERVER:
                    Routine(SendDebugToServer(st, File.ReadAllText(bodyPath)));
                    break;

                case eCrashWriteType.EWRITEMAIL:
                    Routine(SendDebugToMail(st, m_stServerInfo.GetCurrentSmtp().userID, m_stServerInfo.GetCurrentSmtp().userPwd, File.ReadAllText(bodyPath)));
                    break;
                }
            }
        }
    }
コード例 #13
0
        public List <LogStruct> getLogs(string username, string pass)
        {
            List <LogStruct> logList = new List <LogStruct>();

            if (checkAdmin(username, pass))
            {
                using (MySqlConnection connection = new MySqlConnection(ConnectionString))
                {
                    connection.Open();

                    using (MySqlCommand com = new MySqlCommand("select * from api_log", connection))
                    {
                        MySqlDataReader reader = com.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                LogStruct logs = new LogStruct();
                                logs.ID           = Convert.ToInt32(reader["id"]);
                                logs.ipAdress     = reader["ip_adress"].ToString();
                                logs.log          = reader["log"].ToString();
                                logs.functionName = reader["function_name"].ToString();

                                logs.cdate = DateTime.Parse(reader["cdate"].ToString());



                                logList.Add(logs);
                            }
                        }
                        com.Dispose();
                    }
                    connection.Dispose();
                    connection.Close();
                }
            }

            return(logList);
        }
コード例 #14
0
    string GetFirstFunctionName(LogStruct lastexception)
    {
        string function = "[" + lastexception.type.ToString() + "] ";

        if (lastexception.condition.Contains("Exception"))
        {
            function = "[" + lastexception.condition.Replace(" ", "").Split(':')[0] + "] ";
        }

        if (lastexception.stacktrace.IndexOf(" (") != -1)
        {
            bool isAssert = lastexception.stacktrace.Contains("SGUtil.Assert") == true?true:false;

            string[] line = lastexception.stacktrace.Split('\n');
            for (int i = 0; i < line.Length; i++)
            {
                string lineString = line[i];
                UnityEngine.Debug.Log("Line : " + lineString);
                if (isAssert)
                {
                    function = "[SGUtil.Assert] ";
                    isAssert = false;
                    continue;
                }
                if (lineString.IndexOf(" (") != -1)
                {
                    function += lineString.Substring(0, lineString.IndexOf(" ("));
                }
                else if (lineString.IndexOf("(") != -1)
                {
                    function += lineString.Substring(0, lineString.IndexOf("("));
                }
                break;
            }
        }
        return(function);
    }
コード例 #15
0
    IEnumerator SendDebugToServer(LogStruct lastexception, string unreportedMessageBody = "")
    {
        if (m_bCrashCatched != true)
        {
            m_bCrashCatched = true;
            AnalyticsImplement(lastexception);

            UnityEngine.Debug.Log("SendDebugToServer ");

            string mailList = GetMailingList();

            Hashtable data = new Hashtable();
            data["subject"] = "[" + m_strProjectName + " CrashReport - " + lastexception.type.ToString() + " #" + m_strBuild_version.ToString() + " ] " + m_stUserInfo.teamname + " #" + DateTime.Now;
            data["text"]    = unreportedMessageBody.Length > 0? unreportedMessageBody : MakeMassageHeader(BufferToText());
            data["reciver"] = mailList;
            data["from"]    = "no-reply";
            data["sender"]  = GetSenderList();

            Debug.Log(SG.MiniJsonExtensions.toJson(GetSenderList()));

            if (unreportedMessageBody.Length <= 0)
            {
                WriteFileLog(data["text"].ToString(), lastexception.stacktrace, lastexception.type == LogType.Exception);
            }

            ScreenShotRoutine((attachmentPath) => {
                if (File.Exists(attachmentPath))
                {
                    byte[] imageBytes = File.ReadAllBytes(attachmentPath);
                    // Convert byte[] to Base64 String

                    if (imageBytes.Length > 0)
                    {
                        string base64String = Convert.ToBase64String(imageBytes);
                        data["raw"]         = base64String;
                        Debug.Log("file save success = " + attachmentPath);
                    }
                }

                string base_data = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(SG.MiniJsonExtensions.toJson(data)));

                string www   = "";
                WWWForm form = null;
#if USING_GET
                www = (m_stServerInfo.host + "?data=" + base_data);
#else
                form = new WWWForm();
                form.AddField("data", base_data);

                www = m_stServerInfo.host;
#endif
                Routine(WebRequest(www, form, (msg) => {
                    Debug.Log(msg);
                    FinalWorking(unreportedMessageBody.Length > 0);
                }, () => {
                    Debug.Log("fail");
                    FinalWorking(unreportedMessageBody.Length > 0);
                }));
            });
        }
        yield return(null);
    }
コード例 #16
0
        private void grabLogEntry(string testname, XmlElement logElement)
        {
            string importance = logElement.GetAttribute("importance");
            string message = logElement.InnerText;

            LogStruct log = new LogStruct();

            log.TestName = testname;
            log.importance = Util.StringToLogImportance(importance);
            log.LogEntry = message;

            LogList.Add(log);
        }
コード例 #17
0
    IEnumerator UpdateCrashRepoter()
    {
        while (true)
        {
            yield return(new WaitForSeconds(1));

            //be sure no body else take control of log
#if !UNITY_5_4_OR_NEWER
            Application.RegisterLogCallback(HandleException);
            Application.RegisterLogCallbackThreaded(HandleExceptionThread);
#else
#endif

            if (m_listLogBufferThread.Count > 0)
            {
                lock ( m_listLogBufferThread )
                {
                    for (int i = 0; i < m_listLogBufferThread.Count; i++)
                    {
                        m_listLogBuffer.Add(m_listLogBufferThread[i]);
                    }
                    m_listLogBufferThread.Clear();
                }
            }

            if (m_iExceptionCount > 0)
            {
                m_iExceptionCount = 0;
                UnityEngine.Debug.Log("CrashReporter Exception Catched");


                int       index            = 1;
                LogStruct lastExceptionLog = m_listLogBuffer[m_listLogBuffer.Count - index++];

                while (lastExceptionLog.type == LogType.Log ||
                       lastExceptionLog.type == LogType.Warning)
                {
                    lastExceptionLog = m_listLogBuffer[m_listLogBuffer.Count - index++];

                    if (index >= m_listLogBuffer.Count)
                    {
                        break;
                    }
                }

                switch (m_eWriteMode)
                {
                case eCrashWriteType.EWRITEFILE:
                {
                    Routine(SendDebugToFile(lastExceptionLog));
                }
                break;

                case eCrashWriteType.EWRITESERVER:
                    Routine(SendDebugToServer(lastExceptionLog));
                    break;

                case eCrashWriteType.EWRITEMAIL:

                    Routine(SendDebugToMail(lastExceptionLog, m_stServerInfo.GetCurrentSmtp().userID, m_stServerInfo.GetCurrentSmtp().userPwd));
                    break;

                case eCrashWriteType.EWRITEGAv3:
                    SendDebugToGoogleAnalytics(lastExceptionLog);
                    break;
                }

                yield return(null);
            }
        }
    }
コード例 #18
0
 public CLogParser()
 {
      m_logStruct = new LogStruct();
 }
コード例 #19
0
 public void AddEvent(LogImportance importance, string TestName, string entry)
 {
     LogStruct ls = new LogStruct();
     ls.importance = importance;
     ls.LogEntry = entry;
     ls.TestName = TestName;
     LogList.Add(ls);
     if (this.OnEventLog != null) OnEventLog((IUPnPTestGroup)this, ls);
 }
コード例 #20
0
    IEnumerator SendDebugToMail(LogStruct lastexception, string gmailID = "", string gmailPwd = "", string unreportedMessageBody = "")
    {
        if (m_bCrashCatched != true)
        {
            m_bCrashCatched = true;
            AnalyticsImplement(lastexception);

            UnityEngine.Debug.Log("SendDebugToMail ");
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("CrashReporter");

            if (m_strMailingList.Length > 0 && m_strMailingList.IndexOf(";") != -1)
            {
                string[] sliceList = m_strMailingList.Split(';');
                for (int i = 0; i < sliceList.Length; i++)
                {
                    mail.To.Add(sliceList [i]);
                    //				UnityEngine.Debug.Log(sliceList[i]);
                }
            }
            else if (m_strMailingList.Length > 0)
            {
                mail.To.Add(m_strMailingList);
            }
            else
            {
                yield return(null);
            }

            mail.Subject = "[" + m_strProjectName + " CrashReport - " + lastexception.type.ToString() + " #" + m_strBuild_version.ToString() + " ] " + m_stUserInfo.teamname + " #" + DateTime.Now;

            mail.Body = unreportedMessageBody.Length > 0 ? unreportedMessageBody : MakeMassageHeader(BufferToText());


            ScreenShotRoutine((attachmentPath) => {
                if (unreportedMessageBody.Length <= 0)
                {
                    WriteFileLog(mail.Body, lastexception.stacktrace, lastexception.type == LogType.Exception);
                }
                try {
                    if (File.Exists(attachmentPath))
                    {
                        Attachment inline = new Attachment(attachmentPath);
                        string contentID  = Path.GetFileName(attachmentPath).Replace(".", "") + "@zofm";
                        inline.ContentDisposition.Inline          = true;
                        inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
                        inline.ContentId             = contentID;
                        inline.ContentType.MediaType = "image/png";
                        inline.ContentType.Name      = Path.GetFileName(attachmentPath);

                        mail.Attachments.Add(inline);
                    }

                    SmtpClient smtpServer            = new SmtpClient();
                    smtpServer.Host                  = m_stServerInfo.GetCurrentSmtp().smtpHost;
                    smtpServer.Port                  = 587;
                    smtpServer.EnableSsl             = m_stServerInfo.GetCurrentSmtp().sslEnable;
                    smtpServer.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtpServer.UseDefaultCredentials = false;
                    smtpServer.Credentials           = new System.Net.NetworkCredential(gmailID,
                                                                                        gmailPwd) as ICredentialsByHost;

                    ServicePointManager.ServerCertificateValidationCallback =
                        delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
                        return(true);
                    };

                    smtpServer.Send(mail);
                    UnityEngine.Debug.Log("send finish");

                    FinalWorking(unreportedMessageBody.Length > 0);
                } catch (Exception ex) {
                    Debug.Log("Can't send crashreporter mail, smtp sending error : " + ex.Message);

                    SmtpMailInfo info = m_stServerInfo.GetCurrentSmtp();
                    if (info != null)
                    {
                        m_stServerInfo.SetNextSmtp();
                        m_bCrashCatched = false;
                        Routine(SendDebugToMail(lastexception, info.userID, info.userPwd));
                    }
                }
            });
        }

        yield return(null);
    }