Skip to content

Commit

Permalink
Set Strophe log level
Browse files Browse the repository at this point in the history
Update strophe.
  • Loading branch information
jcbrand committed Mar 24, 2024
1 parent ec93d85 commit 3a4810b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
Expand Down
4 changes: 2 additions & 2 deletions src/headless/shared/connection/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/headless/shared/connection/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ 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';
lmap[Strophe.LogLevel.WARN] = 'warn';
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 () {
Expand Down
2 changes: 1 addition & 1 deletion src/headless/types/shared/connection/utils.d.ts
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion src/shared/rich-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/tests/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3a4810b

Please sign in to comment.