Преглед изворни кода

Set Strophe log level

Update strophe.
JC Brand пре 1 година
родитељ
комит
7ccc0fcbb4

+ 3 - 3
package-lock.json

@@ -9288,8 +9288,8 @@
     },
     "node_modules/strophe.js": {
       "version": "2.0.0",
-      "resolved": "git+ssh://git@github.com/strophe/strophejs.git#a02d8932d6d6175a72833f7493b5ca9562438509",
-      "integrity": "sha512-CoezG0Hubhrmp7fKhXdPJ8puhalzjzGcnbo/qfiG/yGsy0uXKlQJd0giS22AchKbqrevgGcGrTZmMXVESXFIwA==",
+      "resolved": "git+ssh://git@github.com/strophe/strophejs.git#d6cb60012fd243a1c3f1033e8acd6c80264d65cf",
+      "integrity": "sha512-sS6LSjZRgagAaa42WMPppxhXEyj/KaY1xoIY5FBz/R4yGq06YjrLfsKGFkBU+FGOe5uG/hbNZCxKrbPzp+gDNg==",
       "license": "MIT",
       "dependencies": {
         "abab": "^2.0.3"
@@ -10383,7 +10383,7 @@
         "pluggable.js": "3.0.1",
         "sizzle": "^2.3.5",
         "sprintf-js": "^1.1.2",
-        "strophe.js": "strophe/strophejs#a02d8932d6d6175a72833f7493b5ca9562438509",
+        "strophe.js": "strophe/strophejs#d6cb60012fd243a1c3f1033e8acd6c80264d65cf",
         "urijs": "^1.19.10"
       },
       "devDependencies": {}

+ 1 - 1
src/headless/package.json

@@ -43,7 +43,7 @@
     "pluggable.js": "3.0.1",
     "sizzle": "^2.3.5",
     "sprintf-js": "^1.1.2",
-    "strophe.js": "strophe/strophejs#a02d8932d6d6175a72833f7493b5ca9562438509",
+    "strophe.js": "strophe/strophejs#d6cb60012fd243a1c3f1033e8acd6c80264d65cf",
     "urijs": "^1.19.10"
   },
   "devDependencies": {}

+ 2 - 2
src/headless/shared/connection/api.js

@@ -2,7 +2,7 @@ import events_api from '../api/events.js';
 import { Connection, MockConnection } from './index.js';
 import { PREBIND } from '../constants.js';
 import { Strophe } from 'strophe.js';
-import { getConnectionServiceURL, setUpXMLLogging } from './utils.js';
+import { getConnectionServiceURL, setStropheLogLevel } from './utils.js';
 import { isSameDomain } from '../../utils/jid.js';
 import { isTestEnv } from '../../utils/session.js';
 import { settings_api } from '../settings/api.js';
@@ -40,7 +40,7 @@ export default {
             })
         );
 
-        setUpXMLLogging(connection);
+        setStropheLogLevel();
         /**
          * Triggered once the `Connection` constructor has been initialized, which
          * will be responsible for managing the connection to the XMPP server.

+ 5 - 5
src/headless/shared/connection/utils.js

@@ -6,7 +6,10 @@ export function generateResource () {
     return `/converse.js-${Math.floor(Math.random() * 139749528).toString()}`;
 }
 
-export function setUpXMLLogging (connection) {
+export function setStropheLogLevel () {
+    const level = settings_api.get('loglevel');
+    Strophe.setLogLevel(Strophe.LogLevel[level.toUpperCase()]);
+
     const lmap = {};
     lmap[Strophe.LogLevel.DEBUG] = 'debug';
     lmap[Strophe.LogLevel.INFO] = 'info';
@@ -14,11 +17,8 @@ export function setUpXMLLogging (connection) {
     lmap[Strophe.LogLevel.ERROR] = 'error';
     lmap[Strophe.LogLevel.FATAL] = 'fatal';
 
-    Strophe.log = (level, msg) => log.log(msg, lmap[level]);
+    Strophe.log = (l, msg) => log.log(msg, lmap[l]);
     Strophe.error = (msg) => log.error(msg);
-
-    connection.xmlInput = (body) => log.debug(body.outerHTML, 'color: darkgoldenrod');
-    connection.xmlOutput = (body) => log.debug(body.outerHTML, 'color: darkcyan');
 }
 
 export function getConnectionServiceURL () {

+ 1 - 1
src/headless/types/shared/connection/utils.d.ts

@@ -1,4 +1,4 @@
 export function generateResource(): string;
-export function setUpXMLLogging(connection: any): void;
+export function setStropheLogLevel(): void;
 export function getConnectionServiceURL(): any;
 //# sourceMappingURL=utils.d.ts.map

+ 0 - 1
src/shared/rich-text.js

@@ -335,7 +335,6 @@ export class RichText extends String {
      * @param { Object } template - The lit TemplateResult instance
      */
     addTemplateResult (begin, end, template) {
-        console.log(`addTemplateResult called with ${begin}, ${end}, ${template}`);
         this.references.push({ begin, end, template });
     }
 

+ 1 - 1
src/shared/tests/mock.js

@@ -696,7 +696,7 @@ async function _initConverse (settings) {
         discover_connection_methods: false,
         enable_smacks: false,
         i18n: 'en',
-        loglevel: window.location.pathname === 'debug.html' ? 'debug' : 'warn',
+        loglevel: window.location.pathname === 'debug.html' ? 'debug' : 'error',
         no_trimming: true,
         persistent_store: 'localStorage',
         play_sounds: false,