Skip to content

Commit

Permalink
set Strophe loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Mar 23, 2024
1 parent 6baaad0 commit 508d71e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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, setStropheLogging } 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);
setStropheLogging();
/**
* Triggered once the `Connection` constructor has been initialized, which
* will be responsible for managing the connection to the XMPP server.
Expand Down
8 changes: 4 additions & 4 deletions src/headless/shared/connection/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export function generateResource () {
return `/converse.js-${Math.floor(Math.random() * 139749528).toString()}`;
}

export function setUpXMLLogging (connection) {
export function setStropheLogging () {
const level = settings_api.get('loglevel');
Strophe.setLogLevel(level)

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (90% of all statements in
the enclosing function
have an explicit semicolon).

const lmap = {};
lmap[Strophe.LogLevel.DEBUG] = 'debug';
lmap[Strophe.LogLevel.INFO] = 'info';
Expand All @@ -16,9 +19,6 @@ export function setUpXMLLogging (connection) {

Strophe.log = (level, msg) => log.log(msg, lmap[level]);
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 setStropheLogging(): void;
export function getConnectionServiceURL(): any;
//# sourceMappingURL=utils.d.ts.map

0 comments on commit 508d71e

Please sign in to comment.