Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Jowysama · Feb 03, 2018 at 10:10 PM · crashwwwcrash logloggingtool

Failing to have HandleLog sending crash log to Slack using WWW

So in my work as QA, I've been adding simple tools to capture Error logs picked up during development phase and send it to Slack whenever the app nullrefs on a mobile device (iOS). Bear with me, my coding knowledge is amateurish so if I'm missing something obvious, its simply because I didn't understand it.

The first implementation was straightforward, when the app crashes, it would send a POST message to Slack using Webclient, without need to get a response. This is great when I'm catching a string of logs in which I can see them all in a flow before it crashes:

Example of a message: LogError1 LogError2 LogError3

However, I've been trying challenging myself to improve the way the messages are sent to Slack by editing the same message, meaning, instead of one Slack message per progress sent to Slack, I want to edit and collect all logs in one Slack message.

This means I'm using an IEnumerator with WWW to send and receive the message id (ts). My problem is that when the app in development crashes, it will, instead of sending: LogError1 LogError2 LogError3

It will instead send: LogError1

Then crash. It seems the Handlelog ignores any kind of Coroutine since it will only finish the Handlelog function then crash, so I've been trying to use the www.isDone in a while loop inside Handle Log but for some reason it will get stuck in that while loop after it crashes. Same for using a while loop and counting deltatime (trying to send a message without using Coroutine), or keeping track of number of messages currently being processed and only send a new one if the amount of messages sent is equal to 0.


public static int MessagesInProgress = 0;
    private static string ts = "";
    private static string channel = "";
    private static bool firstResponse = true;
    public static IEnumerator SendCall(WWWForm message, bool threadIt = false){
        Debug.Log("Data being sent "+SlackForm.form.data);
        WWW www;
        if(SlackBot.firstResponse){
            www = new WWW( postMessageUrl, message );
        } else if (!threadIt){
            message.AddField("channel",channel);
            message.AddField("ts",ts);
            www = new WWW( updateMessageUrl, message );
        } else {
            message.AddField("channel",channel);
            message.AddField("ts",ts);
            message.AddField("thread_ts",ts);
            www = new WWW( postMessageUrl, message );            
        }
        yield return www;
        if(!string.IsNullOrEmpty(www.error)) {
            Debug.Log( "Error with Slack: " + www.error );
        } else {
            Debug.Log(www.text);
            if(SlackBot.firstResponse){
                JSONObject json = new JSONObject(www.text);
                channel =  json["channel"].str;
                ts = json["ts"].str;
                SlackBot.firstResponse = false;
            }
        }
    }

 public static void HandleLog(string logString, string stackTrace, LogType type) {
     if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert){
         string msg = "";
         string msgAddOn = "";
         msg += "*" + AppTitle + "* (" + Tools.CommitID() + ") logged this error after "+ LogHandler.ConvertToMinutesAndSeconds(Time.realtimeSinceStartup) + ":\n" + PlaysetPlugin.CurrentScene.Title + " " + deviceGeneration + " " + SystemInfo.operatingSystem + "\n\n" + logString + "\n\n" + stackTrace + msgAddOn;

         LogHandler.PostAndEditSameSlackMessage();
         counter= 50f;
         while(counter>=0){
             Debug.Log("Hej");
         }
     }
 }


    public static void PostAndEditSameSlackMessage(string slackText = ""){
        try {
            if (slackBot == null) {
                slackBot = new SlackBot();
            }
            WWWForm slackMessage;
            slackMessage = null;
            slackMessage = new SlackForm().GetForm();
            SlackForm.AddAttachment(Automation.Instance.tests); 
            slackText += Automation.Instance.GetPrettyTestProgress();
            SlackForm.AddText(slackText+"\n"+GetBasicInfo()+"\n");
Automation.Instance.StartCoroutine(SlackBot.SendCall(slackMessage));
        }
        catch (System.Exception ex) {
            Debug.Log(ex.ToString());
        }
    }
,

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

82 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Where can I find the crash log of my built game or he editor 0 Answers

iPad crashes after many WWW images queries 1 Answer

Crashes inside playloop 0 Answers

WWW.h crash in store build 5 Answers

Why Unity crash every time I exit the play mode ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges