Browse Source

Adds download logs method for debugging.

Adds a download logs method that can be called from console to take usefull messages for debugging.
console> APP.conference.saveLogs();
j8
damencho 8 years ago
parent
commit
bbc7aedb48
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      conference.js

+ 24
- 0
conference.js View File

@@ -711,6 +711,30 @@ export default {
711 711
         return room.getLogs();
712 712
     },
713 713
 
714
+    /**
715
+     * Download logs, a function that can be called from console while
716
+     * debugging.
717
+     * @param filename (optional) specify target filename
718
+     */
719
+    saveLogs (filename = 'meetlog.json') {
720
+        // this can be called from console and will not have reference to this
721
+        // that's why we reference the global var
722
+        let logs = APP.conference.getLogs();
723
+        let data = encodeURIComponent(JSON.stringify(logs, null, '  '));
724
+
725
+        let elem = document.createElement('a');
726
+
727
+        elem.download = filename;
728
+        elem.href = 'data:application/json;charset=utf-8,\n' + data;
729
+        elem.dataset.downloadurl
730
+            = ['text/json', elem.download, elem.href].join(':');
731
+        elem.dispatchEvent(new MouseEvent('click', {
732
+            view: window,
733
+            bubbles: true,
734
+            cancelable: false
735
+        }));
736
+    },
737
+
714 738
     /**
715 739
      * Exposes a Command(s) API on this instance. It is necessitated by (1) the
716 740
      * desire to keep room private to this instance and (2) the need of other

Loading…
Cancel
Save