diff --git a/shared/js/ConnectionHandler.ts b/shared/js/ConnectionHandler.ts index 1b5ecb16..85c0ccc7 100644 --- a/shared/js/ConnectionHandler.ts +++ b/shared/js/ConnectionHandler.ts @@ -4,8 +4,7 @@ import {GroupManager} from "./permission/GroupManager"; import {ServerSettings, Settings, settings, StaticSettings} from "./settings"; import {Sound, SoundManager} from "./sound/Sounds"; import {ConnectionProfile} from "./profiles/ConnectionProfile"; -import * as log from "./log"; -import {LogCategory, logError, logInfo, logWarn} from "./log"; +import {LogCategory, logError, logInfo, logTrace, logWarn} from "./log"; import {createErrorModal, createInfoModal, createInputModal, Modal} from "./ui/elements/Modal"; import {hashPassword} from "./utils/helpers"; import {HandshakeHandler} from "./connection/HandshakeHandler"; @@ -375,7 +374,7 @@ export class ConnectionHandler { try { await this.serverConnection.disconnect(); } catch (error) { - log.warn(LogCategory.CLIENT, tr("Failed to successfully disconnect from server: {}"), error); + logWarn(LogCategory.CLIENT, tr("Failed to successfully disconnect from server: {}"), error); } this.sound.play(Sound.CONNECTION_DISCONNECTED); this.log.log("disconnected", {}); @@ -525,7 +524,7 @@ export class ConnectionHandler { } break; case DisconnectReason.DNS_FAILED: - log.error(LogCategory.CLIENT, tr("Failed to resolve hostname: %o"), data); + logError(LogCategory.CLIENT, tr("Failed to resolve hostname: %o"), data); this.log.log("connection.hostname.resolve.error", { message: data as any }); @@ -538,9 +537,9 @@ export class ConnectionHandler { } if(data) { - log.error(LogCategory.CLIENT, tr("Could not connect to remote host! Extra data: %o"), data); + logError(LogCategory.CLIENT, tr("Could not connect to remote host! Extra data: %o"), data); } else { - log.error(LogCategory.CLIENT, tr("Could not connect to remote host!"), data); + logError(LogCategory.CLIENT, tr("Could not connect to remote host!"), data); } if(__build.target === "client" || !dns.resolve_address_ipv4) { @@ -583,7 +582,7 @@ export class ConnectionHandler { break; case DisconnectReason.HANDSHAKE_FAILED: //TODO sound - log.error(LogCategory.CLIENT, tr("Failed to process handshake: %o"), data); + logError(LogCategory.CLIENT, tr("Failed to process handshake: %o"), data); createErrorModal( tr("Could not connect"), tr("Failed to process handshake: ") + data as string @@ -607,7 +606,7 @@ export class ConnectionHandler { autoReconnect = false; break; case DisconnectReason.CONNECTION_CLOSED: - log.error(LogCategory.CLIENT, tr("Lost connection to remote server!")); + logError(LogCategory.CLIENT, tr("Lost connection to remote server!")); if(!this.autoReconnectAttempt) { createErrorModal( tr("Connection closed"), @@ -619,7 +618,7 @@ export class ConnectionHandler { autoReconnect = true; break; case DisconnectReason.CONNECTION_PING_TIMEOUT: - log.error(LogCategory.CLIENT, tr("Connection ping timeout")); + logError(LogCategory.CLIENT, tr("Connection ping timeout")); this.sound.play(Sound.CONNECTION_DISCONNECTED_TIMEOUT); createErrorModal( tr("Connection lost"), @@ -699,8 +698,8 @@ export class ConnectionHandler { this.sound.play(Sound.CONNECTION_BANNED); break; default: - log.error(LogCategory.CLIENT, tr("Got uncaught disconnect!")); - log.error(LogCategory.CLIENT, tr("Type: %o Data: %o"), type, data); + logError(LogCategory.CLIENT, tr("Got uncaught disconnect!")); + logError(LogCategory.CLIENT, tr("Type: %o Data: %o"), type, data); break; } @@ -747,7 +746,7 @@ export class ConnectionHandler { } private on_connection_state_changed(old_state: ConnectionState, new_state: ConnectionState) { - console.log("From %s to %s", ConnectionState[old_state], ConnectionState[new_state]); + logTrace(LogCategory.CLIENT, tr("From %s to %s"), ConnectionState[old_state], ConnectionState[new_state]); this.events_.fire("notify_connection_state_changed", { oldState: old_state, newState: new_state @@ -834,7 +833,7 @@ export class ConnectionHandler { this.clientStatusSync = true; this.serverConnection.send_command("clientupdate", localClientUpdates).catch(error => { - log.warn(LogCategory.GENERAL, tr("Failed to update client audio hardware properties. Error: %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to update client audio hardware properties. Error: %o"), error); this.log.log("error.custom", { message: tr("Failed to update audio hardware properties.") }); this.clientStatusSync = false; }); @@ -880,7 +879,7 @@ export class ConnectionHandler { //client_input_hardware: this.client_status.sound_record_supported && this.getInputHardwareState() === InputHardwareState.VALID, //client_output_hardware: this.client_status.sound_playback_supported }).catch(error => { - log.warn(LogCategory.GENERAL, tr("Failed to sync handler state with server. Error: %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to sync handler state with server. Error: %o"), error); this.log.log("error.custom", {message: tr("Failed to sync handler state with server.")}); }); } @@ -990,7 +989,7 @@ export class ConnectionHandler { }).then(() => { createInfoModal(tr("Avatar deleted"), tr("Avatar successfully deleted")).open(); }).catch(error => { - log.error(LogCategory.GENERAL, tr("Failed to reset avatar flag: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to reset avatar flag: %o"), error); let message; if(error instanceof CommandResult) { @@ -1021,7 +1020,7 @@ export class ConnectionHandler { if(transfer.transferState() !== FileTransferState.FINISHED) { if(transfer.transferState() === FileTransferState.ERRORED) { - log.warn(LogCategory.FILE_TRANSFER, tr("Failed to upload clients avatar: %o"), transfer.currentError()); + logWarn(LogCategory.FILE_TRANSFER, tr("Failed to upload clients avatar: %o"), transfer.currentError()); createErrorModal(tr("Failed to upload avatar"), traj("Failed to upload avatar:{:br:}{0}", transfer.currentErrorMessage())).open(); return; } else if(transfer.transferState() === FileTransferState.CANCELED) { @@ -1038,7 +1037,7 @@ export class ConnectionHandler { client_flag_avatar: md5(new Uint8Array(data)) }); } catch(error) { - log.error(LogCategory.GENERAL, tr("Failed to update avatar flag: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to update avatar flag: %o"), error); let message; if(error instanceof CommandResult) @@ -1217,7 +1216,7 @@ export class ConnectionHandler { client_away: typeof(this.client_status.away) === "string" || this.client_status.away, client_away_message: typeof(this.client_status.away) === "string" ? this.client_status.away : "", }).catch(error => { - log.warn(LogCategory.GENERAL, tr("Failed to update away status. Error: %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to update away status. Error: %o"), error); this.log.log("error.custom", {message: tr("Failed to update away status.")}); }); diff --git a/shared/js/KeyControl.ts b/shared/js/KeyControl.ts index cea12bab..41d672a2 100644 --- a/shared/js/KeyControl.ts +++ b/shared/js/KeyControl.ts @@ -1,6 +1,6 @@ import * as ppt from "tc-backend/ppt"; import * as log from "./log"; -import {LogCategory, logWarn} from "./log"; +import {LogCategory, logError, logWarn} from "./log"; import {KeyDescriptor, KeyHook} from "./PPTListener"; import {Settings, settings} from "./settings"; import {server_connections} from "tc-shared/ConnectionManager"; @@ -137,7 +137,7 @@ export function initializeKeyControl() { try { cfg = JSON.parse(settings.getValue(Settings.KEY_KEYCONTROL_DATA)); } catch (e) { - log.error(LogCategory.GENERAL, tr("Failed to parse old key control data.")); + logError(LogCategory.GENERAL, tr("Failed to parse old key control data.")); cfg = {}; } diff --git a/shared/js/bookmarks.ts b/shared/js/bookmarks.ts index fa9a36f9..8ea86eb6 100644 --- a/shared/js/bookmarks.ts +++ b/shared/js/bookmarks.ts @@ -1,5 +1,4 @@ -import * as log from "./log"; -import {LogCategory} from "./log"; +import {LogCategory, logError} from "./log"; import {guid} from "./crypto/uid"; import {createErrorModal, createInfoModal, createInputModal} from "./ui/elements/Modal"; import {defaultConnectProfile, findConnectProfile} from "./profiles/ConnectionProfile"; @@ -99,7 +98,7 @@ function bookmark_config() : BookmarkConfig { try { bookmarks = JSON.parse(bookmark_json) || {} as BookmarkConfig; } catch(error) { - log.error(LogCategory.BOOKMARKS, tr("Failed to load bookmarks: %o"), error); + logError(LogCategory.BOOKMARKS, tr("Failed to load bookmarks: %o"), error); bookmarks = {} as any; } diff --git a/shared/js/connection/AbstractCommandHandler.ts b/shared/js/connection/AbstractCommandHandler.ts index 37204c06..2cf484e4 100644 --- a/shared/js/connection/AbstractCommandHandler.ts +++ b/shared/js/connection/AbstractCommandHandler.ts @@ -1,9 +1,6 @@ -import { - AbstractServerConnection, - ServerCommand, - SingleCommandHandler -} from "../connection/ConnectionBase"; +import {AbstractServerConnection, ServerCommand, SingleCommandHandler} from "../connection/ConnectionBase"; import {tr} from "../i18n/localize"; +import {LogCategory, logError, logWarn} from "tc-shared/log"; export abstract class AbstractCommandHandler { readonly connection: AbstractServerConnection; @@ -67,7 +64,7 @@ export abstract class AbstractCommandHandlerBoss { unregister_handler(handler: AbstractCommandHandler) { if(!handler.volatile_handler_boss && handler.handler_boss !== this) { - console.warn(tr("Tried to unregister command handler which does not belong to the handler boss")); + logWarn(LogCategory.NETWORKING, tr("Tried to unregister command handler which does not belong to the handler boss")); return; } @@ -98,7 +95,7 @@ export abstract class AbstractCommandHandlerBoss { if(!flag_consumed || handler.ignore_consumed) flag_consumed = handler.handle_command(command) || flag_consumed; } catch(error) { - console.error(tr("Failed to invoke command handler. Invocation results in an exception: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to invoke command handler. Invocation results in an exception: %o"), error); } } @@ -108,7 +105,7 @@ export abstract class AbstractCommandHandlerBoss { try { flag_consumed = handler(command, flag_consumed) || flag_consumed; } catch(error) { - console.error(tr("Failed to invoke command handler. Invocation results in an exception: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to invoke command handler. Invocation results in an exception: %o"), error); } } } @@ -122,7 +119,7 @@ export abstract class AbstractCommandHandlerBoss { if(handler.function(command)) this.single_command_handler.remove(handler); } catch(error) { - console.error(tr("Failed to invoke single command handler. Invocation results in an exception: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to invoke single command handler. Invocation results in an exception: %o"), error); } } diff --git a/shared/js/connection/CommandHandler.ts b/shared/js/connection/CommandHandler.ts index 4870a08b..66a05dfc 100644 --- a/shared/js/connection/CommandHandler.ts +++ b/shared/js/connection/CommandHandler.ts @@ -1,5 +1,4 @@ -import * as log from "../log"; -import {LogCategory, logError, logWarn} from "../log"; +import {LogCategory, logError, logInfo, logWarn} from "../log"; import {AbstractServerConnection, CommandOptions, ServerCommand} from "../connection/ConnectionBase"; import {Sound} from "../sound/Sounds"; import {CommandResult} from "../connection/ServerConnectionDeclaration"; @@ -125,7 +124,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { } else if(typeof(ex) === "string") { this.connection_handler.log.log("connection.command.error", {error: ex}); } else { - log.error(LogCategory.NETWORKING, tr("Invalid promise result type: %s. Result: %o"), typeof (ex), ex); + logError(LogCategory.NETWORKING, tr("Invalid promise result type: %s. Result: %o"), typeof (ex), ex); } } @@ -160,7 +159,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { handleCommandResult(json) { let code : string = json[0]["return_code"]; if(!code || code.length == 0) { - log.warn(LogCategory.NETWORKING, tr("Invalid return code! (%o)"), json); + logWarn(LogCategory.NETWORKING, tr("Invalid return code! (%o)"), json); return; } let retListeners = this.connection["_retListener"] || this.connection["returnListeners"]; @@ -278,7 +277,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { const client = this.connection_handler.channelTree.findClient(parseInt(json["clid"])); if(!client) { - log.warn(LogCategory.NETWORKING, tr("Received client connection info for unknown client (%o)"), json["clid"]); + logWarn(LogCategory.NETWORKING, tr("Received client connection info for unknown client (%o)"), json["clid"]); return; } @@ -410,7 +409,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let playSound = false; - log.info(LogCategory.NETWORKING, tr("Got %d channel deletions"), json.length); + logInfo(LogCategory.NETWORKING, tr("Got %d channel deletions"), json.length); for(let index = 0; index < json.length; index++) { conversations.destroyConversation(parseInt(json[index]["cid"])); let channel = tree.findChannel(json[index]["cid"]); @@ -442,7 +441,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { handleCommandChannelHide(json) { let tree = this.connection.client.channelTree; - log.info(LogCategory.NETWORKING, tr("Got %d channel hides"), json.length); + logInfo(LogCategory.NETWORKING, tr("Got %d channel hides"), json.length); for(let index = 0; index < json.length; index++) { let channel = tree.findChannel(json[index]["cid"]); if(!channel) { @@ -471,6 +470,12 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { for(const entry of json) { /* attempt to update properties if given */ channel = typeof(entry["ctid"]) !== "undefined" ? tree.findChannel(parseInt(entry["ctid"])) : channel; + if(!channel) { + /* TODO: Close the connection */ + logError(LogCategory.NETWORKING, tr("Received client enter view for invalid target channel: %o"), entry["ctid"]); + continue; + } + old_channel = typeof(entry["cfid"]) !== "undefined" ? tree.findChannel(parseInt(entry["cfid"])) : old_channel; reasonId = typeof(entry["reasonid"]) !== "undefined" ? entry["reasonid"] : reasonId; reasonMsg = typeof(entry["reason_msg"]) !== "undefined" ? entry["reason_msg"] : reasonMsg; @@ -522,7 +527,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { } else if(reasonId == ViewReasonId.VREASON_SYSTEM) { } else { - console.warn(tr("Unknown reasonid for %o"), reasonId); + logWarn(LogCategory.NETWORKING, tr("Unknown reasonid for %o"), reasonId); } } @@ -560,7 +565,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let tree = this.connection.client.channelTree; let client = tree.findClient(entry["clid"]); if(!client) { - log.error(LogCategory.NETWORKING, tr("Unknown client left!")); + logError(LogCategory.NETWORKING, tr("Unknown client left!")); return 0; } if(client == this.connection.client.getClient()) { @@ -611,7 +616,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { } else if(reason_id == ViewReasonId.VREASON_MOVED) { this.connection_handler.sound.play(Sound.USER_LEFT_MOVED); } else { - log.error(LogCategory.NETWORKING, tr("Unknown client left reason %d!"), reason_id); + logError(LogCategory.NETWORKING, tr("Unknown client left reason %d!"), reason_id); } } } @@ -630,21 +635,21 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let channelFrom = tree.findChannel(parseInt(json["cfid"])); if(!client) { - log.error(LogCategory.NETWORKING, tr("Unknown client move (Client)!")); + logError(LogCategory.NETWORKING, tr("Unknown client move (Client)!")); return 0; } if(!channel_to) { - log.error(LogCategory.NETWORKING, tr("Unknown client move (Channel to)!")); + logError(LogCategory.NETWORKING, tr("Unknown client move (Channel to)!")); return 0; } if(!self) { if(!channelFrom) { - log.error(LogCategory.NETWORKING, tr("Unknown client move (Channel from)!")); + logError(LogCategory.NETWORKING, tr("Unknown client move (Channel from)!")); channelFrom = client.currentChannel(); } else if(channelFrom != client.currentChannel()) { - log.error(LogCategory.NETWORKING, + logError(LogCategory.NETWORKING, tr("Client move from invalid source channel! Local client registered in channel %d but server send %d."), client.currentChannel().channelId, channelFrom.channelId ); @@ -713,7 +718,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { else if(own_channel == channelFrom) this.connection_handler.sound.play(Sound.USER_LEFT_KICKED_CHANNEL); } else { - console.warn(tr("Unknown reason id %o"), json["reasonid"]); + logWarn(LogCategory.NETWORKING, tr("Unknown reason id %o"), json["reasonid"]); } } @@ -723,19 +728,19 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let tree = this.connection.client.channelTree; let channel = tree.findChannel(json["cid"]); if(!channel) { - log.error(LogCategory.NETWORKING, tr("Unknown channel move (Channel)!")); + logError(LogCategory.NETWORKING, tr("Unknown channel move (Channel)!")); return 0; } let prev = tree.findChannel(json["order"]); if(!prev && json["order"] != 0) { - log.error(LogCategory.NETWORKING, tr("Unknown channel move (prev)!")); + logError(LogCategory.NETWORKING, tr("Unknown channel move (prev)!")); return 0; } let parent = tree.findChannel(json["cpid"]); if(!parent && json["cpid"] != 0) { - log.error(LogCategory.NETWORKING, tr("Unknown channel move (parent)!")); + logError(LogCategory.NETWORKING, tr("Unknown channel move (parent)!")); return 0; } @@ -748,7 +753,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let tree = this.connection.client.channelTree; let channel = tree.findChannel(json["cid"]); if(!channel) { - log.error(LogCategory.NETWORKING, tr("Unknown channel edit (Channel)!")); + logError(LogCategory.NETWORKING, tr("Unknown channel edit (Channel)!")); return 0; } @@ -797,7 +802,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { const targetIsOwn = targetClientEntry instanceof LocalClientEntry; if(targetIsOwn && targetClientId === invokerClientId) { - log.error(LogCategory.NETWORKING, tr("Received conversation message from our self. This should be impossible."), json); + logError(LogCategory.NETWORKING, tr("Received conversation message from our self. This should be impossible."), json); return; } @@ -899,7 +904,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { const conversationManager = this.connection_handler.getPrivateConversations(); const conversation = conversationManager.findConversation(json["cluid"]); if(!conversation) { - log.warn(LogCategory.GENERAL, tr("Received chat close for client, but we haven't a chat open.")); + logWarn(LogCategory.GENERAL, tr("Received chat close for client, but we haven't a chat open.")); return; } @@ -911,7 +916,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let client = this.connection.client.channelTree.findClient(json["clid"]); if(!client) { - log.error(LogCategory.NETWORKING, tr("Tried to update an non existing client")); + logError(LogCategory.NETWORKING, tr("Tried to update an non existing client")); return; } @@ -968,7 +973,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { let bot = this.connection.client.channelTree.find_client_by_dbid(json["bot_id"]); if(!bot || !(bot instanceof MusicClientEntry)) { - log.warn(LogCategory.CLIENT, tr("Got music player info for unknown or invalid bot! (ID: %i, Entry: %o)"), json["bot_id"], bot); + logWarn(LogCategory.CLIENT, tr("Got music player info for unknown or invalid bot! (ID: %i, Entry: %o)"), json["bot_id"], bot); return; } @@ -1026,7 +1031,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { for(const entry of json) { const channel = this.connection.client.channelTree.findChannel(parseInt(entry["cid"])); if(!channel) { - console.warn(tr("Received channel subscribed for not visible channel (cid: %d)"), entry['cid']); + logWarn(LogCategory.NETWORKING, tr("Received channel subscribed for not visible channel (cid: %o)"), entry["cid"]); continue; } @@ -1041,7 +1046,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { for(const entry of json) { const channel = this.connection.client.channelTree.findChannel(entry["cid"]); if(!channel) { - console.warn(tr("Received channel unsubscribed for not visible channel (cid: %d)"), entry['cid']); + logWarn(LogCategory.NETWORKING, tr("Received channel unsubscribed for not visible channel (cid: %o)"), entry["cid"]); continue; } @@ -1058,7 +1063,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { const bot_id = parseInt(json["bot_id"]); const client = this.connection.client.channelTree.find_client_by_dbid(bot_id); if(!client || !(client instanceof MusicClientEntry)) { - log.warn(LogCategory.CLIENT, tr("Received music bot status update for unknown bot (%d)"), bot_id); + logWarn(LogCategory.CLIENT, tr("Received music bot status update for unknown bot (%d)"), bot_id); return; } @@ -1074,7 +1079,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler { const bot_id = parseInt(json["bot_id"]); const client = this.connection.client.channelTree.find_client_by_dbid(bot_id); if(!client || !(client instanceof MusicClientEntry)) { - log.warn(LogCategory.CLIENT, tr("Received music bot status update for unknown bot (%d)"), bot_id); + logWarn(LogCategory.CLIENT, tr("Received music bot status update for unknown bot (%d)"), bot_id); return; } diff --git a/shared/js/connection/CommandHelper.ts b/shared/js/connection/CommandHelper.ts index 39cf6ec9..e29db03c 100644 --- a/shared/js/connection/CommandHelper.ts +++ b/shared/js/connection/CommandHelper.ts @@ -1,6 +1,5 @@ import {ServerCommand, SingleCommandHandler} from "../connection/ConnectionBase"; -import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logError} from "../log"; import { ClientNameInfo, CommandResult, @@ -221,7 +220,7 @@ export class CommandHelper extends AbstractCommandHandler { needed_power_song_remove: parseInt(entry["needed_power_song_remove"]) }); } catch(error) { - log.error(LogCategory.NETWORKING, tr("Failed to parse playlist entry: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to parse playlist entry: %o"), error); } } @@ -281,7 +280,7 @@ export class CommandHelper extends AbstractCommandHandler { song_metadata: entry["song_metadata"] }); } catch(error) { - log.error(LogCategory.NETWORKING, tr("Failed to parse playlist song entry: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to parse playlist song entry: %o"), error); } } @@ -319,7 +318,7 @@ export class CommandHelper extends AbstractCommandHandler { const json = command.arguments; if(json[0]["playlist_id"] != playlist_id) { - log.error(LogCategory.NETWORKING, tr("Received invalid notification for playlist clients")); + logError(LogCategory.NETWORKING, tr("Received invalid notification for playlist clients")); return false; } @@ -355,7 +354,7 @@ export class CommandHelper extends AbstractCommandHandler { command: "notifyservergroupclientlist", function: command => { if (command.arguments[0]["sgid"] != group_id) { - log.error(LogCategory.NETWORKING, tr("Received invalid notification for server group client list")); + logError(LogCategory.NETWORKING, tr("Received invalid notification for server group client list")); return false; } @@ -372,7 +371,7 @@ export class CommandHelper extends AbstractCommandHandler { } resolve(result); } catch (error) { - log.error(LogCategory.NETWORKING, tr("Failed to parse server group client list: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to parse server group client list: %o"), error); reject("failed to parse info"); } @@ -394,7 +393,7 @@ export class CommandHelper extends AbstractCommandHandler { function: command => { const json = command.arguments[0]; if (json["playlist_id"] != playlist_id) { - log.error(LogCategory.NETWORKING, tr("Received invalid notification for playlist info")); + logError(LogCategory.NETWORKING, tr("Received invalid notification for playlist info")); return; } @@ -416,7 +415,7 @@ export class CommandHelper extends AbstractCommandHandler { playlist_max_songs: parseInt(json["playlist_max_songs"]) }); } catch (error) { - log.error(LogCategory.NETWORKING, tr("Failed to parse playlist info: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to parse playlist info: %o"), error); reject("failed to parse info"); } diff --git a/shared/js/connection/rtc/Connection.ts b/shared/js/connection/rtc/Connection.ts index eb524239..ed9775b2 100644 --- a/shared/js/connection/rtc/Connection.ts +++ b/shared/js/connection/rtc/Connection.ts @@ -1,7 +1,6 @@ import {AbstractServerConnection, ServerCommand, ServerConnectionEvents} from "tc-shared/connection/ConnectionBase"; import {ConnectionState} from "tc-shared/ConnectionHandler"; -import * as log from "tc-shared/log"; -import {group, LogCategory, logDebug, logError, logGroupNative, logTrace, LogType, logWarn} from "tc-shared/log"; +import {LogCategory, logDebug, logError, logGroupNative, logTrace, LogType, logWarn} from "tc-shared/log"; import {AbstractCommandHandler} from "tc-shared/connection/AbstractCommandHandler"; import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration"; import {tr, tra} from "tc-shared/i18n/localize"; @@ -307,8 +306,6 @@ class CommandHandler extends AbstractCommandHandler { } else { logWarn(LogCategory.WEBRTC, tr("Received unknown/invalid rtc track state: %d"), state); } - } else if(command.command === "notifybroadcastvideo") { - /* FIXME: TODO! */ } return false; } @@ -920,9 +917,6 @@ export class RTCConnection { this.peer.ondatachannel = event => this.handleDataChannel(event.channel); this.peer.ontrack = event => this.handleTrack(event); - /* FIXME: Remove this debug! */ - (window as any).rtp = this; - this.updateConnectionState(RTPConnectionState.CONNECTING); this.doInitialSetup0().catch(error => { this.handleFatalError(tr("initial setup failed"), true); @@ -959,7 +953,7 @@ export class RTCConnection { /* Firefox has some crazy issues */ if(window.detectedBrowser.name !== "firefox") { if(target) { - console.error("Setting sendrecv from %o", this.currentTransceiver[type].direction, this.currentTransceiver[type].currentDirection); + logTrace(LogCategory.NETWORKING, "Setting sendrecv from %o", this.currentTransceiver[type].direction, this.currentTransceiver[type].currentDirection); this.currentTransceiver[type].direction = "sendrecv"; } else if(type === "video" || type === "video-screen") { /* @@ -1046,7 +1040,6 @@ export class RTCConnection { private handleLocalIceCandidate(candidate: RTCIceCandidate | undefined) { if(candidate) { - console.error(candidate.candidate); if(candidate.address?.endsWith(".local")) { logTrace(LogCategory.WEBRTC, tr("Skipping local fqdn ICE candidate %s"), candidate.toJSON().candidate); return; @@ -1109,18 +1102,18 @@ export class RTCConnection { private handleIceCandidateError(event: RTCPeerConnectionIceErrorEvent) { if(this.peer.iceGatheringState === "gathering") { - log.warn(LogCategory.WEBRTC, tr("Received error while gathering the ice candidates: %d/%s for %s (url: %s)"), + logWarn(LogCategory.WEBRTC, tr("Received error while gathering the ice candidates: %d/%s for %s (url: %s)"), event.errorCode, event.errorText, event.hostCandidate, event.url); } else { - log.trace(LogCategory.WEBRTC, tr("Ice candidate %s (%s) errored: %d/%s"), + logTrace(LogCategory.WEBRTC, tr("Ice candidate %s (%s) errored: %d/%s"), event.url, event.hostCandidate, event.errorCode, event.errorText); } } private handleIceConnectionStateChanged() { - log.trace(LogCategory.WEBRTC, tr("ICE connection state changed to %s"), this.peer.iceConnectionState); + logTrace(LogCategory.WEBRTC, tr("ICE connection state changed to %s"), this.peer.iceConnectionState); } private handleIceGatheringStateChanged() { - log.trace(LogCategory.WEBRTC, tr("ICE gathering state changed to %s"), this.peer.iceGatheringState); + logTrace(LogCategory.WEBRTC, tr("ICE gathering state changed to %s"), this.peer.iceGatheringState); } private handleSignallingStateChanged() { diff --git a/shared/js/connection/rtc/Negotiation.ts b/shared/js/connection/rtc/Negotiation.ts index dcad7be3..0a247789 100644 --- a/shared/js/connection/rtc/Negotiation.ts +++ b/shared/js/connection/rtc/Negotiation.ts @@ -218,7 +218,6 @@ function generateSdp(session: RTCNegotiationMessage) { generateMedia(session.ssrc[index], flags); } - console.error(JSON.stringify(session)); return sdpTransform.write(sdp); } @@ -243,7 +242,7 @@ export class RTCNegotiator { } } -/* FIXME: mozilla...THIS_IS_SDPARTA-82.0.3 (Needs to be parsed from the offer) */ +/* TODO: mozilla...THIS_IS_SDPARTA-82.0.3 (Needs to be parsed from the offer) */ /* console.error("XYX\n%s", generateSdp({ diff --git a/shared/js/connection/rtc/RemoteTrack.ts b/shared/js/connection/rtc/RemoteTrack.ts index 38500fe0..3d29c3b6 100644 --- a/shared/js/connection/rtc/RemoteTrack.ts +++ b/shared/js/connection/rtc/RemoteTrack.ts @@ -1,5 +1,5 @@ import {Registry} from "tc-shared/events"; -import {LogCategory, logWarn} from "tc-shared/log"; +import {LogCategory, logTrace, logWarn} from "tc-shared/log"; import {tr} from "tc-shared/i18n/localize"; import {globalAudioContext, on_ready} from "tc-backend/audio/player"; @@ -104,10 +104,10 @@ export class RemoteRTPVideoTrack extends RemoteRTPTrack { this.mediaStream.addTrack(transceiver.receiver.track); const track = transceiver.receiver.track; - track.onended = () => console.error("TRACK %d ended", ssrc); - track.onmute = () => console.error("TRACK %d muted", ssrc); - track.onunmute = () => console.error("TRACK %d unmuted", ssrc); - track.onisolationchange = () => console.error("TRACK %d onisolationchange", ssrc); + track.onended = () => logTrace(LogCategory.VIDEO, "Track %d ended", ssrc); + track.onmute = () => logTrace(LogCategory.VIDEO, "Track %d muted", ssrc); + track.onunmute = () => logTrace(LogCategory.VIDEO, "Track %d unmuted", ssrc); + track.onisolationchange = () => logTrace(LogCategory.VIDEO, "Track %d isolation changed", ssrc); } getMediaStream() : MediaStream { diff --git a/shared/js/connection/rtc/video/Connection.ts b/shared/js/connection/rtc/video/Connection.ts index 261239ea..1305551a 100644 --- a/shared/js/connection/rtc/video/Connection.ts +++ b/shared/js/connection/rtc/video/Connection.ts @@ -1,8 +1,8 @@ import { - VideoBroadcastConfig, LocalVideoBroadcast, LocalVideoBroadcastEvents, LocalVideoBroadcastState, + VideoBroadcastConfig, VideoBroadcastStatistics, VideoBroadcastType, VideoClient, @@ -13,7 +13,7 @@ import { import {Registry} from "tc-shared/events"; import {VideoSource} from "tc-shared/video/VideoSource"; import {RTCBroadcastableTrackType, RTCConnection, RTCConnectionEvents, RTPConnectionState} from "../Connection"; -import {LogCategory, logError, logWarn} from "tc-shared/log"; +import {LogCategory, logError, logTrace, logWarn} from "tc-shared/log"; import {Settings, settings} from "tc-shared/settings"; import {RtpVideoClient} from "./VideoClient"; import {tr} from "tc-shared/i18n/localize"; @@ -77,7 +77,7 @@ class LocalRtpVideoBroadcast implements LocalVideoBroadcast { let sourceRef = source.ref(); try { if(this.currentSource !== source) { - console.error("Source changed"); + logTrace(LogCategory.VIDEO, tr("Video broadcast %s source changed"), this.type); const videoTracks = source.getStream().getVideoTracks(); if(videoTracks.length === 0) { throw tr("missing video stream track"); @@ -110,7 +110,7 @@ class LocalRtpVideoBroadcast implements LocalVideoBroadcast { this.setCurrentSource(sourceRef); } else if(!_.isEqual(this.currentConfig, constraints)) { - console.error("Constraints changed"); + logTrace(LogCategory.VIDEO, tr("Video broadcast %s constraints changed"), this.type); await this.applyConstraints(constraints); } } finally { diff --git a/shared/js/connectionlog/DispatcherNotifications.ts b/shared/js/connectionlog/DispatcherNotifications.ts index a9b5f396..a75fa527 100644 --- a/shared/js/connectionlog/DispatcherNotifications.ts +++ b/shared/js/connectionlog/DispatcherNotifications.ts @@ -2,14 +2,14 @@ import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {server_connections} from "tc-shared/ConnectionManager"; import {getIconManager} from "tc-shared/file/Icons"; -import { tra, tr } from "tc-shared/i18n/localize"; +import {tr, tra} from "tc-shared/i18n/localize"; import {EventClient, EventServerAddress, EventType, TypeInfo} from "tc-shared/connectionlog/Definitions"; import {Settings, settings} from "tc-shared/settings"; import {format_time} from "tc-shared/ui/frames/chat"; import {ViewReasonId} from "tc-shared/ConnectionHandler"; import {formatDate} from "tc-shared/MessageFormatter"; import {renderBBCodeAsText} from "tc-shared/text/bbcode"; -import {LogCategory, logInfo} from "tc-shared/log"; +import {LogCategory, logInfo, logTrace} from "tc-shared/log"; export type DispatcherLog = (data: TypeInfo[T], handlerId: string, eventType: T) => void; @@ -77,7 +77,7 @@ function spawnNotification(title: string, options: NotificationOptions) { try { new Notification(title, options); } catch (error) { - console.error(error); + logTrace(LogCategory.GENERAL, tr("Failed to spawn notification: %o"), error); } } } diff --git a/shared/js/conversations/PrivateConversationHistory.ts b/shared/js/conversations/PrivateConversationHistory.ts index 7f2349c4..1d26db4a 100644 --- a/shared/js/conversations/PrivateConversationHistory.ts +++ b/shared/js/conversations/PrivateConversationHistory.ts @@ -1,6 +1,6 @@ import * as loader from "tc-loader"; import {Stage} from "tc-loader"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; import {LogCategory, logDebug, logError, logInfo, logWarn} from "tc-shared/log"; import {ChatEvent} from "../ui/frames/side/AbstractConversationDefinitions"; @@ -176,7 +176,7 @@ async function doOpenDatabase(forceUpgrade: boolean) { }; openRequest.onerror = () => { - console.error("Private conversation history opening error: %o", openRequest.error); + logWarn(LogCategory.CHAT, tr("Private conversation history opening error: %o"), openRequest.error); reject(openRequest.error.message); }; diff --git a/shared/js/events.ts b/shared/js/events.ts index 6af8c8ef..b9d6dbe8 100644 --- a/shared/js/events.ts +++ b/shared/js/events.ts @@ -1,5 +1,4 @@ -import * as log from "./log"; -import {LogCategory} from "./log"; +import {LogCategory, logTrace, logWarn} from "./log"; import {guid} from "./crypto/uid"; import * as React from "react"; import {useEffect} from "react"; @@ -181,7 +180,7 @@ export class Registry(event_type: T, data?: Events[T], overrideTypeKey?: boolean) { if(this.debugPrefix) - log.trace(LogCategory.EVENT_REGISTRY, tr("[%s] Trigger event: %s"), this.debugPrefix, event_type); + logTrace(LogCategory.EVENT_REGISTRY, tr("[%s] Trigger event: %s"), this.debugPrefix, event_type); if(typeof data === "object" && 'type' in data && !overrideTypeKey) { if((data as any).type !== event_type) { @@ -222,7 +221,7 @@ export class Registry) event_registry.on("action_open_window", event => { const handle_import_error = error => { - console.error("Failed to import script: %o", error); + logError(LogCategory.GENERAL, tr("Failed to import script: %o"), error); createErrorModal(tr("Failed to load window"), tr("Failed to load the bookmark window.\nSee the console for more details.")).open(); }; @@ -136,7 +136,6 @@ export function initialize(event_registry: Registry) }).then(() => { createInfoModal(tr("Use token"), tr("Toke successfully used!")).open(); }).catch(error => { - //TODO tr createErrorModal(tr("Use token"), formatMessage(tr("Failed to use token: {}"), error instanceof CommandResult ? error.message : error)).open(); }); }).open(); @@ -166,7 +165,7 @@ export function initialize(event_registry: Registry) break; default: - console.warn(tr("Received open window event for an unknown window: %s"), event.window); + logWarn(LogCategory.GENERAL, tr("Received open window event for an unknown window: %s"), event.window); } }); @@ -199,7 +198,6 @@ export function initialize(event_registry: Registry) try { const broadcast = connection.getServerConnection().getVideoConnection().getLocalBroadcast(event.broadcastType); if(broadcast.getState().state === "initializing" || broadcast.getState().state === "broadcasting") { - console.error("Change source"); broadcast.changeSource(source, config).catch(error => { logError(LogCategory.VIDEO, tr("Failed to change broadcast source: %o"), event.broadcastType, error); if(typeof error !== "string") { @@ -213,7 +211,6 @@ export function initialize(event_registry: Registry) } }); } else { - console.error("Start broadcast"); broadcast.startBroadcasting(source, config).catch(error => { logError(LogCategory.VIDEO, tr("Failed to start %s broadcasting: %o"), event.broadcastType, error); if(typeof error !== "string") { diff --git a/shared/js/file/FileManager.tsx b/shared/js/file/FileManager.tsx index 39709a4a..b5d6ce91 100644 --- a/shared/js/file/FileManager.tsx +++ b/shared/js/file/FileManager.tsx @@ -1,5 +1,4 @@ -import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logError, logWarn} from "tc-shared/log"; import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {ServerCommand} from "tc-shared/connection/ConnectionBase"; import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration"; @@ -172,7 +171,7 @@ class FileCommandHandler extends AbstractCommandHandler { const transfer = this.manager.findTransfer(parseInt(data["clientftfid"])); if(!transfer) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file transfer start notification for unknown transfer (%s)"), data["clientftfid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file transfer start notification for unknown transfer (%s)"), data["clientftfid"]); return; } @@ -213,7 +212,7 @@ class FileCommandHandler extends AbstractCommandHandler { const transfer = this.manager.findTransfer(parseInt(data["clientftfid"])) as FileUploadTransfer; if(!transfer) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file transfer start notification for unknown transfer (%s)"), data["clientftfid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file transfer start notification for unknown transfer (%s)"), data["clientftfid"]); return; } @@ -243,7 +242,7 @@ class FileCommandHandler extends AbstractCommandHandler { const transfer = this.manager.findTransfer(parseInt(data["clientftfid"])) as FileUploadTransfer; if(!transfer) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file transfer start notification for unknown transfer (%s)"), data["clientftfid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file transfer start notification for unknown transfer (%s)"), data["clientftfid"]); return; } @@ -258,7 +257,7 @@ class FileCommandHandler extends AbstractCommandHandler { const transfer = this.manager.findTransfer(parseInt(data["clientftfid"])) as FileUploadTransfer; if(!transfer) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file transfer progress notification for unknown transfer (%s)"), data["clientftfid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file transfer progress notification for unknown transfer (%s)"), data["clientftfid"]); return; } @@ -283,7 +282,7 @@ class FileCommandHandler extends AbstractCommandHandler { const transfer = this.manager.findTransfer(parseInt(data["clientftfid"])) as FileUploadTransfer; if(!transfer) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file transfer status notification for unknown transfer (%s)"), data["clientftfid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file transfer status notification for unknown transfer (%s)"), data["clientftfid"]); return; } @@ -308,7 +307,7 @@ class FileCommandHandler extends AbstractCommandHandler { private handleNotifyFileList(data: any[]) { const query = this.pendingFileLists.find(e => e.path === data[0]["path"] && (e.channelId === parseInt(data[0]["cid"]) || e.channelId === undefined && !data[0]["cid"])); if(!query) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file list for not request path: %s (channel %s)"), data[0]["path"], data[0]["cid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file list for not request path: %s (channel %s)"), data[0]["path"], data[0]["cid"]); return; } @@ -326,7 +325,7 @@ class FileCommandHandler extends AbstractCommandHandler { private handleNotifyFileListFinished(data) { const query = this.pendingFileLists.find(e => e.path === data[0]["path"] && (e.channelId === parseInt(data[0]["cid"]) || e.channelId === undefined && !data[0]["cid"])); if(!query) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file list finish for not request path: %s (channel %s)"), data[0]["path"], data[0]["cid"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file list finish for not request path: %s (channel %s)"), data[0]["path"], data[0]["cid"]); return; } @@ -336,11 +335,11 @@ class FileCommandHandler extends AbstractCommandHandler { private handleNotifyFileInfo(data: any[]) { const query = this.pendingFileInfos.find(e => e.returnCode === data[0]["return_code"]); if(!query) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file info for unknown return code: %s"), data[0]["return_code"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file info for unknown return code: %s"), data[0]["return_code"]); return; } if(query.finished) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file info for already finished return code: %s"), data[0]["return_code"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file info for already finished return code: %s"), data[0]["return_code"]); return; } @@ -358,7 +357,7 @@ class FileCommandHandler extends AbstractCommandHandler { private handleNotifyFileInfoFinished(data) { const query = this.pendingFileInfos.find(e => e.returnCode === data[0]["return_code"]); if(!query) { - log.warn(LogCategory.FILE_TRANSFER, tr("Received file info for unknown return code: %s"), data[0]["return_code"]); + logWarn(LogCategory.FILE_TRANSFER, tr("Received file info for unknown return code: %s"), data[0]["return_code"]); return; } @@ -656,7 +655,7 @@ export class FileManager { const index = this.registeredTransfers_.findIndex(e => e.transfer === transfer); if(index === -1) { - log.error(LogCategory.FILE_TRANSFER, tr("Missing file transfer in file transfer list!")); + logError(LogCategory.FILE_TRANSFER, tr("Missing file transfer in file transfer list!")); return; } else { this.registeredTransfers_.splice(index, 1); @@ -680,7 +679,7 @@ export class FileManager { transferErrorMessage: transfer.currentErrorMessage(), }); } else { - log.warn(LogCategory.FILE_TRANSFER, tra("File transfer finished callback called with invalid transfer state ({0})", FileTransferState[state])); + logWarn(LogCategory.FILE_TRANSFER, tra("File transfer finished callback called with invalid transfer state ({0})", FileTransferState[state])); } }; diff --git a/shared/js/file/Icons.ts b/shared/js/file/Icons.ts index 5317f417..96c6059e 100644 --- a/shared/js/file/Icons.ts +++ b/shared/js/file/Icons.ts @@ -1,5 +1,5 @@ import {Registry} from "tc-shared/events"; -import { tr, tra } from "tc-shared/i18n/localize"; +import {tr, tra} from "tc-shared/i18n/localize"; export const kIPCIconChannel = "icons"; export const kGlobalIconHandlerId = "global"; diff --git a/shared/js/file/ImageCache.ts b/shared/js/file/ImageCache.ts index 86b64cc3..eeb44db7 100644 --- a/shared/js/file/ImageCache.ts +++ b/shared/js/file/ImageCache.ts @@ -1,5 +1,5 @@ import {tr} from "../i18n/localize"; -import {LogCategory, logDebug} from "tc-shared/log"; +import {LogCategory, logDebug, logWarn} from "tc-shared/log"; export enum ImageType { UNKNOWN, @@ -169,7 +169,7 @@ export class ImageCache { ignoreSearch: true }); if(!flag) { - console.warn(tr("Failed to delete key %s from cache!"), key); + logWarn(LogCategory.FILE_TRANSFER, tr("Failed to delete key %s from cache!"), key); } } } \ No newline at end of file diff --git a/shared/js/file/LocalAvatars.ts b/shared/js/file/LocalAvatars.ts index d525e6b1..a1a9736d 100644 --- a/shared/js/file/LocalAvatars.ts +++ b/shared/js/file/LocalAvatars.ts @@ -1,5 +1,4 @@ -import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logDebug, logError, logInfo, logWarn} from "../log"; import * as ipc from "../ipc/BrowserIPC"; import {ChannelMessage} from "../ipc/BrowserIPC"; import * as loader from "tc-loader"; @@ -58,7 +57,7 @@ export class AvatarManager extends AbstractAvatarManager { } create_avatar_download(client_avatar_id: string) : FileDownloadTransfer { - log.debug(LogCategory.GENERAL, "Requesting download for avatar %s", client_avatar_id); + logDebug(LogCategory.GENERAL, "Requesting download for avatar %s", client_avatar_id); return this.handle.initializeFileDownload({ path: "", @@ -86,11 +85,11 @@ export class AvatarManager extends AbstractAvatarManager { let cachedAvatarHash = response.headers.has("X-avatar-version") ? response.headers.get("X-avatar-version") : undefined; if(avatar.getAvatarHash() !== "unknown") { if(cachedAvatarHash === undefined) { - log.debug(LogCategory.FILE_TRANSFER, tr("Invalidating cached avatar for %s (Version miss match. Cached: unset, Current: %s)"), avatar.clientAvatarId, avatar.getAvatarHash()); + logDebug(LogCategory.FILE_TRANSFER, tr("Invalidating cached avatar for %s (Version miss match. Cached: unset, Current: %s)"), avatar.clientAvatarId, avatar.getAvatarHash()); await localAvatarCache.delete('avatar_' + avatar.clientAvatarId); break cache_lookup; } else if(cachedAvatarHash !== avatar.getAvatarHash()) { - log.debug(LogCategory.FILE_TRANSFER, tr("Invalidating cached avatar for %s (Version miss match. Cached: %s, Current: %s)"), avatar.clientAvatarId, cachedAvatarHash, avatar.getAvatarHash()); + logDebug(LogCategory.FILE_TRANSFER, tr("Invalidating cached avatar for %s (Version miss match. Cached: %s, Current: %s)"), avatar.clientAvatarId, cachedAvatarHash, avatar.getAvatarHash()); await localAvatarCache.delete('avatar_' + avatar.clientAvatarId); break cache_lookup; } @@ -122,7 +121,7 @@ export class AvatarManager extends AbstractAvatarManager { if(commandResult instanceof CommandResult) { if(commandResult.id === ErrorCode.FILE_NOT_FOUND) { if(avatar.getAvatarHash() !== initialAvatarHash) { - log.debug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), initialAvatarHash, avatar.getAvatarHash()); + logDebug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), initialAvatarHash, avatar.getAvatarHash()); return; } @@ -136,7 +135,7 @@ export class AvatarManager extends AbstractAvatarManager { } } - log.error(LogCategory.CLIENT, tr("Could not request download for avatar %s: %o"), avatar.clientAvatarId, error); + logError(LogCategory.CLIENT, tr("Could not request download for avatar %s: %o"), avatar.clientAvatarId, error); if(error === transfer.currentError()) throw transfer.currentErrorMessage(); @@ -161,7 +160,7 @@ export class AvatarManager extends AbstractAvatarManager { const media = imageType2MediaType(type); if(avatar.getAvatarHash() !== initialAvatarHash) { - log.debug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), initialAvatarHash, avatar.getAvatarHash()); + logDebug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), initialAvatarHash, avatar.getAvatarHash()); return; } @@ -188,7 +187,7 @@ export class AvatarManager extends AbstractAvatarManager { /* ensure we're still up to date */ if(avatar.getAvatarHash() !== initialAvatarHash) { - log.debug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), initialAvatarHash, avatar.getAvatarHash()); + logDebug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), initialAvatarHash, avatar.getAvatarHash()); return; } @@ -207,7 +206,7 @@ export class AvatarManager extends AbstractAvatarManager { avatar.loadingTimestamp = Date.now(); this.executeAvatarLoad0(avatar).catch(error => { if(avatar.getAvatarHash() !== avatarHash) { - log.debug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), avatarHash, avatar.getAvatarHash()); + logDebug(LogCategory.GENERAL, tr("Ignoring avatar not found since the avatar itself got updated. Out version: %s, current version: %s"), avatarHash, avatar.getAvatarHash()); return; } @@ -216,7 +215,7 @@ export class AvatarManager extends AbstractAvatarManager { } else if(error instanceof Error) { avatar.setErrored({ message: error.message }); } else { - log.error(LogCategory.FILE_TRANSFER, tr("Failed to load avatar %s (hash: %s): %o"), avatar.clientAvatarId, avatarHash, error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to load avatar %s (hash: %s): %o"), avatar.clientAvatarId, avatarHash, error); avatar.setErrored({ message: tr("lookup the console") }); } }); @@ -228,7 +227,7 @@ export class AvatarManager extends AbstractAvatarManager { if(cached.getAvatarHash() === clientAvatarHash) return; - log.info(LogCategory.GENERAL, tr("Deleting cached avatar for client %s. Cached version: %s; New version: %s"), cached.getAvatarHash(), clientAvatarHash); + logInfo(LogCategory.GENERAL, tr("Deleting cached avatar for client %s. Cached version: %s; New version: %s"), cached.getAvatarHash(), clientAvatarHash); } const response = await localAvatarCache.resolveCached('avatar_' + clientAvatarId); @@ -236,7 +235,7 @@ export class AvatarManager extends AbstractAvatarManager { let cachedAvatarHash = response.headers.has("X-avatar-version") ? response.headers.get("X-avatar-version") : undefined; if(cachedAvatarHash !== clientAvatarHash) { await localAvatarCache.delete("avatar_" + clientAvatarId).catch(error => { - log.warn(LogCategory.FILE_TRANSFER, tr("Failed to delete avatar %s: %o"), clientAvatarId, error); + logWarn(LogCategory.FILE_TRANSFER, tr("Failed to delete avatar %s: %o"), clientAvatarId, error); }); } } diff --git a/shared/js/file/LocalIcons.ts b/shared/js/file/LocalIcons.ts index 100df25c..dc3fb820 100644 --- a/shared/js/file/LocalIcons.ts +++ b/shared/js/file/LocalIcons.ts @@ -2,7 +2,6 @@ import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {ImageCache, ImageType, imageType2MediaType, responseImageType} from "tc-shared/file/ImageCache"; import {AbstractIconManager, kIPCIconChannel, RemoteIcon, RemoteIconState, setIconManager} from "tc-shared/file/Icons"; -import * as log from "tc-shared/log"; import {LogCategory, logDebug, logError, logWarn} from "tc-shared/log"; import {server_connections} from "tc-shared/ConnectionManager"; import {ConnectionEvents, ConnectionHandler, ConnectionState} from "tc-shared/ConnectionHandler"; @@ -292,7 +291,7 @@ class IconManager extends AbstractIconManager { throw error.extra_message || error.message; } } - log.error(LogCategory.FILE_TRANSFER, tr("Could not request download for icon %d: %o"), icon.iconId, error); + logError(LogCategory.FILE_TRANSFER, tr("Could not request download for icon %d: %o"), icon.iconId, error); if(error === transfer.currentError()) { throw transfer.currentErrorMessage(); } diff --git a/shared/js/i18n/localize.ts b/shared/js/i18n/localize.ts index 63cee0ee..74a1ac47 100644 --- a/shared/js/i18n/localize.ts +++ b/shared/js/i18n/localize.ts @@ -1,5 +1,4 @@ -import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logError, logInfo, logWarn} from "../log"; import {guid} from "../crypto/uid"; import {Settings, StaticSettings} from "../settings"; import * as loader from "tc-loader"; @@ -54,7 +53,7 @@ export function tr(message: string, key?: string) { const sloppy = fast_translate[message]; if(sloppy) return sloppy; - log.info(LogCategory.I18N, "Translating \"%s\". Default: \"%s\"", key, message); + logInfo(LogCategory.I18N, "Translating \"%s\". Default: \"%s\"", key, message); let translated = message; for(const translation of translations) { @@ -116,7 +115,7 @@ async function load_translation_file(url: string, path: string) : Promise { throw "dummy test failed"; } - log.info(LogCategory.I18N, tr("Successfully initialized up translation file from %s"), url); + logInfo(LogCategory.I18N, tr("Successfully initialized up translation file from %s"), url); translations = result.translations; }).catch(error => { - log.warn(LogCategory.I18N, tr("Failed to load translation file from \"%s\". Error: %o"), url, error); + logWarn(LogCategory.I18N, tr("Failed to load translation file from \"%s\". Error: %o"), url, error); return Promise.reject(error); }); } @@ -210,7 +209,7 @@ export namespace config { try { config = config_string ? JSON.parse(config_string) : {}; } catch(error) { - log.error(LogCategory.I18N, tr("Failed to parse repository config: %o"), error); + logError(LogCategory.I18N, tr("Failed to parse repository config: %o"), error); } config.repositories = config.repositories || []; for(const repo of config.repositories) @@ -219,10 +218,10 @@ export namespace config { if(config.repositories.length == 0) { //Add the default TeaSpeak repository load_repository(StaticSettings.instance.static(Settings.KEY_I18N_DEFAULT_REPOSITORY)).then(repo => { - log.info(LogCategory.I18N, tr("Successfully added default repository from \"%s\"."), repo.url); + logInfo(LogCategory.I18N, tr("Successfully added default repository from \"%s\"."), repo.url); register_repository(repo); }).catch(error => { - log.warn(LogCategory.I18N, tr("Failed to add default repository. Error: %o"), error); + logWarn(LogCategory.I18N, tr("Failed to add default repository. Error: %o"), error); }); } @@ -244,7 +243,7 @@ export namespace config { try { _cached_translation_config = config_string ? JSON.parse(config_string) : {}; } catch(error) { - log.error(LogCategory.I18N, tr("Failed to initialize translation config. Using default one. Error: %o"), error); + logError(LogCategory.I18N, tr("Failed to initialize translation config. Using default one. Error: %o"), error); _cached_translation_config = {} as any; } return _cached_translation_config; @@ -284,7 +283,7 @@ export async function iterate_repositories(callback_entry: (repository: Translat for(const repository of registered_repositories()) { promises.push(load_repository0(repository, false).then(() => callback_entry(repository)).catch(error => { - log.warn(LogCategory.I18N, "Failed to fetch repository %s. error: %o", repository.url, error); + logWarn(LogCategory.I18N, "Failed to fetch repository %s. error: %o", repository.url, error); })); } @@ -318,7 +317,7 @@ export async function initialize() { try { await load_file(cfg.current_translation_url, cfg.current_translation_path); } catch (error) { - console.error(tr("Failed to initialize selected translation: %o"), error); + logError(LogCategory.I18N, tr("Failed to initialize selected translation: %o"), error); const show_error = () => { import("../ui/elements/Modal").then(Modal => { Modal.createErrorModal(tr("Translation System"), tra("Failed to load current selected translation file.{:br:}File: {0}{:br:}Error: {1}{:br:}{:br:}Using default fallback translations.", cfg.current_translation_url, error)).open() diff --git a/shared/js/ipc/BrowserIPC.ts b/shared/js/ipc/BrowserIPC.ts index 32c67148..6d8b928b 100644 --- a/shared/js/ipc/BrowserIPC.ts +++ b/shared/js/ipc/BrowserIPC.ts @@ -1,8 +1,7 @@ import "broadcastchannel-polyfill"; -import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logDebug, logError, logWarn} from "../log"; import {ConnectHandler} from "../ipc/ConnectHandler"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export interface BroadcastMessage { timestamp: number; @@ -67,7 +66,7 @@ export abstract class BasicIPCHandler { if(message.receiver === BasicIPCHandler.BROADCAST_UNIQUE_ID) { if(message.type == "process-query") { - log.debug(LogCategory.IPC, tr("Received a device query from %s."), message.sender); + logDebug(LogCategory.IPC, tr("Received a device query from %s."), message.sender); this.sendMessage("process-query-response", { request_query_id: (message.data).query_id, request_timestamp: (message.data).timestamp, @@ -83,14 +82,14 @@ export abstract class BasicIPCHandler { if(this._query_results[response.request_query_id]) this._query_results[response.request_query_id].push(response); else { - log.warn(LogCategory.IPC, tr("Received a query response for an unknown request.")); + logWarn(LogCategory.IPC, tr("Received a query response for an unknown request.")); } return; } else if(message.type == "certificate-accept-callback") { const data: CertificateAcceptCallback = message.data; if(!this._cert_accept_callbacks[data.request_id]) { - log.warn(LogCategory.IPC, tr("Received certificate accept callback for an unknown request ID.")); + logWarn(LogCategory.IPC, tr("Received certificate accept callback for an unknown request ID.")); return; } this._cert_accept_callbacks[data.request_id](); @@ -103,7 +102,7 @@ export abstract class BasicIPCHandler { } else if(message.type == "certificate-accept-succeeded") { if(!this._cert_accept_succeeded[message.sender]) { - log.warn(LogCategory.IPC, tr("Received certificate accept succeeded, but haven't a callback.")); + logWarn(LogCategory.IPC, tr("Received certificate accept succeeded, but haven't a callback.")); return; } this._cert_accept_succeeded[message.sender](); @@ -230,7 +229,7 @@ class BroadcastChannelIPC extends BasicIPCHandler { private onMessage(event: MessageEvent) { if(typeof(event.data) !== "string") { - log.warn(LogCategory.IPC, tr("Received message with an invalid type (%s): %o"), typeof(event.data), event.data); + logWarn(LogCategory.IPC, tr("Received message with an invalid type (%s): %o"), typeof(event.data), event.data); return; } @@ -238,14 +237,14 @@ class BroadcastChannelIPC extends BasicIPCHandler { try { message = JSON.parse(event.data); } catch(error) { - log.error(LogCategory.IPC, tr("Received an invalid encoded message: %o"), event.data); + logError(LogCategory.IPC, tr("Received an invalid encoded message: %o"), event.data); return; } super.handleMessage(message); } private onError(event: MessageEvent) { - log.warn(LogCategory.IPC, tr("Received error: %o"), event); + logWarn(LogCategory.IPC, tr("Received error: %o"), event); } sendMessage(type: string, data: any, target?: string) { diff --git a/shared/js/ipc/ConnectHandler.ts b/shared/js/ipc/ConnectHandler.ts index f1616766..c731f83e 100644 --- a/shared/js/ipc/ConnectHandler.ts +++ b/shared/js/ipc/ConnectHandler.ts @@ -1,8 +1,7 @@ -import * as log from "../log"; -import {LogCategory} from "../log"; -import {BasicIPCHandler, IPCChannel, ChannelMessage} from "../ipc/BrowserIPC"; +import {LogCategory, logDebug, logError, logWarn} from "../log"; +import {BasicIPCHandler, ChannelMessage, IPCChannel} from "../ipc/BrowserIPC"; import {guid} from "../crypto/uid"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export type ConnectRequestData = { address: string; @@ -91,7 +90,7 @@ export class ConnectHandler { } as ConnectOfferAnswer; if(response.accepted) { - log.debug(LogCategory.IPC, tr("Received new connect offer from %s: %s"), sender, data.request_id); + logDebug(LogCategory.IPC, tr("Received new connect offer from %s: %s"), sender, data.request_id); const ld = { remote_handler: sender, @@ -101,7 +100,7 @@ export class ConnectHandler { }; this._pending_connect_offers.push(ld); ld.timeout = setTimeout(() => { - log.debug(LogCategory.IPC, tr("Dropping connect request %s, because we never received an execute."), ld.id); + logDebug(LogCategory.IPC, tr("Dropping connect request %s, because we never received an execute."), ld.id); this._pending_connect_offers.remove(ld); }, 120 * 1000) as any; } @@ -112,19 +111,19 @@ export class ConnectHandler { const data = message.data as ConnectOfferAnswer; const request = this._pending_connects_requests.find(e => e.id === data.request_id); if(!request) { - log.warn(LogCategory.IPC, tr("Received connect offer answer with unknown request id (%s)."), data.request_id); + logWarn(LogCategory.IPC, tr("Received connect offer answer with unknown request id (%s)."), data.request_id); return; } if(!data.accepted) { - log.debug(LogCategory.IPC, tr("Client %s rejected the connect offer (%s)."), sender, request.id); + logDebug(LogCategory.IPC, tr("Client %s rejected the connect offer (%s)."), sender, request.id); return; } if(request.remote_handler) { - log.debug(LogCategory.IPC, tr("Client %s accepted the connect offer (%s), but offer has already been accepted."), sender, request.id); + logDebug(LogCategory.IPC, tr("Client %s accepted the connect offer (%s), but offer has already been accepted."), sender, request.id); return; } - log.debug(LogCategory.IPC, tr("Client %s accepted the connect offer (%s). Request local acceptance."), sender, request.id); + logDebug(LogCategory.IPC, tr("Client %s accepted the connect offer (%s). Request local acceptance."), sender, request.id); request.remote_handler = sender; clearTimeout(request.timeout); @@ -134,7 +133,7 @@ export class ConnectHandler { return; } - log.debug(LogCategory.IPC, tr("Executing connect with client %s"), request.remote_handler); + logDebug(LogCategory.IPC, tr("Executing connect with client %s"), request.remote_handler); this.ipc_channel.sendMessage("execute", { request_id: request.id } as ConnectExecute, request.remote_handler); @@ -142,7 +141,7 @@ export class ConnectHandler { request.callback_failed("connect execute timeout"); }, 1000) as any; }).catch(error => { - log.error(LogCategory.IPC, tr("Local avail callback caused an error: %o"), error); + logError(LogCategory.IPC, tr("Local avail callback caused an error: %o"), error); request.callback_failed(tr("local avail callback caused an error")); }); @@ -151,16 +150,16 @@ export class ConnectHandler { const data = message.data as ConnectExecuted; const request = this._pending_connects_requests.find(e => e.id === data.request_id); if(!request) { - log.warn(LogCategory.IPC, tr("Received connect executed with unknown request id (%s)."), data.request_id); + logWarn(LogCategory.IPC, tr("Received connect executed with unknown request id (%s)."), data.request_id); return; } if(request.remote_handler != sender) { - log.warn(LogCategory.IPC, tr("Received connect executed for request %s, but from wrong client: %s (expected %s)"), data.request_id, sender, request.remote_handler); + logWarn(LogCategory.IPC, tr("Received connect executed for request %s, but from wrong client: %s (expected %s)"), data.request_id, sender, request.remote_handler); return; } - log.debug(LogCategory.IPC, tr("Received connect executed response from client %s for request %s. Succeeded: %o (%s)"), sender, data.request_id, data.succeeded, data.message); + logDebug(LogCategory.IPC, tr("Received connect executed response from client %s for request %s. Succeeded: %o (%s)"), sender, data.request_id, data.succeeded, data.message); clearTimeout(request.timeout); if(data.succeeded) request.callback_success(); @@ -171,18 +170,18 @@ export class ConnectHandler { const data = message.data as ConnectExecute; const request = this._pending_connect_offers.find(e => e.id === data.request_id); if(!request) { - log.warn(LogCategory.IPC, tr("Received connect execute with unknown request id (%s)."), data.request_id); + logWarn(LogCategory.IPC, tr("Received connect execute with unknown request id (%s)."), data.request_id); return; } if(request.remote_handler != sender) { - log.warn(LogCategory.IPC, tr("Received connect execute for request %s, but from wrong client: %s (expected %s)"), data.request_id, sender, request.remote_handler); + logWarn(LogCategory.IPC, tr("Received connect execute for request %s, but from wrong client: %s (expected %s)"), data.request_id, sender, request.remote_handler); return; } clearTimeout(request.timeout); this._pending_connect_offers.remove(request); - log.debug(LogCategory.IPC, tr("Executing connect for %s"), data.request_id); + logDebug(LogCategory.IPC, tr("Executing connect for %s"), data.request_id); const cr = this.callback_execute(request.data); const response = { diff --git a/shared/js/ipc/MethodProxy.ts b/shared/js/ipc/MethodProxy.ts index dc6811d5..1c3a5606 100644 --- a/shared/js/ipc/MethodProxy.ts +++ b/shared/js/ipc/MethodProxy.ts @@ -1,8 +1,7 @@ -import * as log from "../log"; -import {LogCategory} from "../log"; -import {BasicIPCHandler, IPCChannel, ChannelMessage} from "../ipc/BrowserIPC"; +import {LogCategory, logDebug, logInfo, logWarn} from "../log"; +import {BasicIPCHandler, ChannelMessage, IPCChannel} from "../ipc/BrowserIPC"; import {guid} from "../crypto/uid"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export interface MethodProxyInvokeData { method_name: string; @@ -81,10 +80,10 @@ export abstract class MethodProxy { protected register_method(method: (...args: any[]) => Promise | string) { let method_name: string; if(typeof method === "function") { - log.debug(LogCategory.IPC, tr("Registering method proxy for %s"), method.name); + logDebug(LogCategory.IPC, tr("Registering method proxy for %s"), method.name); method_name = method.name; } else { - log.debug(LogCategory.IPC, tr("Registering method proxy for %s"), method); + logDebug(LogCategory.IPC, tr("Registering method proxy for %s"), method); method_name = method; } @@ -169,11 +168,11 @@ export abstract class MethodProxy { } try { - log.info(LogCategory.IPC, tr("Invoking method %s with arguments: %o"), data.method_name, data.arguments); + logInfo(LogCategory.IPC, tr("Invoking method %s with arguments: %o"), data.method_name, data.arguments); const promise = this[data.method_name](...data.arguments); promise.then(result => { - log.info(LogCategory.IPC, tr("Result: %o"), result); + logInfo(LogCategory.IPC, tr("Result: %o"), result); this._send_result(data.promise_id, true, result); }).catch(error => { this._send_result(data.promise_id, false, error); @@ -186,7 +185,7 @@ export abstract class MethodProxy { private _handle_result(data: MethodProxyResultData) { if(!this._proxied_callbacks[data.promise_id]) { - console.warn(tr("Received proxy method result for unknown promise")); + logWarn(LogCategory.IPC, tr("Received proxy method result for unknown promise")); return; } const callback = this._proxied_callbacks[data.promise_id]; diff --git a/shared/js/log.ts b/shared/js/log.ts index 4406e6d8..767811a6 100644 --- a/shared/js/log.ts +++ b/shared/js/log.ts @@ -131,7 +131,7 @@ function logDirect(type: LogType, message: string, ...optionalParams: any[]) { } } -export function log(type: LogType, category: LogCategory, message: string, ...optionalParams: any[]) { +function doLog(type: LogType, category: LogCategory, message: string, ...optionalParams: any[]) { if(!enabled_mapping.get(category)) return; optionalParams.unshift(categoryMapping.get(category)); @@ -139,45 +139,25 @@ export function log(type: LogType, category: LogCategory, message: string, ...op logDirect(type, message, ...optionalParams); } -export function trace(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.TRACE, category, message, ...optionalParams); -} - -export function debug(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.DEBUG, category, message, ...optionalParams); -} - -export function info(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.INFO, category, message, ...optionalParams); -} - -export function warn(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.WARNING, category, message, ...optionalParams); -} - -export function error(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.ERROR, category, message, ...optionalParams); -} - /* methods for direct import */ export function logTrace(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.TRACE, category, message, ...optionalParams); + doLog(LogType.TRACE, category, message, ...optionalParams); } export function logDebug(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.DEBUG, category, message, ...optionalParams); + doLog(LogType.DEBUG, category, message, ...optionalParams); } export function logInfo(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.INFO, category, message, ...optionalParams); + doLog(LogType.INFO, category, message, ...optionalParams); } export function logWarn(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.WARNING, category, message, ...optionalParams); + doLog(LogType.WARNING, category, message, ...optionalParams); } export function logError(category: LogCategory, message: string, ...optionalParams: any[]) { - log(LogType.ERROR, category, message, ...optionalParams); + doLog(LogType.ERROR, category, message, ...optionalParams); } export function group(level: LogType, category: LogCategory, name: string, ...optionalParams: any[]) : Group { diff --git a/shared/js/media/Stream.ts b/shared/js/media/Stream.ts index a42515bf..ea1d8878 100644 --- a/shared/js/media/Stream.ts +++ b/shared/js/media/Stream.ts @@ -1,5 +1,4 @@ import {InputStartError} from "tc-shared/voice/RecorderBase"; -import * as log from "tc-shared/log"; import {LogCategory, logInfo, logWarn} from "tc-shared/log"; import {tr} from "tc-shared/i18n/localize"; @@ -28,17 +27,17 @@ export async function requestMediaStreamWithConstraints(constraints: MediaTrackC if('name' in error) { if(error.name === "NotAllowedError") { if(Date.now() - beginTimestamp < 250) { - log.warn(LogCategory.AUDIO, tr("Media stream request failed (System denied). Browser message: %o"), error.message); + logWarn(LogCategory.AUDIO, tr("Media stream request failed (System denied). Browser message: %o"), error.message); return InputStartError.ESYSTEMDENIED; } else { - log.warn(LogCategory.AUDIO, tr("Media stream request failed (No permissions). Browser message: %o"), error.message); + logWarn(LogCategory.AUDIO, tr("Media stream request failed (No permissions). Browser message: %o"), error.message); return InputStartError.ENOTALLOWED; } } else { - log.warn(LogCategory.AUDIO, tr("Media stream request failed. Request resulted in error: %o: %o"), error.name, error); + logWarn(LogCategory.AUDIO, tr("Media stream request failed. Request resulted in error: %o: %o"), error.name, error); } } else { - log.warn(LogCategory.AUDIO, tr("Failed to initialize media stream (%o)"), error); + logWarn(LogCategory.AUDIO, tr("Failed to initialize media stream (%o)"), error); } return InputStartError.EUNKNOWN; diff --git a/shared/js/permission/GroupManager.ts b/shared/js/permission/GroupManager.ts index 2a5ab246..388d5dd9 100644 --- a/shared/js/permission/GroupManager.ts +++ b/shared/js/permission/GroupManager.ts @@ -1,6 +1,5 @@ import {LaterPromise} from "../utils/LaterPromise"; -import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logDebug, logError, logWarn} from "../log"; import {PermissionManager, PermissionValue} from "../permission/PermissionManager"; import {ServerCommand} from "../connection/ConnectionBase"; import {CommandResult} from "../connection/ServerConnectionDeclaration"; @@ -188,7 +187,7 @@ export class GroupManager extends AbstractCommandHandler { return; } - log.debug(LogCategory.PERMISSIONS, tr("Resetting server/channel groups")); + logDebug(LogCategory.PERMISSIONS, tr("Resetting server/channel groups")); this.serverGroups = []; this.channelGroups = []; this.allGroupsReceived = false; @@ -219,11 +218,11 @@ export class GroupManager extends AbstractCommandHandler { requestGroups(){ this.connectionHandler.serverConnection.send_command("servergrouplist", {}, { process_result: false }).catch(error => { - log.warn(LogCategory.PERMISSIONS, tr("Failed to request the server group list: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to request the server group list: %o"), error); }); this.connectionHandler.serverConnection.send_command("channelgrouplist", {}, { process_result: false }).catch(error => { - log.warn(LogCategory.PERMISSIONS, tr("Failed to request the channel group list: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to request the channel group list: %o"), error); }); } @@ -257,7 +256,7 @@ export class GroupManager extends AbstractCommandHandler { case 1: type = GroupType.NORMAL; break; case 2: type = GroupType.QUERY; break; default: - log.error(LogCategory.CLIENT, tr("Invalid group type: %o for group %s"), groupData["type"], groupData["name"]); + logError(LogCategory.CLIENT, tr("Invalid group type: %o for group %s"), groupData["type"], groupData["name"]); continue; } @@ -332,7 +331,7 @@ export class GroupManager extends AbstractCommandHandler { private handleGroupPermissionList(json: any[]) { let group = json[0]["sgid"] ? this.findServerGroup(parseInt(json[0]["sgid"])) : this.findChannelGroup(parseInt(json[0]["cgid"])); if(!group) { - log.error(LogCategory.PERMISSIONS, tr("Got group permissions for group %o/%o, but its not a registered group!"), json[0]["sgid"], json[0]["cgid"]); + logError(LogCategory.PERMISSIONS, tr("Got group permissions for group %o/%o, but its not a registered group!"), json[0]["sgid"], json[0]["cgid"]); return; } let requests: GroupPermissionRequest[] = []; @@ -341,7 +340,7 @@ export class GroupManager extends AbstractCommandHandler { requests.push(req); if(requests.length == 0) { - log.warn(LogCategory.PERMISSIONS, tr("Got group permissions for group %o/%o, but it was never requested!"), json[0]["sgid"], json[0]["cgid"]); + logWarn(LogCategory.PERMISSIONS, tr("Got group permissions for group %o/%o, but it was never requested!"), json[0]["sgid"], json[0]["cgid"]); return; } diff --git a/shared/js/permission/PermissionManager.ts b/shared/js/permission/PermissionManager.ts index 96955d15..f58c2da3 100644 --- a/shared/js/permission/PermissionManager.ts +++ b/shared/js/permission/PermissionManager.ts @@ -1,5 +1,5 @@ import * as log from "../log"; -import {LogCategory, LogType} from "../log"; +import {LogCategory, logDebug, logInfo, logTrace, LogType, logWarn} from "../log"; import {PermissionType} from "../permission/PermissionType"; import {LaterPromise} from "../utils/LaterPromise"; import {ServerCommand} from "../connection/ConnectionBase"; @@ -51,7 +51,7 @@ export class PermissionValue { let result; result = this.value == -1 || this.value >= requiredValue || (this.value == -2 && requiredValue == -2 && !required); - log.trace(LogCategory.PERMISSIONS, + logTrace(LogCategory.PERMISSIONS, tr("Required permission test resulted for permission %s: %s. Required value: %s, Granted value: %s"), this.type ? this.type.name : "unknown", result ? tr("granted") : tr("denied"), @@ -227,7 +227,7 @@ export class PermissionManager extends AbstractCommandHandler { let perm_info = manager.resolveInfo(perm_id); if(!perm_info) { - log.warn(LogCategory.PERMISSIONS, tr("Got unknown permission id (%o/%o (%o))!"), perm["permid"], perm_id, perm["permsid"]); + logWarn(LogCategory.PERMISSIONS, tr("Got unknown permission id (%o/%o (%o))!"), perm["permid"], perm_id, perm["permsid"]); return; } @@ -360,7 +360,7 @@ export class PermissionManager extends AbstractCommandHandler { log.table(LogType.DEBUG, LogCategory.PERMISSIONS, "Permission list", table_entries); group.end(); - log.info(LogCategory.PERMISSIONS, tr("Got %i permissions"), this.permissionList.length); + logInfo(LogCategory.PERMISSIONS, tr("Got %i permissions"), this.permissionList.length); if(this._cacheNeededPermissions) this.onNeededPermissions(this._cacheNeededPermissions); for(let listener of this.initializedListener) @@ -369,7 +369,7 @@ export class PermissionManager extends AbstractCommandHandler { private onNeededPermissions(json) { if(this.permissionList.length == 0) { - log.warn(LogCategory.PERMISSIONS, tr("Got needed permissions but don't have a permission list!")); + logWarn(LogCategory.PERMISSIONS, tr("Got needed permissions but don't have a permission list!")); this._cacheNeededPermissions = json; return; } @@ -396,7 +396,7 @@ export class PermissionManager extends AbstractCommandHandler { entry = new NeededPermissionValue(info, -2); this.neededPermissions.push(entry); } else { - log.warn(LogCategory.PERMISSIONS, tr("Could not resolve perm for id %s (%o|%o)"), e["permid"], e, info); + logWarn(LogCategory.PERMISSIONS, tr("Could not resolve perm for id %s (%o|%o)"), e["permid"], e, info); continue; } addcount++; @@ -417,7 +417,7 @@ export class PermissionManager extends AbstractCommandHandler { log.table(LogType.DEBUG, LogCategory.PERMISSIONS, "Needed client permissions", table_entries); group.end(); - log.debug(LogCategory.PERMISSIONS, tr("Dropping %o needed permissions and added %o permissions."), copy.length, addcount); + logDebug(LogCategory.PERMISSIONS, tr("Dropping %o needed permissions and added %o permissions."), copy.length, addcount); for(let e of copy) { e.value = -2; for(const listener of this.needed_permission_change_listener[e.type.name] || []) @@ -704,10 +704,10 @@ export class PermissionManager extends AbstractCommandHandler { if(perm.type.id == key || perm.type.name == key || perm.type == key) return perm; - log.debug(LogCategory.PERMISSIONS, tr("Could not resolve grant permission %o. Creating a new one."), key); + logDebug(LogCategory.PERMISSIONS, tr("Could not resolve grant permission %o. Creating a new one."), key); let info = key instanceof PermissionInfo ? key : this.resolveInfo(key); if(!info) { - log.warn(LogCategory.PERMISSIONS, tr("Requested needed permission with invalid key! (%o)"), key); + logWarn(LogCategory.PERMISSIONS, tr("Requested needed permission with invalid key! (%o)"), key); return new NeededPermissionValue(undefined, -2); } let result = new NeededPermissionValue(info, -2); diff --git a/shared/js/profiles/ConnectionProfile.ts b/shared/js/profiles/ConnectionProfile.ts index 6096fd68..ba84e1e1 100644 --- a/shared/js/profiles/ConnectionProfile.ts +++ b/shared/js/profiles/ConnectionProfile.ts @@ -9,7 +9,7 @@ import {formatMessage} from "../ui/frames/chat"; import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {LogCategory, logDebug, logError} from "tc-shared/log"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export class ConnectionProfile { id: string; @@ -135,7 +135,7 @@ async function loadConnectProfiles() { try { return profiles_json ? JSON.parse(profiles_json) : {version: 0} as any; } catch (error) { - console.error(tr("Invalid profile json! Resetting profiles :( (%o)"), profiles_json); + logError(LogCategory.IDENTITIES, tr("Invalid profile json! Resetting profiles :( (%o)"), profiles_json); createErrorModal(tr("Profile data invalid"), formatMessage(tr("The profile data is invalid.{:br:}This might cause data loss."))).open(); return { version: 0 }; } @@ -151,7 +151,7 @@ async function loadConnectProfiles() { for (const profile_data of profiles_data.profiles) { const profile = await decodeProfile(profile_data); if (typeof profile === "string") { - console.error(tr("Failed to load profile. Reason: %s, Profile data: %s"), profile, profiles_data); + logError(LogCategory.IDENTITIES, tr("Failed to load profile. Reason: %s, Profile data: %s"), profile, profiles_data); } else { availableProfiles_.push(profile as ConnectionProfile); } diff --git a/shared/js/profiles/Identity.ts b/shared/js/profiles/Identity.ts index d104d7fe..58a1b04d 100644 --- a/shared/js/profiles/Identity.ts +++ b/shared/js/profiles/Identity.ts @@ -1,7 +1,8 @@ import {AbstractServerConnection, ServerCommand} from "../connection/ConnectionBase"; import {HandshakeIdentityHandler} from "../connection/HandshakeHandler"; import {AbstractCommandHandler} from "../connection/AbstractCommandHandler"; -import { tr } from "tc-shared/i18n/localize"; +import {LogCategory, logError, logWarn} from "tc-shared/log"; +import {tr} from "tc-shared/i18n/localize"; export enum IdentitifyType { TEAFORO, @@ -45,8 +46,7 @@ export async function decode_identity(type: IdentitifyType, data: string) : Prom try { await identity.decode(data) } catch(error) { - /* todo better error handling! */ - console.error(error); + logError(LogCategory.IDENTITIES, tr("Failed to decode identity: %o"), error); return undefined; } @@ -87,7 +87,7 @@ export class HandshakeCommandHandler } else if(command.command == "error") { return false; } else { - console.warn(tr("Received unknown command while handshaking (%o)"), command); + logWarn(LogCategory.IDENTITIES, tr("Received unknown command while handshaking (%o)"), command); } return true; } diff --git a/shared/js/profiles/identities/NameIdentity.ts b/shared/js/profiles/identities/NameIdentity.ts index 39608169..55200e7e 100644 --- a/shared/js/profiles/identities/NameIdentity.ts +++ b/shared/js/profiles/identities/NameIdentity.ts @@ -4,8 +4,7 @@ import { IdentitifyType, Identity } from "../../profiles/Identity"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logError} from "../../log"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import {AbstractServerConnection} from "../../connection/ConnectionBase"; import {HandshakeIdentityHandler} from "../../connection/HandshakeHandler"; @@ -30,7 +29,7 @@ class NameHandshakeHandler extends AbstractHandshakeIdentityHandler { authentication_method: this.identity.type(), client_nickname: this.identity.name() }).catch(error => { - log.error(LogCategory.IDENTITIES, tr("Failed to initialize name based handshake. Error: %o"), error); + logError(LogCategory.IDENTITIES, tr("Failed to initialize name based handshake. Error: %o"), error); if(error instanceof CommandResult) error = error.extra_message || error.message; this.trigger_fail("failed to execute begin (" + error + ")"); diff --git a/shared/js/profiles/identities/TeaForumIdentity.ts b/shared/js/profiles/identities/TeaForumIdentity.ts index 38295bd7..74e58633 100644 --- a/shared/js/profiles/identities/TeaForumIdentity.ts +++ b/shared/js/profiles/identities/TeaForumIdentity.ts @@ -4,8 +4,7 @@ import { IdentitifyType, Identity } from "../../profiles/Identity"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logError} from "../../log"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import {AbstractServerConnection} from "../../connection/ConnectionBase"; import {HandshakeIdentityHandler} from "../../connection/HandshakeHandler"; @@ -30,7 +29,7 @@ class TeaForumHandshakeHandler extends AbstractHandshakeIdentityHandler { authentication_method: this.identity.type(), data: this.identity.data().data_json() }).catch(error => { - log.error(LogCategory.IDENTITIES, tr("Failed to initialize TeaForum based handshake. Error: %o"), error); + logError(LogCategory.IDENTITIES, tr("Failed to initialize TeaForum based handshake. Error: %o"), error); if(error instanceof CommandResult) error = error.extra_message || error.message; @@ -43,7 +42,7 @@ class TeaForumHandshakeHandler extends AbstractHandshakeIdentityHandler { this.connection.send_command("handshakeindentityproof", { proof: this.identity.data().data_sign() }).catch(error => { - log.error(LogCategory.IDENTITIES, tr("Failed to proof the identity. Error: %o"), error); + logError(LogCategory.IDENTITIES, tr("Failed to proof the identity. Error: %o"), error); if(error instanceof CommandResult) error = error.extra_message || error.message; diff --git a/shared/js/profiles/identities/TeamSpeakIdentity.ts b/shared/js/profiles/identities/TeamSpeakIdentity.ts index 70244d96..a8e72aad 100644 --- a/shared/js/profiles/identities/TeamSpeakIdentity.ts +++ b/shared/js/profiles/identities/TeamSpeakIdentity.ts @@ -1,5 +1,4 @@ -import * as log from "../../log"; -import {LogCategory, logTrace, logWarn} from "../../log"; +import {LogCategory, logError, logInfo, logTrace, logWarn} from "../../log"; import * as asn1 from "../../crypto/asn1"; import * as sha from "../../crypto/sha"; @@ -244,7 +243,7 @@ export class TeaSpeakHandshakeHandler extends AbstractHandshakeIdentityHandler { authentication_method: this.identity.type(), publicKey: this.identity.publicKey }).catch(error => { - log.error(LogCategory.IDENTITIES, tr("Failed to initialize TeamSpeak based handshake. Error: %o"), error); + logError(LogCategory.IDENTITIES, tr("Failed to initialize TeamSpeak based handshake. Error: %o"), error); if(error instanceof CommandResult) error = error.extra_message || error.message; @@ -260,7 +259,7 @@ export class TeaSpeakHandshakeHandler extends AbstractHandshakeIdentityHandler { this.identity.sign_message(json[0]["message"], json[0]["digest"]).then(proof => { this.connection.send_command("handshakeindentityproof", {proof: proof}).catch(error => { - log.error(LogCategory.IDENTITIES, tr("Failed to proof the identity. Error: %o"), error); + logError(LogCategory.IDENTITIES, tr("Failed to proof the identity. Error: %o"), error); if(error instanceof CommandResult) error = error.extra_message || error.message; @@ -318,7 +317,7 @@ class IdentityPOWWorker { resolve(); }; this._worker.onerror = event => { - log.error(LogCategory.IDENTITIES, tr("POW Worker error %o"), event); + logError(LogCategory.IDENTITIES, tr("POW Worker error %o"), event); clearTimeout(timeout_id); reject("Failed to load worker (" + event.message + ")"); }; @@ -433,7 +432,7 @@ class IdentityPOWWorker { }; }); } catch(error) { - log.error(LogCategory.IDENTITIES, tr("Failed to finalize POW worker! (%o)"), error); + logError(LogCategory.IDENTITIES, tr("Failed to finalize POW worker! (%o)"), error); } } @@ -442,7 +441,7 @@ class IdentityPOWWorker { } private handle_message(message: any) { - log.info(LogCategory.IDENTITIES, tr("Received message: %o"), message); + logInfo(LogCategory.IDENTITIES, tr("Received message: %o"), message); } } @@ -452,7 +451,7 @@ export class TeaSpeakIdentity implements Identity { try { key = await crypto.subtle.generateKey({name:'ECDH', namedCurve: 'P-256'}, true, ["deriveKey"]); } catch(e) { - log.error(LogCategory.IDENTITIES, tr("Could not generate a new key: %o"), e); + logError(LogCategory.IDENTITIES, tr("Could not generate a new key: %o"), e); throw "Failed to generate keypair"; } const private_key = await CryptoHelper.export_ecc_key(key.privateKey, false); @@ -509,7 +508,7 @@ export class TeaSpeakIdentity implements Identity { try { buffer = new Uint8Array(arrayBufferBase64(data)); } catch(error) { - log.error(LogCategory.IDENTITIES, tr("Failed to decode given base64 data (%s)"), data); + logError(LogCategory.IDENTITIES, tr("Failed to decode given base64 data (%s)"), data); throw "failed to base data (base64 decode failed)"; } const key64 = await CryptoHelper.decryptTeaSpeakIdentity(buffer); @@ -538,7 +537,7 @@ export class TeaSpeakIdentity implements Identity { if(this.private_key && (typeof(initialize) === "undefined" || initialize)) { this.initialize().catch(error => { - log.error(LogCategory.IDENTITIES, "Failed to initialize TeaSpeakIdentity (%s)", error); + logError(LogCategory.IDENTITIES, "Failed to initialize TeaSpeakIdentity (%s)", error); this._initialized = false; }); } @@ -698,7 +697,7 @@ export class TeaSpeakIdentity implements Identity { try { await Promise.all(initialize_promise); } catch (error) { - log.error(LogCategory.IDENTITIES, error); + logError(LogCategory.IDENTITIES, error); throw "failed to initialize"; } } @@ -753,7 +752,7 @@ export class TeaSpeakIdentity implements Identity { if (worker.current_level() > best_level) { this.hash_number = worker.current_hash(); - log.info(LogCategory.IDENTITIES, "Found new best at %s (%d). Old was %d", this.hash_number, worker.current_level(), best_level); + logInfo(LogCategory.IDENTITIES, "Found new best at %s (%d). Old was %d", this.hash_number, worker.current_level(), best_level); best_level = worker.current_level(); if (callback_level) callback_level(best_level); @@ -777,7 +776,7 @@ export class TeaSpeakIdentity implements Identity { }).catch(error => { worker_promise.remove(p); - log.warn(LogCategory.IDENTITIES, "POW worker error %o", error); + logWarn(LogCategory.IDENTITIES, "POW worker error %o", error); reject(error); return Promise.resolve(); @@ -803,7 +802,7 @@ export class TeaSpeakIdentity implements Identity { try { await Promise.all(finalize_promise); } catch(error) { - log.error(LogCategory.IDENTITIES, "Failed to shutdown worker: %o", error); + logError(LogCategory.IDENTITIES, "Failed to shutdown worker: %o", error); } } throw "this should never be reached"; @@ -882,14 +881,14 @@ export class TeaSpeakIdentity implements Identity { try { this._crypto_key_sign = await crypto.subtle.importKey("jwk", jwk, {name:'ECDSA', namedCurve: 'P-256'}, false, ["sign"]); } catch(error) { - log.error(LogCategory.IDENTITIES, error); + logError(LogCategory.IDENTITIES, error); throw "failed to create crypto sign key"; } try { this._crypto_key = await crypto.subtle.importKey("jwk", jwk, {name:'ECDH', namedCurve: 'P-256'}, true, ["deriveKey"]); } catch(error) { - log.error(LogCategory.IDENTITIES, error); + logError(LogCategory.IDENTITIES, error); throw "failed to create crypto key"; } @@ -897,7 +896,7 @@ export class TeaSpeakIdentity implements Identity { this.publicKey = await CryptoHelper.export_ecc_key(this._crypto_key, true); this._unique_id = base64_encode_ab(await sha.sha1(this.publicKey)); } catch(error) { - log.error(LogCategory.IDENTITIES, error); + logError(LogCategory.IDENTITIES, error); throw "failed to calculate unique id"; } diff --git a/shared/js/profiles/identities/teaspeak-forum.ts b/shared/js/profiles/identities/teaspeak-forum.ts index ac0ea43b..cec81283 100644 --- a/shared/js/profiles/identities/teaspeak-forum.ts +++ b/shared/js/profiles/identities/teaspeak-forum.ts @@ -1,9 +1,8 @@ import {settings, Settings} from "../../settings"; import * as loader from "tc-loader"; import * as fidentity from "./TeaForumIdentity"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; -import { tr } from "tc-shared/i18n/localize"; +import {LogCategory, logDebug, logError, logInfo, logWarn} from "../../log"; +import {tr} from "tc-shared/i18n/localize"; declare global { interface Window { @@ -48,7 +47,7 @@ export namespace gcaptcha { script.remove(); script = undefined; - console.error(tr("Failed to fetch recaptcha javascript source: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to fetch recaptcha javascript source: %o"), error); throw tr("failed to download source"); } finally { if(script) @@ -66,7 +65,7 @@ export namespace gcaptcha { try { await initialize(); } catch(error) { - console.error(tr("Failed to initialize G-Recaptcha. Error: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to initialize G-Recaptcha. Error: %o"), error); throw tr("initialisation failed"); } if(container.attr("captcha-uuid")) @@ -163,7 +162,7 @@ export async function login(username: string, password: string, captcha?: any) : success: resolve, error: (xhr, status, error) => { - console.log(tr("Login request failed %o: %o"), status, error); + logDebug(LogCategory.GENERAL, tr("Login request failed %o: %o"), status, error); reject(tr("request failed")); } }) @@ -176,7 +175,7 @@ export async function login(username: string, password: string, captcha?: any) : } if(response["status"] !== "ok") { - console.error(tr("Response status not okey. Error happend: %o"), response); + logError(LogCategory.GENERAL, tr("Response status not okey. Error happend: %o"), response); return { status: "error", error_message: (response["errors"] || [])[0] || tr("Unknown error") @@ -184,7 +183,7 @@ export async function login(username: string, password: string, captcha?: any) : } if(!response["success"]) { - console.error(tr("Login failed. Response %o"), response); + logError(LogCategory.GENERAL, tr("Login failed. Response %o"), response); let message = tr("failed to login"); let captcha; @@ -216,7 +215,7 @@ export async function login(username: string, password: string, captcha?: any) : localStorage.setItem("teaspeak-forum-auth", response["auth-key"]); fidentity.update_forum(); } catch(error) { - console.error(tr("Failed to parse forum given data: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to parse forum given data: %o"), error); return { status: "error", error_message: tr("Failed to parse response data") @@ -245,7 +244,7 @@ export async function renew_data() : Promise<"success" | "login-required"> { success: resolve, error: (xhr, status, error) => { - console.log(tr("Renew request failed %o: %o"), status, error); + logError(LogCategory.GENERAL, tr("Renew request failed %o: %o"), status, error); reject(tr("request failed")); } }) @@ -255,7 +254,7 @@ export async function renew_data() : Promise<"success" | "login-required"> { } if(response["status"] !== "ok") { - console.error(tr("Response status not okey. Error happend: %o"), response); + logError(LogCategory.GENERAL, tr("Response status not okey. Error happend: %o"), response); throw (response["errors"] || [])[0] || tr("Unknown error"); } @@ -268,7 +267,7 @@ export async function renew_data() : Promise<"success" | "login-required"> { if(!response["data"] || !response["sign"]) throw tr("response missing data"); - console.debug(tr("Renew succeeded. Parsing data.")); + logDebug(LogCategory.GENERAL, tr("Renew succeeded. Parsing data.")); try { _data = new Data(_data.auth_key, response["data"], response["sign"]); @@ -276,7 +275,7 @@ export async function renew_data() : Promise<"success" | "login-required"> { localStorage.setItem("teaspeak-forum-sign", response["sign"]); fidentity.update_forum(); } catch(error) { - console.error(tr("Failed to parse forum given data: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to parse forum given data: %o"), error); throw tr("failed to parse data"); } @@ -303,7 +302,7 @@ export async function logout() : Promise { success: resolve, error: (xhr, status, error) => { - console.log(tr("Logout request failed %o: %o"), status, error); + logInfo(LogCategory.GENERAL, tr("Logout request failed %o: %o"), status, error); reject(tr("request failed")); } }) @@ -313,7 +312,7 @@ export async function logout() : Promise { } if(response["status"] !== "ok") { - console.error(tr("Response status not okey. Error happend: %o"), response); + logError(LogCategory.GENERAL, tr("Response status not okey. Error happend: %o"), response); throw (response["errors"] || [])[0] || tr("Unknown error"); } @@ -339,53 +338,53 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { const raw_sign = localStorage.getItem("teaspeak-forum-sign"); const forum_auth = localStorage.getItem("teaspeak-forum-auth"); if(!raw_data || !raw_sign || !forum_auth) { - console.log(tr("No TeaForo authentification found. TeaForo connection status: unconnected")); + logInfo(LogCategory.GENERAL, tr("No TeaForo authentification found. TeaForo connection status: unconnected")); return; } try { _data = new Data(forum_auth, raw_data, raw_sign); } catch(error) { - console.error(tr("Failed to initialize TeaForo connection from local data. Error: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to initialize TeaForo connection from local data. Error: %o"), error); return; } if(_data.should_renew()) { - console.info(tr("TeaForo data should be renewed. Executing renew.")); + logInfo(LogCategory.GENERAL, tr("TeaForo data should be renewed. Executing renew.")); renew_data().then(status => { if(status === "success") { - console.info(tr("TeaForo data has been successfully renewed.")); + logInfo(LogCategory.GENERAL, tr("TeaForo data has been successfully renewed.")); } else { - console.warn(tr("Failed to renew TeaForo data. New login required.")); + logWarn(LogCategory.GENERAL, tr("Failed to renew TeaForo data. New login required.")); localStorage.removeItem("teaspeak-forum-data"); localStorage.removeItem("teaspeak-forum-sign"); localStorage.removeItem("teaspeak-forum-auth"); } }).catch(error => { - console.warn(tr("Failed to renew TeaForo data. An error occurred: %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to renew TeaForo data. An error occurred: %o"), error); }); return; } if(_data && _data.is_expired()) { - console.error(tr("TeaForo data is expired. TeaForo connection isn't available!")); + logError(LogCategory.GENERAL, tr("TeaForo data is expired. TeaForo connection isn't available!")); } setInterval(() => { /* if we don't have any _data object set we could not renew anything */ if(_data) { - log.info(LogCategory.IDENTITIES, tr("Renewing TeaForo data.")); + logInfo(LogCategory.IDENTITIES, tr("Renewing TeaForo data.")); renew_data().then(status => { if(status === "success") { - log.info(LogCategory.IDENTITIES,tr("TeaForo data has been successfully renewed.")); + logInfo(LogCategory.IDENTITIES,tr("TeaForo data has been successfully renewed.")); } else { - log.warn(LogCategory.IDENTITIES,tr("Failed to renew TeaForo data. New login required.")); + logWarn(LogCategory.IDENTITIES,tr("Failed to renew TeaForo data. New login required.")); localStorage.removeItem("teaspeak-forum-data"); localStorage.removeItem("teaspeak-forum-sign"); localStorage.removeItem("teaspeak-forum-auth"); } }).catch(error => { - console.warn(tr("Failed to renew TeaForo data. An error occurred: %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to renew TeaForo data. An error occurred: %o"), error); }); } }, 24 * 60 * 60 * 1000); diff --git a/shared/js/proto.ts b/shared/js/proto.ts index 2973aaa4..f604f7c3 100644 --- a/shared/js/proto.ts +++ b/shared/js/proto.ts @@ -1,6 +1,7 @@ /* setup jsrenderer */ import "jsrender"; -import { tr } from "./i18n/localize"; +import {tr} from "./i18n/localize"; +import {LogCategory, logTrace} from "tc-shared/log"; if(__build.target === "web") { (window as any).$ = require("jquery"); @@ -114,11 +115,11 @@ if(!JSON.map_to) { let updates = 0; for (let field of variables) { if (typeof json[field] === "undefined") { - console.trace(tr("Json does not contains %s"), field); + logTrace(LogCategory.GENERAL, tr("Json does not contains %s"), field); continue; } if (!validator(field, json[field])) { - console.trace(tr("Validator results in false for %s"), field); + logTrace(LogCategory.GENERAL, tr("Validator results in false for %s"), field); continue; } diff --git a/shared/js/settings.ts b/shared/js/settings.ts index 596e1cc9..fad2ab63 100644 --- a/shared/js/settings.ts +++ b/shared/js/settings.ts @@ -1,5 +1,5 @@ import * as log from "./log"; -import {LogCategory, logTrace} from "./log"; +import {LogCategory, logError, logTrace} from "./log"; import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {Registry} from "./events"; @@ -82,11 +82,11 @@ function resolveKey( let value = resolver(key.key); if(typeof value === "string") { - return this.decodeValueFromString(value, key.valueType); + return decodeValueFromString(value, key.valueType); } /* trying fallback values */ - for(const fallback of key.fallbackKeys) { + for(const fallback of key.fallbackKeys || []) { value = resolver(fallback); if(typeof value !== "string") { continue; @@ -125,7 +125,7 @@ export namespace AppParameters { search.substr(1).split("&").forEach(part => { let item = part.split("="); - this.staticValues[item[0]] = decodeURIComponent(item[1]); + parameters[item[0]] = decodeURIComponent(item[1]); }); } @@ -793,7 +793,7 @@ export class Settings { try { this.cacheGlobal = JSON.parse(json); } catch(error) { - log.error(LogCategory.GENERAL, tr("Failed to load global settings!\nJson: %s\nError: %o"), json, error); + logError(LogCategory.GENERAL, tr("Failed to load global settings!\nJson: %s\nError: %o"), json, error); const show_popup = () => { //FIXME: Readd this @@ -823,6 +823,7 @@ export class Settings { } else if("defaultValue" in key) { return resolveKey(key, key => this.cacheGlobal[key], key.defaultValue); } else { + debugger; throw tr("missing default value"); } } @@ -900,7 +901,9 @@ export class ServerSettings { this.serverSaveWorker = undefined; } - getValue(key: RegistryKey | ValuedRegistryKey, defaultValue?: DV) : V | DV { + getValue(key: RegistryKey, defaultValue: DV) : V | DV; + getValue(key: ValuedRegistryKey, defaultValue?: V) : V; + getValue(key, defaultValue) { if(this._destroyed) { throw "destroyed"; } @@ -910,6 +913,7 @@ export class ServerSettings { } else if("defaultValue" in key) { return resolveKey(key, key => this.cacheServer[key], key.defaultValue); } else { + debugger; throw tr("missing default value"); } } @@ -950,7 +954,7 @@ export class ServerSettings { try { this.cacheServer = JSON.parse(json); } catch(error) { - log.error(LogCategory.GENERAL, tr("Failed to load server settings for server %s!\nJson: %s\nError: %o"), server_unique_id, json, error); + logError(LogCategory.GENERAL, tr("Failed to load server settings for server %s!\nJson: %s\nError: %o"), server_unique_id, json, error); } if(!this.cacheServer) this.cacheServer = {}; diff --git a/shared/js/sound/Sounds.ts b/shared/js/sound/Sounds.ts index d5f399d8..4e020750 100644 --- a/shared/js/sound/Sounds.ts +++ b/shared/js/sound/Sounds.ts @@ -1,5 +1,5 @@ import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logError, logInfo, logWarn} from "../log"; import {Settings, settings} from "../settings"; import {ConnectionHandler} from "../ConnectionHandler"; import * as sbackend from "tc-backend/audio/sounds"; @@ -199,7 +199,7 @@ export function initialize() : Promise { resolve(); }, error: error => { - log.error(LogCategory.AUDIO, "error: %o", error); + logError(LogCategory.AUDIO, "error: %o", error); reject(); }, timeout: 5000, @@ -239,7 +239,7 @@ export class SoundManager { options = options || {}; const volume = get_sound_volume(_sound, options.default_volume); - log.info(LogCategory.AUDIO, tr("Replaying sound %s (Sound volume: %o | Master volume %o)"), _sound, volume, master_volume); + logInfo(LogCategory.AUDIO, tr("Replaying sound %s (Sound volume: %o | Master volume %o)"), _sound, volume, master_volume); if(volume == 0 || master_volume == 0) return; @@ -251,7 +251,7 @@ export class SoundManager { if(!handle) return; if(!options.ignore_overlap && (this._playing_sounds[handle.filename] > 0) && !overlap_activated()) { - log.info(LogCategory.AUDIO, tr("Dropping requested playback for sound %s because it would overlap."), _sound); + logInfo(LogCategory.AUDIO, tr("Dropping requested playback for sound %s because it would overlap."), _sound); return; } @@ -263,14 +263,14 @@ export class SoundManager { if(options.callback) options.callback(true); }).catch(error => { - log.warn(LogCategory.AUDIO, tr("Failed to replay sound %s: %o"), handle.filename, error); + logWarn(LogCategory.AUDIO, tr("Failed to replay sound %s: %o"), handle.filename, error); if(options.callback) options.callback(false); }).then(() => { this._playing_sounds[handle.filename]--; }); }).catch(error => { - log.warn(LogCategory.AUDIO, tr("Failed to replay sound %o because it could not be resolved: %o"), _sound, error); + logWarn(LogCategory.AUDIO, tr("Failed to replay sound %o because it could not be resolved: %o"), _sound, error); if(options.callback) options.callback(false); }); diff --git a/shared/js/stats.ts b/shared/js/stats.ts index 7453886f..5e61abf7 100644 --- a/shared/js/stats.ts +++ b/shared/js/stats.ts @@ -1,4 +1,4 @@ -import {LogCategory} from "./log"; +import {LogCategory, logDebug, logInfo, logTrace, logWarn} from "./log"; import * as log from "./log"; import { tr } from "./i18n/localize"; @@ -74,7 +74,7 @@ function initialize_config_object(target_object: any, source_object: any) : any export function initialize(config: Config) { current_config = initialize_config_object(config || {}, DEFAULT_CONFIG); if(current_config.verbose) - log.info(LogCategory.STATISTICS, tr("Initializing statistics with this config: %o"), current_config); + logInfo(LogCategory.STATISTICS, tr("Initializing statistics with this config: %o"), current_config); connection.start_connection(); } @@ -108,7 +108,7 @@ namespace connection { if(connection_copy !== connection) return; if(current_config.verbose) - log.warn(LogCategory.STATISTICS, tr("Lost connection to statistics server (Connection closed). Reason: %o. Event object: %o"), CloseCodes[event.code] || event.code, event); + logWarn(LogCategory.STATISTICS, tr("Lost connection to statistics server (Connection closed). Reason: %o. Event object: %o"), CloseCodes[event.code] || event.code, event); if(event.code != CloseCodes.BANNED) invoke_reconnect(); @@ -118,7 +118,7 @@ namespace connection { if(connection_copy !== connection) return; if(current_config.verbose) - log.debug(LogCategory.STATISTICS, tr("Successfully connected to server. Initializing session.")); + logDebug(LogCategory.STATISTICS, tr("Successfully connected to server. Initializing session.")); connection_state = ConnectionState.INITIALIZING; initialize_session(); @@ -128,7 +128,7 @@ namespace connection { if(connection_copy !== connection) return; if(current_config.verbose) - log.warn(LogCategory.STATISTICS, tr("Received an error. Closing connection. Object: %o"), event); + logWarn(LogCategory.STATISTICS, tr("Received an error. Closing connection. Object: %o"), event); connection.close(CloseCodes.INTERNAL_ERROR); invoke_reconnect(); @@ -139,7 +139,7 @@ namespace connection { if(typeof(event.data) !== 'string') { if(current_config.verbose) - log.warn(LogCategory.STATISTICS, tr("Received an message which isn't a string. Event object: %o"), event); + logWarn(LogCategory.STATISTICS, tr("Received an message which isn't a string. Event object: %o"), event); return; } @@ -168,11 +168,11 @@ namespace connection { } if(current_config.verbose) - log.info(LogCategory.STATISTICS, tr("Scheduled reconnect in %dms"), current_config.reconnect_interval); + logInfo(LogCategory.STATISTICS, tr("Scheduled reconnect in %dms"), current_config.reconnect_interval); reconnect_timer = setTimeout(() => { if(current_config.verbose) - log.info(LogCategory.STATISTICS, tr("Reconnecting")); + logInfo(LogCategory.STATISTICS, tr("Reconnecting")); start_connection(); }, current_config.reconnect_interval); } @@ -210,10 +210,10 @@ namespace connection { if(typeof(handler[type]) === 'function') { if(current_config.verbose) - log.trace(LogCategory.STATISTICS, tr("Handling message of type %s"), type); + logTrace(LogCategory.STATISTICS, tr("Handling message of type %s"), type); handler[type](data); } else if(current_config.verbose) { - log.warn(LogCategory.STATISTICS, tr("Received message with an unknown type (%s). Dropping message. Full message: %o"), type, data_object); + logWarn(LogCategory.STATISTICS, tr("Received message with an unknown type (%s). Dropping message. Full message: %o"), type, data_object); } } @@ -229,7 +229,7 @@ namespace connection { interface NotifyInitialized {} function handle_notify_initialized(json: NotifyInitialized) { if(current_config.verbose) - log.info(LogCategory.STATISTICS, tr("Session successfully initialized.")); + logInfo(LogCategory.STATISTICS, tr("Session successfully initialized.")); connection_state = ConnectionState.CONNECTED; } diff --git a/shared/js/text/bbcode/highlight.tsx b/shared/js/text/bbcode/highlight.tsx index 20118d3e..b66276fc 100644 --- a/shared/js/text/bbcode/highlight.tsx +++ b/shared/js/text/bbcode/highlight.tsx @@ -12,10 +12,11 @@ import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMe import '!style-loader!css-loader!highlight.js/styles/darcula.css'; import {Settings, settings} from "tc-shared/settings"; +import {LogCategory, logWarn} from "tc-shared/log"; const registerLanguage = (name, language: Promise) => { language.then(lan => hljs.registerLanguage(name, lan)).catch(error => { - console.warn("Failed to load language %s (%o)", name, error); + logWarn(LogCategory.CHAT, tr("Failed to load language %s (%o)"), name, error); }); }; diff --git a/shared/js/text/chat.ts b/shared/js/text/chat.ts index ceaf9c0a..3367c752 100644 --- a/shared/js/text/chat.ts +++ b/shared/js/text/chat.ts @@ -108,7 +108,6 @@ export function preprocessChatMessageForSend(message: string) : string { break; } } - console.error("Message: %s; No Parse: %s", message, noParseRanges); message = bbcodeLinkUrls(message, noParseRanges); } diff --git a/shared/js/text/markdown.ts b/shared/js/text/markdown.ts index e75cc7f6..d666e8e1 100644 --- a/shared/js/text/markdown.ts +++ b/shared/js/text/markdown.ts @@ -1,5 +1,5 @@ import * as log from "../log"; -import {LogCategory, logTrace} from "../log"; +import {LogCategory, logDebug, logTrace, logWarn} from "../log"; import { CodeToken, Env, @@ -135,10 +135,10 @@ export class MD2BBCodeRenderer { } private renderToken(token: Token) { - log.debug(LogCategory.GENERAL, tr("Render Markdown token: %o"), token); + logDebug(LogCategory.GENERAL, tr("Render Markdown token: %o"), token); const renderer = MD2BBCodeRenderer.renderers[token.type]; if(typeof(renderer) === "undefined") { - log.warn(LogCategory.CHAT, tr("Missing markdown to bbcode renderer for token %s: %o"), token.type, token); + logWarn(LogCategory.CHAT, tr("Missing markdown to bbcode renderer for token %s: %o"), token.type, token); return 'content' in token ? this.options().textProcessor(token.content) : ""; } diff --git a/shared/js/tree/Channel.ts b/shared/js/tree/Channel.ts index 81756b6e..e2091e53 100644 --- a/shared/js/tree/Channel.ts +++ b/shared/js/tree/Channel.ts @@ -1,7 +1,7 @@ import {ChannelTree} from "./ChannelTree"; import {ClientEntry, ClientEvents} from "./Client"; import * as log from "../log"; -import {LogCategory, LogType} from "../log"; +import {LogCategory, logInfo, LogType, logWarn} from "../log"; import {PermissionType} from "../permission/PermissionType"; import {settings, Settings} from "../settings"; import * as contextmenu from "../ui/elements/ContextMenu"; @@ -223,7 +223,7 @@ export class ChannelEntry extends ChannelTreeEntry { }); this.collapsed = this.channelTree.client.settings.getValue(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId)); - this.subscriptionMode = this.channelTree.client.settings.getValue(Settings.FN_SERVER_CHANNEL_SUBSCRIBE_MODE(this.channelId)); + this.subscriptionMode = this.channelTree.client.settings.getValue(Settings.FN_SERVER_CHANNEL_SUBSCRIBE_MODE(this.channelId), ChannelSubscribeMode.INHERITED); this.channelDescriptionCached = false; this.channelDescriptionCallback = []; @@ -310,7 +310,7 @@ export class ChannelEntry extends ChannelTreeEntry { unregisterClient(client: ClientEntry, noEvent?: boolean) { client.events.off("notify_properties_updated", this.clientPropertyChangedListener); if(!this.client_list.remove(client)) { - log.warn(LogCategory.CHANNEL, tr("Unregistered unknown client from channel %s"), this.channelName()); + logWarn(LogCategory.CHANNEL, tr("Unregistered unknown client from channel %s"), this.channelName()); } } @@ -508,7 +508,7 @@ export class ChannelEntry extends ChannelTreeEntry { this.channelTree.client.serverConnection.send_command("channeledit", properties).then(() => { this.channelTree.client.sound.play(Sound.CHANNEL_EDITED_SELF); }); - log.info(LogCategory.CHANNEL, tr("Changed channel properties of channel %s: %o"), this.channelName(), properties); + logInfo(LogCategory.CHANNEL, tr("Changed channel properties of channel %s: %o"), this.channelName(), properties); } if(permissions.length > 0) { @@ -720,7 +720,6 @@ export class ChannelEntry extends ChannelTreeEntry { cached_password() { return this.cachedPasswordHash; } async updateSubscribeMode() { - console.error("Update subscribe mode"); let shouldBeSubscribed = false; switch (this.subscriptionMode) { case ChannelSubscribeMode.INHERITED: diff --git a/shared/js/tree/ChannelTree.tsx b/shared/js/tree/ChannelTree.tsx index 132a38db..50879272 100644 --- a/shared/js/tree/ChannelTree.tsx +++ b/shared/js/tree/ChannelTree.tsx @@ -1,7 +1,6 @@ import * as contextmenu from "tc-shared/ui/elements/ContextMenu"; import {MenuEntryType} from "tc-shared/ui/elements/ContextMenu"; -import * as log from "tc-shared/log"; -import {LogCategory, logError, logWarn} from "tc-shared/log"; +import {LogCategory, logDebug, logError, logWarn} from "tc-shared/log"; import {PermissionType} from "tc-shared/permission/PermissionType"; import {Sound} from "tc-shared/sound/Sounds"; import {Group} from "tc-shared/permission/GroupManager"; @@ -236,12 +235,12 @@ export class ChannelTree { batch_updates(BatchUpdateType.CHANNEL_TREE); try { if(!this.channels.remove(channel)) { - log.warn(LogCategory.CHANNEL, tr("Deleting an unknown channel!")); + logWarn(LogCategory.CHANNEL, tr("Deleting an unknown channel!")); } channel.children(false).forEach(e => this.deleteChannel(e)); if(channel.clients(false).length !== 0) { - log.warn(LogCategory.CHANNEL, tr("Deleting a non empty channel! This could cause some errors.")); + logWarn(LogCategory.CHANNEL, tr("Deleting a non empty channel! This could cause some errors.")); for(const client of channel.clients(false)) { this.deleteClient(client, { reason: ViewReasonId.VREASON_SYSTEM, serverLeave: false }); } @@ -308,7 +307,7 @@ export class ChannelTree { moveChannel(channel: ChannelEntry, channelPrevious: ChannelEntry, parent: ChannelEntry, isInsertMove: boolean) { if(channelPrevious != null && channelPrevious.parent != parent) { - console.error(tr("Invalid channel move (different parents! (%o|%o)"), channelPrevious.parent, parent); + logError(LogCategory.CHANNEL, tr("Invalid channel move (different parents! (%o|%o)"), channelPrevious.parent, parent); return; } @@ -890,11 +889,11 @@ export class ChannelTree { spawnCreateChannel(parent?: ChannelEntry) { spawnChannelEditNew(this.client, undefined, parent, (properties, permissions) => { properties["cpid"] = parent ? parent.channelId : 0; - log.debug(LogCategory.CHANNEL, tr("Creating a new channel.\nProperties: %o\nPermissions: %o"), properties); + logDebug(LogCategory.CHANNEL, tr("Creating a new channel.\nProperties: %o\nPermissions: %o"), properties); this.client.serverConnection.send_command("channelcreate", properties).then(() => { let channel = this.find_channel_by_name(properties.channel_name, parent, true); if(!channel) { - log.error(LogCategory.CHANNEL, tr("Failed to resolve channel after creation. Could not apply permissions!")); + logError(LogCategory.CHANNEL, tr("Failed to resolve channel after creation. Could not apply permissions!")); return; } @@ -947,11 +946,11 @@ export class ChannelTree { if(channels.length > 0) { this.client.serverConnection.send_command('channelsubscribe', channels.map(e => { return {cid: e}; })).catch(error => { - console.warn(tr("Failed to subscribe to specific channels (%o): %o"), channels, error); + logWarn(LogCategory.NETWORKING, tr("Failed to subscribe to specific channels (%o): %o"), channels, error); }); } }).catch(error => { - console.warn(tr("Failed to unsubscribe to all channels! (%o)"), error); + logWarn(LogCategory.NETWORKING, tr("Failed to unsubscribe to all channels! (%o)"), error); }); } @@ -969,11 +968,11 @@ export class ChannelTree { if(channels.length > 0) { this.client.serverConnection.send_command('channelunsubscribe', channels.map(e => { return {cid: e}; })).catch(error => { - console.warn(tr("Failed to unsubscribe to specific channels (%o): %o"), channels, error); + logWarn(LogCategory.CHANNEL, tr("Failed to unsubscribe to specific channels (%o): %o"), channels, error); }); } }).catch(error => { - console.warn(tr("Failed to subscribe to all channels! (%o)"), error); + logWarn(LogCategory.CHANNEL, tr("Failed to subscribe to all channels! (%o)"), error); }); } diff --git a/shared/js/tree/Client.ts b/shared/js/tree/Client.ts index f67f3c41..1ec2217f 100644 --- a/shared/js/tree/Client.ts +++ b/shared/js/tree/Client.ts @@ -2,7 +2,7 @@ import * as contextmenu from "../ui/elements/ContextMenu"; import {Registry} from "../events"; import {ChannelTree} from "./ChannelTree"; import * as log from "../log"; -import {LogCategory, logInfo, LogType} from "../log"; +import {LogCategory, logDebug, logError, logInfo, LogType} from "../log"; import {Settings, settings} from "../settings"; import {Sound} from "../sound/Sounds"; import {Group, GroupManager, GroupTarget, GroupType} from "../permission/GroupManager"; @@ -219,11 +219,11 @@ export class ClientEntry extends Cha destroy() { if(this.voiceHandle) { - log.error(LogCategory.AUDIO, tr("Destroying client with an active audio handle. This could cause memory leaks!")); + logError(LogCategory.AUDIO, tr("Destroying client with an active audio handle. This could cause memory leaks!")); this.setVoiceClient(undefined); } if(this.videoHandle) { - log.error(LogCategory.AUDIO, tr("Destroying client with an active video handle. This could cause memory leaks!")); + logError(LogCategory.AUDIO, tr("Destroying client with an active video handle. This could cause memory leaks!")); this.setVideoClient(undefined); } @@ -767,7 +767,7 @@ export class ClientEntry extends Cha const mute_status = this.channelTree.client.settings.getValue(Settings.FN_CLIENT_MUTED(this.clientUid()), false); this.setMuted(mute_status, mute_status); /* force only needed when we want to mute the client */ this.updateVoiceVolume(); - log.debug(LogCategory.CLIENT, tr("Loaded client (%s) server specific properties. Volume: %o Muted: %o."), this.clientUid(), this.voiceVolume, this.voiceMuted); + logDebug(LogCategory.CLIENT, tr("Loaded client (%s) server specific properties. Volume: %o Muted: %o."), this.clientUid(), this.voiceVolume, this.voiceMuted); } if(variable.key == "client_talk_power") { reorder_channel = true; diff --git a/shared/js/tree/Server.ts b/shared/js/tree/Server.ts index c460f60b..c7023684 100644 --- a/shared/js/tree/Server.ts +++ b/shared/js/tree/Server.ts @@ -2,7 +2,7 @@ import {ChannelTree} from "./ChannelTree"; import {Settings, settings} from "../settings"; import * as contextmenu from "../ui/elements/ContextMenu"; import * as log from "../log"; -import {LogCategory, LogType} from "../log"; +import {LogCategory, logInfo, LogType} from "../log"; import {Sound} from "../sound/Sounds"; import * as bookmarks from "../bookmarks"; import {spawnInviteEditor} from "../ui/modal/ModalInvite"; @@ -228,8 +228,7 @@ export class ServerEntry extends ChannelTreeEntry { name: tr("Edit"), callback: () => { createServerModal(this, properties => { - log.info(LogCategory.SERVER, tr("Changing server properties %o"), properties); - console.log(tr("Changed properties: %o"), properties); + logInfo(LogCategory.SERVER, tr("Changing server properties %o"), properties); if (Object.keys(properties || {}).length > 0) { return this.channelTree.client.serverConnection.send_command("serveredit", properties).then(() => { this.channelTree.client.sound.play(Sound.SERVER_EDITED_SELF); diff --git a/shared/js/ui/AppRenderer.tsx b/shared/js/ui/AppRenderer.tsx index 2a0d08d0..d10976f3 100644 --- a/shared/js/ui/AppRenderer.tsx +++ b/shared/js/ui/AppRenderer.tsx @@ -1,4 +1,5 @@ import * as React from "react"; +import {useEffect, useState} from "react"; import {ControlBar2} from "tc-shared/ui/frames/control-bar/Renderer"; import {Registry} from "tc-shared/events"; import {ControlBarEvents} from "tc-shared/ui/frames/control-bar/Definitions"; @@ -15,7 +16,6 @@ import {FooterRenderer} from "tc-shared/ui/frames/footer/Renderer"; import {HostBanner} from "tc-shared/ui/frames/HostBannerRenderer"; import {HostBannerUiEvents} from "tc-shared/ui/frames/HostBannerDefinitions"; import {AppUiEvents} from "tc-shared/ui/AppDefinitions"; -import {useEffect, useState} from "react"; import {ChannelTreeRenderer} from "tc-shared/ui/tree/Renderer"; import {ChannelTreeUIEvents} from "tc-shared/ui/tree/Definitions"; diff --git a/shared/js/ui/ContextMenu.ts b/shared/js/ui/ContextMenu.ts index 2c1c69f9..3edcb770 100644 --- a/shared/js/ui/ContextMenu.ts +++ b/shared/js/ui/ContextMenu.ts @@ -1,6 +1,6 @@ import {RemoteIcon} from "tc-shared/file/Icons"; import {ClientIcon} from "svg-sprites/client-icons"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export type MenuEntryLabel = { text: string, diff --git a/shared/js/ui/elements/ContextDivider.ts b/shared/js/ui/elements/ContextDivider.ts index 877fb8f0..8de1df19 100644 --- a/shared/js/ui/elements/ContextDivider.ts +++ b/shared/js/ui/elements/ContextDivider.ts @@ -1,7 +1,6 @@ import {Settings, settings} from "../../settings"; -import {LogCategory} from "../../log"; -import * as log from "../../log"; -import { tr } from "tc-shared/i18n/localize"; +import {LogCategory, logDebug, logError} from "../../log"; +import {tr} from "tc-shared/i18n/localize"; declare global { interface JQuery { @@ -132,12 +131,12 @@ if(!$.fn.dividerfy) { try { const config = JSON.parse(settings.getValue(Settings.FN_SEPARATOR_STATE(seperator_id), undefined)); if(config) { - log.debug(LogCategory.GENERAL, tr("Applying previous changed sperator settings for %s: %o"), seperator_id, config); + logDebug(LogCategory.GENERAL, tr("Applying previous changed sperator settings for %s: %o"), seperator_id, config); apply_view(config.property, config.previous, config.next); } } catch(e) { if(!(e instanceof SyntaxError)) - log.error(LogCategory.GENERAL, tr("Failed to parse seperator settings for sperator %s: %o"), seperator_id, e); + logError(LogCategory.GENERAL, tr("Failed to parse seperator settings for sperator %s: %o"), seperator_id, e); } } }); diff --git a/shared/js/ui/elements/ContextMenu.ts b/shared/js/ui/elements/ContextMenu.ts index 47d613e5..04003493 100644 --- a/shared/js/ui/elements/ContextMenu.ts +++ b/shared/js/ui/elements/ContextMenu.ts @@ -1,5 +1,6 @@ import {closeContextMenu, ContextMenuEntry, spawnContextMenu} from "tc-shared/ui/ContextMenu"; import {ClientIcon} from "svg-sprites/client-icons"; +import {LogCategory, logError} from "tc-shared/log"; export interface MenuEntry { callback?: () => void; @@ -57,7 +58,7 @@ export interface ContextMenuProvider { let provider: ContextMenuProvider; export function spawn_context_menu(x: number, y: number, ...entries: MenuEntry[]) { if(!provider) { - console.error(tr("Failed to spawn context menu! Missing provider!")); + logError(LogCategory.GENERAL, tr("Failed to spawn context menu! Missing provider!")); return; } diff --git a/shared/js/ui/elements/Modal.ts b/shared/js/ui/elements/Modal.ts index 040eb422..2af2d107 100644 --- a/shared/js/ui/elements/Modal.ts +++ b/shared/js/ui/elements/Modal.ts @@ -2,6 +2,7 @@ import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {KeyCode} from "../../PPTListener"; import * as $ from "jquery"; +import {LogCategory, logError} from "tc-shared/log"; export enum ElementType { HEADER, @@ -40,7 +41,7 @@ export const ModalFunctions = { case "undefined": return undefined; default: - console.error(("Invalid type %o"), typeof val); + logError(LogCategory.GENERAL, "Invalid type %o", typeof val); return $(); } }, @@ -210,7 +211,6 @@ export class Modal { const body = ModalFunctions.jqueriefy(this.properties.body, ElementType.BODY); const footer = ModalFunctions.jqueriefy(this.properties.footer, ElementType.FOOTER); - //FIXME: cache template const template = $(this.properties.template || "#tmpl_modal"); const properties = { diff --git a/shared/js/ui/elements/NetGraph.ts b/shared/js/ui/elements/NetGraph.ts index 778746f8..558298f4 100644 --- a/shared/js/ui/elements/NetGraph.ts +++ b/shared/js/ui/elements/NetGraph.ts @@ -1,3 +1,5 @@ +import {LogCategory, logDebug} from "tc-shared/log"; + export type Entry = { timestamp: number; @@ -120,10 +122,11 @@ export class Graph { if(Graph._loops.length == 1) { const static_loop = () => { Graph._loops.forEach(l => l()); - if(Graph._loops.length > 0) + if(Graph._loops.length > 0) { requestAnimationFrame(static_loop); - else - console.log("STATIC terminate!"); + } else { + logDebug(LogCategory.GENERAL, tr("NetGraph static terminate")); + } }; static_loop(); } diff --git a/shared/js/ui/elements/Slider.ts b/shared/js/ui/elements/Slider.ts index 2ac0ff7a..84e32797 100644 --- a/shared/js/ui/elements/Slider.ts +++ b/shared/js/ui/elements/Slider.ts @@ -66,7 +66,6 @@ export function sliderfy(slider: JQuery, options?: SliderOptions) : Slider { tool.hide(); slider.removeClass("active"); - console.log("Events removed"); }; const mouse_listener = (event: MouseEvent | TouchEvent) => { diff --git a/shared/js/ui/elements/Tab.ts b/shared/js/ui/elements/Tab.ts index 109476b5..fb11b6a3 100644 --- a/shared/js/ui/elements/Tab.ts +++ b/shared/js/ui/elements/Tab.ts @@ -1,3 +1,5 @@ +import {LogCategory, logWarn} from "tc-shared/log"; + declare global { interface JQuery { asTabWidget(copy?: boolean) : JQuery; @@ -19,17 +21,14 @@ if(typeof (customElements) !== "undefined") { customElements.define('x-tag', X_Tag, { extends: 'div' }); customElements.define('x-content', X_Content, { extends: 'div' }); } catch(error) { - console.warn("failed to define costum elements"); + logWarn(LogCategory.GENERAL, tr("failed to define costume elements")); } } else { - console.warn(tr("Could not defied tab customElements!")); + logWarn(LogCategory.GENERAL, tr("Could not defied tab customElements!")); } export const TabFunctions = { tabify(template: JQuery, copy: boolean = true) : JQuery { - console.log("Tabify: copy=" + copy); - console.log(template); - let tag = $.spawn("div"); tag.addClass("tab"); @@ -48,7 +47,6 @@ export const TabFunctions = { const update_height = () => { const height_watcher = tag.find("> .tab-content .height-watcher"); const entries: JQuery = tag.find("> .tab-content-invisible x-content, > .tab-content x-content"); - console.error(entries); let max_height = 0; entries.each((_, _e) => { @@ -92,8 +90,6 @@ export const TabFunctions = { } else { element.first().trigger('click'); } - console.log("Next: %o", tag_header.next('.entry:visible')); - console.log("prev: %o", tag_header.prev('.entry:visible')); } }); } @@ -111,7 +107,6 @@ export const TabFunctions = { let entries = tag_content.find(".tab-show-partitional"); entries.hide(); const show_next = index => { - console.log("Show " + index); if(index >= entries.length) return; entries.eq(index).show(); @@ -123,7 +118,6 @@ export const TabFunctions = { tag_content.show(); }); - console.log(this); header.append(tag_header); }); diff --git a/shared/js/ui/frames/HostBannerRenderer.tsx b/shared/js/ui/frames/HostBannerRenderer.tsx index 71173598..1a423dcd 100644 --- a/shared/js/ui/frames/HostBannerRenderer.tsx +++ b/shared/js/ui/frames/HostBannerRenderer.tsx @@ -4,7 +4,7 @@ import * as React from "react"; import {useEffect, useRef, useState} from "react"; import {useGlobalSetting, useTr} from "tc-shared/ui/react-elements/Helper"; import {ErrorBoundary} from "tc-shared/ui/react-elements/ErrorBoundary"; -import {Settings, settings} from "tc-shared/settings"; +import {Settings} from "tc-shared/settings"; const cssStyle = require("./HostBannerRenderer.scss"); diff --git a/shared/js/ui/frames/SideBarRenderer.tsx b/shared/js/ui/frames/SideBarRenderer.tsx index d07c0aac..bab53ceb 100644 --- a/shared/js/ui/frames/SideBarRenderer.tsx +++ b/shared/js/ui/frames/SideBarRenderer.tsx @@ -7,10 +7,10 @@ import {ClientInfoRenderer} from "tc-shared/ui/frames/side/ClientInfoRenderer"; import {PrivateConversationsPanel} from "tc-shared/ui/frames/side/PrivateConversationRenderer"; import {ChannelBarRenderer} from "tc-shared/ui/frames/side/ChannelBarRenderer"; import {LogCategory, logWarn} from "tc-shared/log"; -import React = require("react"); import {ErrorBoundary} from "tc-shared/ui/react-elements/ErrorBoundary"; import {MusicBotRenderer} from "tc-shared/ui/frames/side/MusicBotRenderer"; import {ConversationPanel} from "tc-shared/ui/frames/side/AbstractConversationRenderer"; +import React = require("react"); const cssStyle = require("./SideBarRenderer.scss"); diff --git a/shared/js/ui/frames/chat.ts b/shared/js/ui/frames/chat.ts index 4f1b5e76..626f23d4 100644 --- a/shared/js/ui/frames/chat.ts +++ b/shared/js/ui/frames/chat.ts @@ -1,8 +1,7 @@ -import {LogCategory} from "../../log"; +import {LogCategory, logWarn} from "../../log"; import {settings, Settings} from "../../settings"; -import * as log from "../../log"; import * as loader from "tc-loader"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export enum ChatType { GENERAL, @@ -83,7 +82,7 @@ export function formatMessage(pattern: string, ...objects: any[]) : JQuery[] { } if(objects.length < number) - log.warn(LogCategory.GENERAL, tr("Message to format contains invalid index (%o)"), number); + logWarn(LogCategory.GENERAL, tr("Message to format contains invalid index (%o)"), number); result.push(...formatElement(objects[number])); } @@ -136,7 +135,7 @@ export function parseMessageWithArguments(pattern: string, argumentCount: number } if(argumentCount < number) { - log.warn(LogCategory.GENERAL, tr("Message to format contains invalid index (%o)"), number); + logWarn(LogCategory.GENERAL, tr("Message to format contains invalid index (%o)"), number); result.push("{" + offset.toString() + "}"); } else { result.push(number); diff --git a/shared/js/ui/frames/connection-handler-list/Controller.ts b/shared/js/ui/frames/connection-handler-list/Controller.ts index de0db0c0..fcbf2cfc 100644 --- a/shared/js/ui/frames/connection-handler-list/Controller.ts +++ b/shared/js/ui/frames/connection-handler-list/Controller.ts @@ -3,7 +3,7 @@ import {ConnectionListUIEvents, HandlerConnectionState} from "tc-shared/ui/frame import {server_connections} from "tc-shared/ConnectionManager"; import {LogCategory, logWarn} from "tc-shared/log"; import {ConnectionState} from "tc-shared/ConnectionHandler"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function initializeConnectionListController(events: Registry) { let registeredHandlerEvents: {[key: string]:(() => void)[]} = {}; diff --git a/shared/js/ui/frames/control-bar/Button.tsx b/shared/js/ui/frames/control-bar/Button.tsx index 24bbd15a..5813f0d6 100644 --- a/shared/js/ui/frames/control-bar/Button.tsx +++ b/shared/js/ui/frames/control-bar/Button.tsx @@ -2,6 +2,7 @@ import * as React from "react"; import {ReactComponentBase} from "tc-shared/ui/react-elements/ReactComponentBase"; import {DropdownContainer} from "./DropDown"; import {ClientIcon} from "svg-sprites/client-icons"; + const cssStyle = require("./Button.scss"); export interface ButtonState { diff --git a/shared/js/ui/frames/control-bar/Controller.ts b/shared/js/ui/frames/control-bar/Controller.ts index d9d7d571..d6a23c5c 100644 --- a/shared/js/ui/frames/control-bar/Controller.ts +++ b/shared/js/ui/frames/control-bar/Controller.ts @@ -3,7 +3,8 @@ import { Bookmark, ControlBarEvents, ControlBarMode, - HostButtonInfo, VideoDeviceInfo, + HostButtonInfo, + VideoDeviceInfo, VideoState } from "tc-shared/ui/frames/control-bar/Definitions"; import {server_connections} from "tc-shared/ConnectionManager"; @@ -23,7 +24,7 @@ import { import {LogCategory, logWarn} from "tc-shared/log"; import {createErrorModal, createInputModal} from "tc-shared/ui/elements/Modal"; import {VideoBroadcastType, VideoConnectionStatus} from "tc-shared/connection/VideoConnection"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; import {getVideoDriver} from "tc-shared/video/VideoSource"; import {kLocalBroadcastChannels} from "tc-shared/ui/frames/video/Definitions"; @@ -412,7 +413,6 @@ export function initializeControlBarController(events: Registry { if(infoHandler.getCurrentHandler()) { - /* TODO: Just update the stream and don't "rebroadcast" */ global_client_actions.fire("action_toggle_video_broadcasting", { connection: infoHandler.getCurrentHandler(), broadcastType: event.broadcastType, diff --git a/shared/js/ui/frames/control-bar/DropDown.tsx b/shared/js/ui/frames/control-bar/DropDown.tsx index 28cbb98e..796ed945 100644 --- a/shared/js/ui/frames/control-bar/DropDown.tsx +++ b/shared/js/ui/frames/control-bar/DropDown.tsx @@ -2,6 +2,7 @@ import * as React from "react"; import {ReactComponentBase} from "tc-shared/ui/react-elements/ReactComponentBase"; import {IconRenderer, RemoteIconRenderer} from "tc-shared/ui/react-elements/Icon"; import {getIconManager, RemoteIconInfo} from "tc-shared/file/Icons"; + const cssStyle = require("./Button.scss"); export interface DropdownEntryProperties { diff --git a/shared/js/ui/frames/control-bar/Renderer.tsx b/shared/js/ui/frames/control-bar/Renderer.tsx index 38ce7020..235183ad 100644 --- a/shared/js/ui/frames/control-bar/Renderer.tsx +++ b/shared/js/ui/frames/control-bar/Renderer.tsx @@ -6,7 +6,8 @@ import { ControlBarEvents, ControlBarMode, HostButtonInfo, - MicrophoneState, VideoDeviceInfo, + MicrophoneState, + VideoDeviceInfo, VideoState } from "tc-shared/ui/frames/control-bar/Definitions"; import * as React from "react"; diff --git a/shared/js/ui/frames/footer/Renderer.tsx b/shared/js/ui/frames/footer/Renderer.tsx index 51cda798..698c57ba 100644 --- a/shared/js/ui/frames/footer/Renderer.tsx +++ b/shared/js/ui/frames/footer/Renderer.tsx @@ -1,7 +1,6 @@ import * as React from "react"; +import {useMemo} from "react"; import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; -import {useEffect, useMemo, useState} from "react"; -import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {server_connections} from "tc-shared/ConnectionManager"; import {StatusController} from "tc-shared/ui/frames/footer/StatusController"; import {ConnectionStatusEvents} from "tc-shared/ui/frames/footer/StatusDefinitions"; @@ -23,8 +22,8 @@ const VersionsRenderer = () => ( ); -/* FIXME: Outsource this! */ const RtcStatus = () => { + /* FIXME: Outsource this! */ const statusController = useMemo(() => new StatusController(new Registry()), []); statusController.setConnectionHandler(server_connections.getActiveConnectionHandler()); diff --git a/shared/js/ui/frames/footer/StatusController.ts b/shared/js/ui/frames/footer/StatusController.ts index 76da3893..5a541f09 100644 --- a/shared/js/ui/frames/footer/StatusController.ts +++ b/shared/js/ui/frames/footer/StatusController.ts @@ -4,7 +4,7 @@ import {Registry} from "tc-shared/events"; import {VoiceConnectionStatus} from "tc-shared/connection/VoiceConnection"; import {VideoConnectionStatus} from "tc-shared/connection/VideoConnection"; import {LogCategory, logError} from "tc-shared/log"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; enum StatusNotifyState { /* no notify has been scheduled */ diff --git a/shared/js/ui/frames/footer/StatusRenderer.tsx b/shared/js/ui/frames/footer/StatusRenderer.tsx index 72286fa3..e1463020 100644 --- a/shared/js/ui/frames/footer/StatusRenderer.tsx +++ b/shared/js/ui/frames/footer/StatusRenderer.tsx @@ -8,7 +8,6 @@ import * as React from "react"; import {useContext, useEffect, useRef, useState} from "react"; import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; import {network} from "tc-shared/ui/frames/chat"; -import {date_format} from "tc-shared/utils/DateUtils"; const cssStyle = require("./Renderer.scss"); export const StatusEvents = React.createContext>(undefined); diff --git a/shared/js/ui/frames/log/Renderer.tsx b/shared/js/ui/frames/log/Renderer.tsx index 2269bebc..57d64cd4 100644 --- a/shared/js/ui/frames/log/Renderer.tsx +++ b/shared/js/ui/frames/log/Renderer.tsx @@ -1,7 +1,7 @@ import {VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; import {Registry} from "tc-shared/events"; -import {useContext, useEffect, useRef, useState} from "react"; import * as React from "react"; +import {useContext, useEffect, useRef, useState} from "react"; import {findLogEventRenderer} from "./RendererEvent"; import {LogMessage} from "tc-shared/connectionlog/Definitions"; import {ServerEventLogUiEvents} from "tc-shared/ui/frames/log/Definitions"; diff --git a/shared/js/ui/frames/log/RendererEvent.tsx b/shared/js/ui/frames/log/RendererEvent.tsx index 523ebbd9..2b2c6e13 100644 --- a/shared/js/ui/frames/log/RendererEvent.tsx +++ b/shared/js/ui/frames/log/RendererEvent.tsx @@ -5,7 +5,6 @@ import {formatDate} from "tc-shared/MessageFormatter"; import {BBCodeRenderer} from "tc-shared/text/bbcode"; import {format_time} from "tc-shared/ui/frames/chat"; import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration"; -import {XBBCodeRenderer} from "vendor/xbbcode/react"; import {ChannelTag, ClientTag} from "tc-shared/ui/tree/EntryTags"; import {EventChannelData, EventClient, EventType, TypeInfo} from "tc-shared/connectionlog/Definitions"; diff --git a/shared/js/ui/frames/menu-bar/MainMenu.ts b/shared/js/ui/frames/menu-bar/MainMenu.ts index 7a26c0ab..f14b531f 100644 --- a/shared/js/ui/frames/menu-bar/MainMenu.ts +++ b/shared/js/ui/frames/menu-bar/MainMenu.ts @@ -15,7 +15,7 @@ import { DirectoryBookmark } from "tc-shared/bookmarks"; import {getBackend} from "tc-shared/backend"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; function renderConnectionItems() { const items: MenuBarEntry[] = []; diff --git a/shared/js/ui/frames/side/AbstractConversationController.ts b/shared/js/ui/frames/side/AbstractConversationController.ts index 46d68371..d86d3eef 100644 --- a/shared/js/ui/frames/side/AbstractConversationController.ts +++ b/shared/js/ui/frames/side/AbstractConversationController.ts @@ -1,16 +1,12 @@ -import { - ChatHistoryState, - AbstractConversationUiEvents -} from "./AbstractConversationDefinitions"; +import {AbstractConversationUiEvents, ChatHistoryState} from "./AbstractConversationDefinitions"; import {EventHandler, Registry} from "../../../events"; -import * as log from "../../../log"; -import {LogCategory} from "../../../log"; -import {tra, tr} from "../../../i18n/localize"; +import {LogCategory, logError} from "../../../log"; +import {tr, tra} from "../../../i18n/localize"; import { AbstractChat, - AbstractConversationEvents, AbstractChatManager, - AbstractChatManagerEvents + AbstractChatManagerEvents, + AbstractConversationEvents } from "tc-shared/conversations/AbstractConversion"; export const kMaxChatFrameMessageSize = 50; /* max 100 messages, since the server does not support more than 100 messages queried at once */ @@ -288,7 +284,7 @@ export abstract class AbstractConversationController< chatId: event.chatId }); - log.error(LogCategory.CLIENT, tr("Tried to query history for an unknown conversation with id %s"), event.chatId); + logError(LogCategory.CLIENT, tr("Tried to query history for an unknown conversation with id %s"), event.chatId); return; } @@ -305,7 +301,7 @@ export abstract class AbstractConversationController< protected handleSendMessage(event: AbstractConversationUiEvents["action_send_message"]) { const conversation = this.conversationManager?.findConversationById(event.chatId); if(!conversation) { - log.error(LogCategory.CLIENT, tr("Tried to send a chat message to an unknown conversation with id %s"), event.chatId); + logError(LogCategory.CLIENT, tr("Tried to send a chat message to an unknown conversation with id %s"), event.chatId); return; } @@ -316,7 +312,7 @@ export abstract class AbstractConversationController< protected handleJumpToPresent(event: AbstractConversationUiEvents["action_jump_to_present"]) { const conversation = this.conversationManager?.findConversationById(event.chatId); if(!conversation) { - log.error(LogCategory.CLIENT, tr("Tried to jump to present for an unknown conversation with id %s"), event.chatId); + logError(LogCategory.CLIENT, tr("Tried to jump to present for an unknown conversation with id %s"), event.chatId); return; } diff --git a/shared/js/ui/frames/side/AbstractConversationRenderer.tsx b/shared/js/ui/frames/side/AbstractConversationRenderer.tsx index 9b2afe07..1095c9e0 100644 --- a/shared/js/ui/frames/side/AbstractConversationRenderer.tsx +++ b/shared/js/ui/frames/side/AbstractConversationRenderer.tsx @@ -1,21 +1,22 @@ import * as React from "react"; -import {EventHandler, ReactEventHandler, Registry} from "tc-shared/events"; import {Ref, useEffect, useRef, useState} from "react"; +import {EventHandler, ReactEventHandler, Registry} from "tc-shared/events"; import {AvatarRenderer} from "tc-shared/ui/react-elements/Avatar"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; import {Countdown} from "tc-shared/ui/react-elements/Countdown"; import { + AbstractConversationUiEvents, ChatEvent, ChatEventLocalAction, ChatEventLocalUserSwitch, ChatEventMessageSendFailed, + ChatEventModeChanged, + ChatEventPartnerAction, ChatEventPartnerInstanceChanged, ChatEventQueryFailed, - ChatEventPartnerAction, ChatHistoryState, - ChatMessage, - AbstractConversationUiEvents, ChatEventModeChanged + ChatMessage } from "./AbstractConversationDefinitions"; import {TimestampRenderer} from "tc-shared/ui/react-elements/TimestampRenderer"; import {BBCodeRenderer} from "tc-shared/text/bbcode"; diff --git a/shared/js/ui/frames/side/ChannelBarRenderer.tsx b/shared/js/ui/frames/side/ChannelBarRenderer.tsx index cc8b1a97..62f9193f 100644 --- a/shared/js/ui/frames/side/ChannelBarRenderer.tsx +++ b/shared/js/ui/frames/side/ChannelBarRenderer.tsx @@ -1,7 +1,7 @@ import {Registry} from "tc-shared/events"; import {ChannelBarMode, ChannelBarModeData, ChannelBarUiEvents} from "tc-shared/ui/frames/side/ChannelBarDefinitions"; -import {useContext, useState} from "react"; import * as React from "react"; +import {useContext, useState} from "react"; import {ConversationPanel} from "tc-shared/ui/frames/side/AbstractConversationRenderer"; import {useDependentState} from "tc-shared/ui/react-elements/Helper"; import {ChannelDescriptionRenderer} from "tc-shared/ui/frames/side/ChannelDescriptionRenderer"; diff --git a/shared/js/ui/frames/side/ChannelConversationController.ts b/shared/js/ui/frames/side/ChannelConversationController.ts index 6f06cadc..7fd11ce9 100644 --- a/shared/js/ui/frames/side/ChannelConversationController.ts +++ b/shared/js/ui/frames/side/ChannelConversationController.ts @@ -1,7 +1,6 @@ -import {ConnectionHandler, ConnectionState} from "../../../ConnectionHandler"; +import {ConnectionHandler} from "../../../ConnectionHandler"; import {EventHandler} from "../../../events"; -import * as log from "../../../log"; -import {LogCategory} from "../../../log"; +import {LogCategory, logError} from "../../../log"; import {tr} from "../../../i18n/localize"; import {AbstractConversationUiEvents} from "./AbstractConversationDefinitions"; import {AbstractConversationController} from "./AbstractConversationController"; @@ -80,7 +79,7 @@ export class ChannelConversationController extends AbstractConversationControlle private handleMessageDelete(event: AbstractConversationUiEvents["action_delete_message"]) { const conversation = this.conversationManager?.findConversationById(event.chatId); if(!conversation) { - log.error(LogCategory.CLIENT, tr("Tried to delete a chat message from an unknown conversation with id %s"), event.chatId); + logError(LogCategory.CLIENT, tr("Tried to delete a chat message from an unknown conversation with id %s"), event.chatId); return; } diff --git a/shared/js/ui/frames/side/ChannelDescriptionRenderer.tsx b/shared/js/ui/frames/side/ChannelDescriptionRenderer.tsx index 5afcb177..85514793 100644 --- a/shared/js/ui/frames/side/ChannelDescriptionRenderer.tsx +++ b/shared/js/ui/frames/side/ChannelDescriptionRenderer.tsx @@ -7,8 +7,7 @@ import * as React from "react"; import {useState} from "react"; import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; -import {allowedBBCodes, BBCodeRenderer} from "tc-shared/text/bbcode"; -import {parse as parseBBCode} from "vendor/xbbcode/parser"; +import {BBCodeRenderer} from "tc-shared/text/bbcode"; const cssStyle = require("./ChannelDescriptionRenderer.scss"); diff --git a/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx b/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx index 1e69b2a3..48fe6e83 100644 --- a/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx +++ b/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx @@ -1,13 +1,14 @@ +import * as React from "react"; import {useState} from "react"; import {Registry} from "tc-shared/events"; import {ChannelFileBrowserUiEvents} from "tc-shared/ui/frames/side/ChannelFileBrowserDefinitions"; import {channelPathPrefix, FileBrowserEvents} from "tc-shared/ui/modal/transfer/FileDefinitions"; import { FileBrowserClassContext, - FileBrowserRenderer, FileBrowserRendererClasses, + FileBrowserRenderer, + FileBrowserRendererClasses, NavigationBar } from "tc-shared/ui/modal/transfer/FileBrowserRenderer"; -import * as React from "react"; const cssStyle = require("./ChannelFileBrowserRenderer.scss"); diff --git a/shared/js/ui/frames/side/ClientInfoController.ts b/shared/js/ui/frames/side/ClientInfoController.ts index ab7c3ea4..f6830c67 100644 --- a/shared/js/ui/frames/side/ClientInfoController.ts +++ b/shared/js/ui/frames/side/ClientInfoController.ts @@ -1,8 +1,5 @@ import {ConnectionHandler} from "tc-shared/ConnectionHandler"; -import { - ClientGroupInfo, - ClientInfoEvents, -} from "tc-shared/ui/frames/side/ClientInfoDefinitions"; +import {ClientGroupInfo, ClientInfoEvents,} from "tc-shared/ui/frames/side/ClientInfoDefinitions"; import {Registry} from "tc-shared/events"; import {openClientInfo} from "tc-shared/ui/modal/ModalClientInfo"; diff --git a/shared/js/ui/frames/side/ClientInfoRenderer.tsx b/shared/js/ui/frames/side/ClientInfoRenderer.tsx index 3f13c544..92748b03 100644 --- a/shared/js/ui/frames/side/ClientInfoRenderer.tsx +++ b/shared/js/ui/frames/side/ClientInfoRenderer.tsx @@ -1,7 +1,9 @@ import * as React from "react"; import {useContext, useEffect, useState} from "react"; import { - ClientCountryInfo, ClientForumInfo, ClientGroupInfo, + ClientCountryInfo, + ClientForumInfo, + ClientGroupInfo, ClientInfoEvents, ClientInfoOnline, ClientStatusInfo, diff --git a/shared/js/ui/frames/side/HeaderController.ts b/shared/js/ui/frames/side/HeaderController.ts index 90b6b0be..4cd817f6 100644 --- a/shared/js/ui/frames/side/HeaderController.ts +++ b/shared/js/ui/frames/side/HeaderController.ts @@ -5,8 +5,6 @@ import {ChannelEntry, ChannelProperties} from "tc-shared/tree/Channel"; import {LocalClientEntry, MusicClientEntry} from "tc-shared/tree/Client"; import {openMusicManage} from "tc-shared/ui/modal/ModalMusicManage"; import {createErrorModal, createInputModal} from "tc-shared/ui/elements/Modal"; -import {server_connections} from "tc-shared/ConnectionManager"; -import {appViewController} from "tc-shared/ui/AppController"; import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration"; import {LogCategory, logError} from "tc-shared/log"; diff --git a/shared/js/ui/frames/side/HeaderRenderer.tsx b/shared/js/ui/frames/side/HeaderRenderer.tsx index b4c1e5a8..2253646a 100644 --- a/shared/js/ui/frames/side/HeaderRenderer.tsx +++ b/shared/js/ui/frames/side/HeaderRenderer.tsx @@ -1,13 +1,15 @@ import * as React from "react"; +import {useContext, useState} from "react"; import {Registry} from "tc-shared/events"; import { - SideHeaderEvents, - SideHeaderState, + PrivateConversationInfo, SideHeaderChannelState, - SideHeaderPingInfo, PrivateConversationInfo, SideHeaderServerInfo + SideHeaderEvents, + SideHeaderPingInfo, + SideHeaderServerInfo, + SideHeaderState } from "tc-shared/ui/frames/side/HeaderDefinitions"; import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; -import {useContext, useState} from "react"; import {RemoteIconRenderer} from "tc-shared/ui/react-elements/Icon"; import {getIconManager} from "tc-shared/file/Icons"; diff --git a/shared/js/ui/frames/side/MusicBotController.ts b/shared/js/ui/frames/side/MusicBotController.ts index 03788b61..36d8473b 100644 --- a/shared/js/ui/frames/side/MusicBotController.ts +++ b/shared/js/ui/frames/side/MusicBotController.ts @@ -276,7 +276,6 @@ export class MusicBotController { let playlistId: number = 0; if(this.currentConnection && this.currentBot) { playlistId = this.currentBot.properties.client_playlist_id; - console.error("Client playlist id: %o", playlistId); } let playlist: SubscribedPlaylist; diff --git a/shared/js/ui/frames/side/MusicBotRenderer.tsx b/shared/js/ui/frames/side/MusicBotRenderer.tsx index e41eb3ef..5bcc0cf2 100644 --- a/shared/js/ui/frames/side/MusicBotRenderer.tsx +++ b/shared/js/ui/frames/side/MusicBotRenderer.tsx @@ -2,13 +2,13 @@ import {Registry} from "tc-shared/events"; import {MusicPlaylistUiEvents} from "tc-shared/ui/frames/side/MusicPlaylistDefinitions"; import {DefaultThumbnail, formatPlaytime, MusicPlaylistList} from "tc-shared/ui/frames/side/MusicPlaylistRenderer"; import * as React from "react"; +import {useContext, useEffect, useRef, useState} from "react"; import { MusicBotPlayerState, MusicBotPlayerTimestamp, MusicBotSongInfo, MusicBotUiEvents } from "tc-shared/ui/frames/side/MusicBotDefinitions"; -import {useContext, useEffect, useRef, useState} from "react"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {preview_image} from "tc-shared/ui/frames/image_preview"; import {Slider} from "tc-shared/ui/react-elements/Slider"; diff --git a/shared/js/ui/frames/side/MusicPlaylistRenderer.tsx b/shared/js/ui/frames/side/MusicPlaylistRenderer.tsx index 5d82bf98..7594297a 100644 --- a/shared/js/ui/frames/side/MusicPlaylistRenderer.tsx +++ b/shared/js/ui/frames/side/MusicPlaylistRenderer.tsx @@ -1,11 +1,11 @@ import * as React from "react"; +import {useContext, useRef, useState} from "react"; import {Registry} from "tc-shared/events"; import { MusicPlaylistEntryInfo, MusicPlaylistStatus, MusicPlaylistUiEvents } from "tc-shared/ui/frames/side/MusicPlaylistDefinitions"; -import {useContext, useRef, useState} from "react"; import {Button} from "tc-shared/ui/react-elements/Button"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; @@ -236,7 +236,6 @@ const PlaylistEntry = React.memo((props: { serverUniqueId: string, playlistId: n onDragEnd={() => setInsertMarker("none")} onDrop={event => { const info = parseDragIds(event.dataTransfer); - console.error("Info: %o - %o - %o", info, insertMarker, { playlistId: props.playlistId, serverUniqueId: props.serverUniqueId }); if(!info) { setInsertMarker("none"); return; diff --git a/shared/js/ui/frames/side/PrivateConversationController.ts b/shared/js/ui/frames/side/PrivateConversationController.ts index a4cc669c..239e57bf 100644 --- a/shared/js/ui/frames/side/PrivateConversationController.ts +++ b/shared/js/ui/frames/side/PrivateConversationController.ts @@ -4,13 +4,10 @@ import { PrivateConversationInfo, PrivateConversationUIEvents } from "../../../ui/frames/side/PrivateConversationDefinitions"; -import { - AbstractConversationUiEvents -} from "./AbstractConversationDefinitions"; -import * as log from "../../../log"; -import {LogCategory} from "../../../log"; +import {AbstractConversationUiEvents} from "./AbstractConversationDefinitions"; +import {LogCategory, logError, logWarn} from "../../../log"; import {AbstractConversationController} from "./AbstractConversationController"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; import { PrivateConversation, PrivateConversationEvents, @@ -147,7 +144,7 @@ export class PrivateConversationController extends AbstractConversationControlle private handleConversationClose(event: PrivateConversationUIEvents["action_close_chat"]) { const conversation = this.conversationManager?.findConversation(event.chatId); if(!conversation) { - log.error(LogCategory.CLIENT, tr("Tried to close a not existing private conversation with id %s"), event.chatId); + logError(LogCategory.CLIENT, tr("Tried to close a not existing private conversation with id %s"), event.chatId); return; } @@ -167,7 +164,7 @@ export class PrivateConversationController extends AbstractConversationControlle } this.connection.serverConnection.send_command("clientchatcomposing", { clid: clientId }).catch(error => { - log.warn(LogCategory.CHAT, tr("Failed to send chat composing to server for chat %d: %o"), clientId, error); + logWarn(LogCategory.CHAT, tr("Failed to send chat composing to server for chat %d: %o"), clientId, error); }); } } \ No newline at end of file diff --git a/shared/js/ui/frames/side/PrivateConversationRenderer.tsx b/shared/js/ui/frames/side/PrivateConversationRenderer.tsx index cc87a6f5..d329dcb6 100644 --- a/shared/js/ui/frames/side/PrivateConversationRenderer.tsx +++ b/shared/js/ui/frames/side/PrivateConversationRenderer.tsx @@ -1,13 +1,12 @@ import * as React from "react"; +import {useContext, useEffect, useState} from "react"; import {Registry} from "tc-shared/events"; import { PrivateConversationInfo, PrivateConversationUIEvents } from "tc-shared/ui/frames/side/PrivateConversationDefinitions"; -import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {ContextDivider} from "tc-shared/ui/react-elements/ContextDivider"; import {ConversationPanel} from "./AbstractConversationRenderer"; -import {useContext, useEffect, useState} from "react"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; import {AvatarRenderer} from "tc-shared/ui/react-elements/Avatar"; import {TimestampRenderer} from "tc-shared/ui/react-elements/TimestampRenderer"; diff --git a/shared/js/ui/frames/video/Renderer.tsx b/shared/js/ui/frames/video/Renderer.tsx index 0df4df2a..ad3c09a2 100644 --- a/shared/js/ui/frames/video/Renderer.tsx +++ b/shared/js/ui/frames/video/Renderer.tsx @@ -7,7 +7,10 @@ import { ChannelVideoEvents, ChannelVideoInfo, ChannelVideoStreamState, - kLocalVideoId, makeVideoAutoplay, VideoStreamState, VideoSubscribeInfo + kLocalVideoId, + makeVideoAutoplay, + VideoStreamState, + VideoSubscribeInfo } from "tc-shared/ui/frames/video/Definitions"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; diff --git a/shared/js/ui/htmltags.ts b/shared/js/ui/htmltags.ts index f0e4ff44..7e463d39 100644 --- a/shared/js/ui/htmltags.ts +++ b/shared/js/ui/htmltags.ts @@ -1,11 +1,10 @@ -import * as log from "../log"; -import {LogCategory} from "../log"; +import {LogCategory, logDebug, logWarn} from "../log"; import {ChannelEntry} from "../tree/Channel"; import {ClientEntry} from "../tree/Client"; import {htmlEscape} from "../ui/frames/chat"; import {guid} from "../crypto/uid"; import {server_connections} from "tc-shared/ConnectionManager"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; let mouse_coordinates: {x: number, y: number} = {x: 0, y: 0}; @@ -47,7 +46,7 @@ function generate_client_open(properties: ClientProperties) : string { try { result = result + "client-unique-id='" + encodeURIComponent(properties.client_unique_id) + "' "; } catch(error) { - console.warn(tr("Failed to generate client tag attribute 'client-unique-id': %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to generate client tag attribute 'client-unique-id': %o"), error); } } @@ -55,7 +54,7 @@ function generate_client_open(properties: ClientProperties) : string { try { result = result + "client-name='" + encodeURIComponent(properties.client_name) + "' "; } catch(error) { - console.warn(tr("Failed to generate client tag attribute 'client-name': %o"), error); + logWarn(LogCategory.GENERAL, tr("Failed to generate client tag attribute 'client-name': %o"), error); } } @@ -161,7 +160,7 @@ export namespace callbacks { if(!client) { /* we may should open a "offline" menu? */ - log.debug(LogCategory.GENERAL, "Failed to resolve client from html tag. Client id: %o, Client unique id: %o, Client name: %o", + logDebug(LogCategory.GENERAL, "Failed to resolve client from html tag. Client id: %o, Client unique id: %o, Client name: %o", client_id, client_unique_id, decodeURIComponent(element.attr("client-name")) diff --git a/shared/js/ui/jsrender.ts b/shared/js/ui/jsrender.ts index 82a27e9b..a1f9bf87 100644 --- a/shared/js/ui/jsrender.ts +++ b/shared/js/ui/jsrender.ts @@ -1,8 +1,7 @@ import * as loader from "tc-loader"; import * as moment from "moment"; -import * as log from "../log"; -import {LogCategory} from "../log"; -import { tr } from "tc-shared/i18n/localize"; +import {LogCategory, logError, logTrace} from "../log"; +import {tr} from "tc-shared/i18n/localize"; export function setupJSRender() : boolean { if(!$.views) { @@ -28,9 +27,9 @@ export function setupJSRender() : boolean { $(".jsrender-template").each((idx, _entry) => { if(!$.templates(_entry.id, _entry.innerHTML)) { - log.error(LogCategory.GENERAL, tr("Failed to setup cache for js renderer template %s!"), _entry.id); + logError(LogCategory.GENERAL, tr("Failed to setup cache for js renderer template %s!"), _entry.id); } else - log.trace(LogCategory.GENERAL, tr("Successfully loaded jsrender template %s"), _entry.id); + logTrace(LogCategory.GENERAL, tr("Successfully loaded jsrender template %s"), _entry.id); }); return true; } \ No newline at end of file diff --git a/shared/js/ui/modal/ModalAbout.ts b/shared/js/ui/modal/ModalAbout.ts index 5f3c9377..38b63ab0 100644 --- a/shared/js/ui/modal/ModalAbout.ts +++ b/shared/js/ui/modal/ModalAbout.ts @@ -1,7 +1,6 @@ import {createModal} from "../../ui/elements/Modal"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; -import { tr } from "tc-shared/i18n/localize"; +import {LogCategory, logError} from "../../log"; +import {tr} from "tc-shared/i18n/localize"; function format_date(date: number) { const d = new Date(date); @@ -34,7 +33,7 @@ export function spawnAbout() { (window as any).native.client_version().then(version => { connectModal.htmlTag.find(".version-client").text(version); }).catch(error => { - log.error(LogCategory.GENERAL, tr("Failed to load client version: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to load client version: %o"), error); connectModal.htmlTag.find(".version-client").text("unknown"); }); } diff --git a/shared/js/ui/modal/ModalAvatar.ts b/shared/js/ui/modal/ModalAvatar.ts index cb55b4b9..897d439e 100644 --- a/shared/js/ui/modal/ModalAvatar.ts +++ b/shared/js/ui/modal/ModalAvatar.ts @@ -1,7 +1,8 @@ //TODO: Test if we could render this image and not only the browser by knowing the type. import {createErrorModal, createModal} from "../../ui/elements/Modal"; -import {tra, tr} from "../../i18n/localize"; +import {tr, tra} from "../../i18n/localize"; import {arrayBufferBase64} from "../../utils/buffers"; +import {LogCategory, logError, logTrace} from "tc-shared/log"; export function spawnAvatarUpload(callback_data: (data: ArrayBuffer | undefined | null) => any) { const modal = createModal({ @@ -41,7 +42,7 @@ export function spawnAvatarUpload(callback_data: (data: ArrayBuffer | undefined input_node.multiple = false; modal.htmlTag.find(".file-inputs").on('change', event => { - console.log("Files: %o", input_node.files); + logTrace(LogCategory.CLIENT, "Files: %o", input_node.files); const read_file = (file: File) => new Promise((resolve, reject) => { const reader = new FileReader(); @@ -55,13 +56,13 @@ export function spawnAvatarUpload(callback_data: (data: ArrayBuffer | undefined const data = await read_file(input_node.files[0]); if (!data.startsWith("data:image/")) { - console.error(tr("Failed to load file %s: Invalid data media type (%o)"), input_node.files[0].name, data); + logError(LogCategory.FILE_TRANSFER, tr("Failed to load file %s: Invalid data media type (%o)"), input_node.files[0].name, data); createErrorModal(tr("Icon upload failed"), tra("Failed to select avatar {}.
File is not an image", input_node.files[0].name)).open(); return; } const semi = data.indexOf(';'); const type = data.substring(11, semi); - console.log(tr("Given image has type %s"), type); + logTrace(LogCategory.CLIENT, tr("Given image has type %s"), type); set_avatar(data.substr(semi + 8 /* 8 bytes := base64, */), type); })(); diff --git a/shared/js/ui/modal/ModalAvatarList.ts b/shared/js/ui/modal/ModalAvatarList.ts index 531b0a79..981e5069 100644 --- a/shared/js/ui/modal/ModalAvatarList.ts +++ b/shared/js/ui/modal/ModalAvatarList.ts @@ -1,12 +1,11 @@ import {createErrorModal, createModal} from "../../ui/elements/Modal"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logError} from "../../log"; import {ConnectionHandler} from "../../ConnectionHandler"; import {base64_encode_ab} from "../../utils/buffers"; import {spawnYesNo} from "../../ui/modal/ModalYesNo"; import {ClientEntry} from "../../tree/Client"; import * as moment from "moment"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; const avatar_to_uid = (id: string) => { const buffer = new Uint8Array(id.length / 2); @@ -151,12 +150,12 @@ export function spawnAvatarList(client: ConnectionHandler) { (username_resolve[uid] || []).forEach(e => e(undefined)); } }).catch(error => { - log.error(LogCategory.GENERAL, tr("Failed to fetch usernames from avatar names. Error: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to fetch usernames from avatar names. Error: %o"), error); createErrorModal(tr("Failed to fetch usernames"), tr("Failed to fetch usernames related to their avatar names"), undefined).open(); }) }).catch(error => { //TODO: Display no perms error - log.error(LogCategory.GENERAL, tr("Failed to receive avatar list. Error: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to receive avatar list. Error: %o"), error); createErrorModal(tr("Failed to list avatars"), tr("Failed to receive avatar list."), undefined).open(); }); }; diff --git a/shared/js/ui/modal/ModalBanClient.ts b/shared/js/ui/modal/ModalBanClient.ts index 70817829..101695e9 100644 --- a/shared/js/ui/modal/ModalBanClient.ts +++ b/shared/js/ui/modal/ModalBanClient.ts @@ -3,7 +3,7 @@ import {ConnectionHandler} from "../../ConnectionHandler"; import {createModal} from "../../ui/elements/Modal"; import {duration_data} from "../../ui/modal/ModalBanList"; import * as tooltip from "../../ui/elements/Tooltip"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export type BanEntry = { name?: string; diff --git a/shared/js/ui/modal/ModalBanList.ts b/shared/js/ui/modal/ModalBanList.ts index 9067dd6e..bd5eea17 100644 --- a/shared/js/ui/modal/ModalBanList.ts +++ b/shared/js/ui/modal/ModalBanList.ts @@ -3,14 +3,13 @@ import {createErrorModal, createInfoModal, createModal, Modal} from "../../ui/el import {SingleCommandHandler} from "../../connection/ConnectionBase"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import PermissionType from "../../permission/PermissionType"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logError, logInfo} from "../../log"; import * as tooltip from "../../ui/elements/Tooltip"; import * as htmltags from "../../ui/htmltags"; import {format_time, formatMessage} from "../../ui/frames/chat"; import * as moment from "moment"; import {ErrorCode} from "../../connection/ErrorCode"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function openBanList(client: ConnectionHandler) { let modal: Modal; @@ -322,7 +321,7 @@ function generate_dom(controller: BanListController): JQuery { container_add_no_permissions.hide(); controller.permission_add().then(result => permission_add = result).catch(error => { - log.error(LogCategory.CLIENT, tr("Failed to query ban add permissions: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to query ban add permissions: %o"), error); }).then(() => { if (permission_add[0] !== permission_add[1]) { const input_global = container_add.find(".group-global input"); @@ -332,7 +331,7 @@ function generate_dom(controller: BanListController): JQuery { }); controller.permission_edit().then(result => permission_edit = result).catch(error => { - log.error(LogCategory.CLIENT, tr("Failed to query ban edit permissions: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to query ban edit permissions: %o"), error); }).then(() => { if (selected_ban) update_edit_window(false); }); @@ -408,7 +407,7 @@ function generate_dom(controller: BanListController): JQuery { update_edit_window(false); } }).catch(error => { - log.error(LogCategory.CLIENT, tr("Failed to delete ban: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to delete ban: %o"), error); if (error instanceof CommandResult) error = error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS ? "no permissions" : error.extra_message || error.message; createErrorModal(tr("Failed to delete ban"), formatMessage(tr("Failed to delete ban. {:br:}Error: {}"), error)).open(); @@ -465,7 +464,7 @@ function generate_dom(controller: BanListController): JQuery { } update_ban_filter(); }).catch(error => { - log.info(LogCategory.CLIENT, tr("Failed to update ban list: %o"), error); + logInfo(LogCategory.CLIENT, tr("Failed to update ban list: %o"), error); if (error instanceof CommandResult) error = error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS ? tr("no permissions") : error.extra_message || error.message; container_ban_entries_error.show().find("a").text(tr("Failed to receive banlist: ") + error); @@ -543,7 +542,7 @@ function generate_dom(controller: BanListController): JQuery { update_trigger_filter(); }).catch(error => { - log.info(LogCategory.CLIENT, tr("Failed to update trigger list: %o"), error); + logInfo(LogCategory.CLIENT, tr("Failed to update trigger list: %o"), error); if (error instanceof CommandResult) error = error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS ? tr("no permissions") : error.extra_message || error.message; container_trigger_entries_error.show().find("a").text(tr("Failed to receive trigger list: ") + error); @@ -801,7 +800,7 @@ function generate_dom(controller: BanListController): JQuery { createInfoModal(tr("Ban successfully edited"), tr("Your ban has been successfully edited.")).open(); }).catch(error => { - log.error(LogCategory.CLIENT, tr("Failed to edited ban: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to edited ban: %o"), error); if (error instanceof CommandResult) error = error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS ? "no permissions" : error.extra_message || error.message; createErrorModal(tr("Failed to edited ban"), formatMessage(tr("Failed to edited ban. {:br:}Error: {}"), error)).open(); @@ -869,7 +868,7 @@ function generate_dom(controller: BanListController): JQuery { createInfoModal(tr("Ban successfully added"), tr("Your ban has been successfully added.")).open(); }).catch(error => { - log.error(LogCategory.CLIENT, tr("Failed to add ban: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to add ban: %o"), error); if (error instanceof CommandResult) error = error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS ? "no permissions" : error.extra_message || error.message; createErrorModal(tr("Failed to add ban"), formatMessage(tr("Failed to add ban. {:br:}Error: {}"), error)).open(); diff --git a/shared/js/ui/modal/ModalBookmarks.ts b/shared/js/ui/modal/ModalBookmarks.ts index 24ce9516..9d350970 100644 --- a/shared/js/ui/modal/ModalBookmarks.ts +++ b/shared/js/ui/modal/ModalBookmarks.ts @@ -14,8 +14,7 @@ import {Regex} from "../../ui/modal/ModalConnect"; import {availableConnectProfiles} from "../../profiles/ConnectionProfile"; import {spawnYesNo} from "../../ui/modal/ModalYesNo"; import {Settings, settings} from "../../settings"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logWarn} from "../../log"; import * as i18nc from "../../i18n/country"; import {formatMessage} from "../../ui/frames/chat"; import {generateIconJQueryTag, getIconManager} from "tc-shared/file/Icons"; @@ -128,7 +127,7 @@ export function spawnBookmarkModal() { let profile = input_connect_profile.find("option[value='" + entry.connect_profile + "']"); if (profile.length == 0) { - log.warn(LogCategory.GENERAL, tr("Failed to find bookmark profile %s. Displaying default one."), entry.connect_profile); + logWarn(LogCategory.GENERAL, tr("Failed to find bookmark profile %s. Displaying default one."), entry.connect_profile); profile = input_connect_profile.find("option[value=default]"); } profile.prop("selected", true); @@ -365,7 +364,7 @@ export function spawnBookmarkModal() { (selected_bookmark as Bookmark).connect_profile = id; save_bookmark(selected_bookmark); } else { - log.warn(LogCategory.GENERAL, tr("Failed to change connect profile for profile %s to %s"), selected_bookmark.unique_id, id); + logWarn(LogCategory.GENERAL, tr("Failed to change connect profile for profile %s to %s"), selected_bookmark.unique_id, id); } }) } diff --git a/shared/js/ui/modal/ModalChangeVolumeNew.tsx b/shared/js/ui/modal/ModalChangeVolumeNew.tsx index ff3e5ef8..18049aed 100644 --- a/shared/js/ui/modal/ModalChangeVolumeNew.tsx +++ b/shared/js/ui/modal/ModalChangeVolumeNew.tsx @@ -6,6 +6,7 @@ import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {EventHandler, ReactEventHandler, Registry} from "tc-shared/events"; import {ClientEntry, MusicClientEntry} from "tc-shared/tree/Client"; import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; + const cssStyle = require("./ModalChangeVolume.scss"); export interface VolumeChangeEvents { diff --git a/shared/js/ui/modal/ModalChannelInfo.ts b/shared/js/ui/modal/ModalChannelInfo.ts index 177ccf36..86466e71 100644 --- a/shared/js/ui/modal/ModalChannelInfo.ts +++ b/shared/js/ui/modal/ModalChannelInfo.ts @@ -4,7 +4,7 @@ import {copyToClipboard} from "../../utils/helpers"; import * as tooltip from "../../ui/elements/Tooltip"; import {formatMessage} from "../../ui/frames/chat"; import {renderBBCodeAsJQuery} from "tc-shared/text/bbcode"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function openChannelInfo(channel: ChannelEntry) { let modal: Modal; diff --git a/shared/js/ui/modal/ModalClientInfo.ts b/shared/js/ui/modal/ModalClientInfo.ts index 526f7ca6..8bf6991e 100644 --- a/shared/js/ui/modal/ModalClientInfo.ts +++ b/shared/js/ui/modal/ModalClientInfo.ts @@ -7,7 +7,7 @@ import * as tooltip from "../../ui/elements/Tooltip"; import * as moment from "moment"; import {format_number, network} from "../../ui/frames/chat"; import {generateIconJQueryTag, getIconManager} from "tc-shared/file/Icons"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; type InfoUpdateCallback = (info: ClientConnectionInfo) => any; diff --git a/shared/js/ui/modal/ModalGroupAssignment.ts b/shared/js/ui/modal/ModalGroupAssignment.ts index aab85018..06d9a214 100644 --- a/shared/js/ui/modal/ModalGroupAssignment.ts +++ b/shared/js/ui/modal/ModalGroupAssignment.ts @@ -1,6 +1,5 @@ -import {LogCategory} from "../../log"; +import {LogCategory, logWarn} from "../../log"; import {createModal, Modal} from "../../ui/elements/Modal"; -import * as log from "../../log"; import {ClientEntry} from "../../tree/Client"; import {GroupManager, GroupType} from "../../permission/GroupManager"; import PermissionType from "../../permission/PermissionType"; @@ -47,12 +46,12 @@ export function createServerGroupAssignmentModal(client: ClientEntry, callback: let group_id = parseInt(entry.attr("group-id")); let group = client.channelTree.client.groups.findServerGroup(group_id); if(!group) { - console.warn(tr("Could not resolve target group!")); + logWarn(LogCategory.GENERAL, tr("Could not resolve target group!")); return false; } let target = entry.prop("checked"); - callback([group.id], target).catch(e => { log.warn(LogCategory.GENERAL, tr("Failed to change group assignment: %o"), e)}).then(update_groups); + callback([group.id], target).catch(e => { logWarn(LogCategory.GENERAL, tr("Failed to change group assignment: %o"), e)}).then(update_groups); }); }); @@ -68,7 +67,7 @@ export function createServerGroupAssignmentModal(client: ClientEntry, callback: group_ids.push(parseInt(entry.attr("group-id"))); }); - callback(group_ids, false).catch(e => { log.warn(LogCategory.GENERAL, tr("Failed to remove all group assignments: %o"), e)}).then(update_groups); + callback(group_ids, false).catch(e => { logWarn(LogCategory.GENERAL, tr("Failed to remove all group assignments: %o"), e)}).then(update_groups); }); diff --git a/shared/js/ui/modal/ModalGroupCreate.tsx b/shared/js/ui/modal/ModalGroupCreate.tsx index dc05d729..8975716b 100644 --- a/shared/js/ui/modal/ModalGroupCreate.tsx +++ b/shared/js/ui/modal/ModalGroupCreate.tsx @@ -13,6 +13,7 @@ import {createErrorModal, createInfoModal} from "tc-shared/ui/elements/Modal"; import {tra} from "tc-shared/i18n/localize"; import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {ErrorCode} from "tc-shared/connection/ErrorCode"; +import {LogCategory, logError} from "tc-shared/log"; const cssStyle = require("./ModalGroupCreate.scss"); @@ -348,7 +349,7 @@ function initializeGroupCreateController(connection: ConnectionHandler, events: return; } - console.warn(tr("Failed to create group: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to create group: %o"), error); createErrorModal(tr("Failed to create group"), tra("Failed to create group.\n{}", stringifyError(error))).open(); }); diff --git a/shared/js/ui/modal/ModalGroupPermissionCopy.tsx b/shared/js/ui/modal/ModalGroupPermissionCopy.tsx index af6e96f7..27f141bb 100644 --- a/shared/js/ui/modal/ModalGroupPermissionCopy.tsx +++ b/shared/js/ui/modal/ModalGroupPermissionCopy.tsx @@ -1,10 +1,10 @@ import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {Registry} from "tc-shared/events"; +import * as React from "react"; import {useRef, useState} from "react"; import {Select} from "tc-shared/ui/react-elements/InputField"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; -import * as React from "react"; import {Button} from "tc-shared/ui/react-elements/Button"; import {GroupType} from "tc-shared/permission/GroupManager"; import PermissionType from "tc-shared/permission/PermissionType"; @@ -13,6 +13,7 @@ import {createErrorModal, createInfoModal} from "tc-shared/ui/elements/Modal"; import {tra} from "tc-shared/i18n/localize"; import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {ErrorCode} from "tc-shared/connection/ErrorCode"; +import {LogCategory, logWarn} from "tc-shared/log"; const cssStyle = require("./ModalGroupPermissionCopy.scss"); @@ -222,7 +223,7 @@ function initializeGroupPermissionCopyController(connection: ConnectionHandler, return; } - console.warn(tr("Failed to copy group permissions: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to copy group permissions: %o"), error); createErrorModal(tr("Failed to copy group permissions"), tra("Failed to copy group permissions.\n{}", stringifyError(error))).open(); }); diff --git a/shared/js/ui/modal/ModalIconSelect.ts b/shared/js/ui/modal/ModalIconSelect.ts index 9168e653..1b7cb728 100644 --- a/shared/js/ui/modal/ModalIconSelect.ts +++ b/shared/js/ui/modal/ModalIconSelect.ts @@ -1,8 +1,7 @@ import {ConnectionHandler} from "../../ConnectionHandler"; import PermissionType from "../../permission/PermissionType"; import {createErrorModal, createModal} from "../../ui/elements/Modal"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logError, logInfo, logWarn} from "../../log"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import {tra, traj} from "../../i18n/localize"; import {arrayBufferBase64} from "../../utils/buffers"; @@ -106,7 +105,7 @@ export function spawnIconSelect(client: ConnectionHandler, callback_icon?: (id: for (const icon of chunk) { const iconId = parseInt((icon.name || "").substr("icon_".length)); if (Number.isNaN(iconId)) { - log.warn(LogCategory.GENERAL, tr("Received an unparsable icon within icon list (%o)"), icon); + logWarn(LogCategory.GENERAL, tr("Received an unparsable icon within icon list (%o)"), icon); continue; } @@ -146,7 +145,7 @@ export function spawnIconSelect(client: ConnectionHandler, callback_icon?: (id: if (error instanceof CommandResult && error.id == ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) { container_no_permissions.show(); } else { - log.error(LogCategory.GENERAL, tr("Failed to fetch icon list. Error: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to fetch icon list. Error: %o"), error); display_remote_error(tr("Failed to fetch icon list")); } container_loading.hide(); @@ -159,7 +158,7 @@ export function spawnIconSelect(client: ConnectionHandler, callback_icon?: (id: const selected = modal.htmlTag.find(".selected"); if (selected.length != 1) - console.warn(tr("UI selected icon length does not equal with 1! (%o)"), selected.length); + logWarn(LogCategory.GENERAL, tr("UI selected icon length does not equal with 1! (%o)"), selected.length); if (selected_icon < 1000) return; /* we cant delete local icons */ @@ -168,7 +167,7 @@ export function spawnIconSelect(client: ConnectionHandler, callback_icon?: (id: }).catch(error => { if (error instanceof CommandResult && error.id == ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) return; - console.warn(tr("Failed to delete icon %d: %o"), selected_icon, error); + logWarn(LogCategory.GENERAL, tr("Failed to delete icon %d: %o"), selected_icon, error); error = error instanceof CommandResult ? error.extra_message || error.message : error; @@ -214,14 +213,14 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco icon.upload_state = "unset"; const file_too_big = () => { - console.error(tr("Failed to load file %s: File is too big!"), file.name); + logError(LogCategory.GENERAL, tr("Failed to load file %s: File is too big!"), file.name); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.
The given file is too big!", file.name)).open(); icon.state = "error"; }; if (file.size > 1024 * 1024 * 512) { file_too_big(); } else if ((file.size | 0) <= 0) { - console.error(tr("Failed to load file %s: Your browser does not support file sizes!"), file.name); + logError(LogCategory.GENERAL, tr("Failed to load file %s: Your browser does not support file sizes!"), file.name); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.
Your browser does not support file sizes!", file.name)).open(); icon.state = "error"; return; @@ -237,8 +236,7 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco reader.readAsDataURL(file); }); } catch (error) { - console.log("Image failed to load (%o)", error); - console.error(tr("Failed to load file %s: Image failed to load"), file.name); + logError(LogCategory.CLIENT, tr("Failed to load file %s: Image failed to load: %o"), file.name, error); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.
Failed to load image", file.name)).open(); icon.state = "error"; return; @@ -246,7 +244,7 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco const result = reader.result as string; if (typeof (result) !== "string") { - console.error(tr("Failed to load file %s: Result is not an media string (%o)"), file.name, result); + logError(LogCategory.GENERAL, tr("Failed to load file %s: Result is not an media string (%o)"), file.name, result); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.
Result is not an media string", file.name)).open(); icon.state = "error"; return; @@ -256,16 +254,16 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco /* get the CRC32 sum */ { if (!result.startsWith("data:image/")) { - console.error(tr("Failed to load file %s: Invalid data media type (%o)"), file.name, result); + logError(LogCategory.GENERAL, tr("Failed to load file %s: Invalid data media type (%o)"), file.name, result); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.
File is not an image", file.name)).open(); icon.state = "error"; return; } const semi = result.indexOf(';'); const type = result.substring(11, semi); - console.log(tr("Given image has type %s"), type); + logInfo(LogCategory.GENERAL, tr("Given image has type %s"), type); if (!result.substr(semi + 1).startsWith("base64,")) { - console.error(tr("Failed to load file %s: Mimetype isnt base64 encoded (%o)"), file.name, result.substr(semi + 1)); + logError(LogCategory.GENERAL, tr("Failed to load file %s: Mimetype isn't base64 encoded (%o)"), file.name, result.substr(semi + 1)); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.
Decoder returned unknown result", file.name)).open(); icon.state = "error"; return; @@ -285,14 +283,14 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco image.src = result; }); } catch (error) { - console.log("Image failed to load (%o)", error); - console.error(tr("Failed to load file %s: Image failed to load"), file.name); + logInfo(LogCategory.GENERAL, "Image failed to load (%o)", error); + logError(LogCategory.GENERAL, tr("Failed to load file %s: Image failed to load"), file.name); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.{:br:}Failed to load image", file.name)).open(); icon.state = "error"; } const width_error = message => { - console.error(tr("Failed to load file %s: Invalid bounds: %s"), file.name, message); + logError(LogCategory.GENERAL, tr("Failed to load file %s: Invalid bounds: %s"), file.name, message); createErrorModal(tr("Icon upload failed"), tra("Failed to upload icon {}.{:br:}Image is too large ({})", file.name, message)).open(); icon.state = "error"; }; @@ -311,7 +309,7 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco return; } } - console.log("Image loaded (%dx%d) %s (%s)", image.naturalWidth, image.naturalHeight, image.name, icon.icon_id); + logInfo(LogCategory.GENERAL, "Image loaded (%dx%d) %s (%s)", image.naturalWidth, image.naturalHeight, image.name, icon.icon_id); icon.image_element = () => { const image = document.createElement("img"); image.src = result; @@ -426,7 +424,7 @@ function handle_icon_upload(file: File, client: ConnectionHandler): UploadingIco break; case FileTransferState.ERRORED: - log.warn(LogCategory.FILE_TRANSFER, tr("Failed to upload icon %s: %o"), icon.file.name, transfer.currentError()); + logWarn(LogCategory.FILE_TRANSFER, tr("Failed to upload icon %s: %o"), icon.file.name, transfer.currentError()); bar.set_value(100); bar.set_error(tr("upload failed: ") + transfer.currentErrorMessage()); icon.upload_state = "error"; diff --git a/shared/js/ui/modal/ModalIdentity.ts b/shared/js/ui/modal/ModalIdentity.ts index 52d57787..96e0b845 100644 --- a/shared/js/ui/modal/ModalIdentity.ts +++ b/shared/js/ui/modal/ModalIdentity.ts @@ -2,7 +2,8 @@ import {createErrorModal, createInfoModal, createModal, Modal} from "../../ui/el import {TeaSpeakIdentity} from "../../profiles/identities/TeamSpeakIdentity"; import * as tooltip from "../../ui/elements/Tooltip"; import {formatMessage} from "../../ui/frames/chat"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; +import {LogCategory, logError} from "tc-shared/log"; export function spawnTeamSpeakIdentityImprove(identity: TeaSpeakIdentity, name: string): Modal { let modal: Modal; @@ -58,7 +59,6 @@ export function spawnTeamSpeakIdentityImprove(identity: TeaSpeakIdentity, name: }, hash_rate => { input_hash_rate.val(hash_rate); }).catch(error => { - console.error(error); createErrorModal(tr("Failed to improve identity"), tr("Failed to improve identity.
Error:") + error).open(); if (active) button_start_stop.trigger('click'); @@ -80,7 +80,6 @@ export function spawnTeamSpeakIdentityImprove(identity: TeaSpeakIdentity, name: if (active) button_start_stop.trigger('click'); }).catch(error => { - console.error(error); createErrorModal(tr("Failed to improve identity"), tr("Failed to improve identity.
Error:") + error).open(); if (active) button_start_stop.trigger('click'); @@ -185,7 +184,7 @@ export function spawnTeamSpeakIdentityImport(callback: (identity: TeaSpeakIdenti }; file_reader.onerror = ev => { - console.error(tr("Failed to read give identity file: %o"), ev); + logError(LogCategory.IDENTITIES, tr("Failed to read give identity file: %o"), ev); set_status(tr("Failed to read the identity file."), "error"); return; }; diff --git a/shared/js/ui/modal/ModalInvite.ts b/shared/js/ui/modal/ModalInvite.ts index c9854d72..027c7e3b 100644 --- a/shared/js/ui/modal/ModalInvite.ts +++ b/shared/js/ui/modal/ModalInvite.ts @@ -2,7 +2,7 @@ import {settings, Settings} from "../../settings"; import {createModal, Modal} from "../../ui/elements/Modal"; import {ConnectionHandler} from "../../ConnectionHandler"; import {ServerAddress} from "../../tree/Server"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; type URLGeneratorSettings = { flag_direct: boolean, diff --git a/shared/js/ui/modal/ModalKeySelect.ts b/shared/js/ui/modal/ModalKeySelect.ts index f91e34ef..c9775ded 100644 --- a/shared/js/ui/modal/ModalKeySelect.ts +++ b/shared/js/ui/modal/ModalKeySelect.ts @@ -1,7 +1,7 @@ import {createModal} from "../../ui/elements/Modal"; import {EventType, key_description, KeyEvent} from "../../PPTListener"; import * as ppt from "tc-backend/ppt"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function spawnKeySelect(callback: (key?: KeyEvent) => void) { let modal = createModal({ diff --git a/shared/js/ui/modal/ModalMusicManage.ts b/shared/js/ui/modal/ModalMusicManage.ts index 292e44ad..788a283a 100644 --- a/shared/js/ui/modal/ModalMusicManage.ts +++ b/shared/js/ui/modal/ModalMusicManage.ts @@ -3,9 +3,8 @@ import {ConnectionHandler} from "../../ConnectionHandler"; import {MusicClientEntry} from "../../tree/Client"; import {modal, Registry} from "../../events"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; -import {tra, tr} from "../../i18n/localize"; +import {LogCategory, logError, logWarn} from "../../log"; +import {tr, tra} from "../../i18n/localize"; import * as tooltip from "../../ui/elements/Tooltip"; import * as i18nc from "../../i18n/country"; import {find} from "../../permission/PermissionManager"; @@ -70,7 +69,7 @@ function permission_controller(event_registry: Registry, bot status: "error", error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to query playlist info for playlist %d: %o"), playlist_id, error); + logError(LogCategory.CLIENT, tr("Failed to query playlist info for playlist %d: %o"), playlist_id, error); }); }); @@ -111,7 +110,7 @@ function permission_controller(event_registry: Registry, bot key: event.key, error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to change playlist status %s for playlist %d: %o"), event.key, playlist_id, error); + logError(LogCategory.CLIENT, tr("Failed to change playlist status %s for playlist %d: %o"), event.key, playlist_id, error); }); }); @@ -176,7 +175,7 @@ function permission_controller(event_registry: Registry, bot key: event.key, error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to change bot setting %s: %o"), event.key, error); + logError(LogCategory.CLIENT, tr("Failed to change bot setting %s: %o"), event.key, error); }); }); } @@ -199,7 +198,7 @@ function permission_controller(event_registry: Registry, bot status: "error", error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to query playlist general permissions for playlist %d: %o"), playlist_id, error); + logError(LogCategory.CLIENT, tr("Failed to query playlist general permissions for playlist %d: %o"), playlist_id, error); }); }); @@ -224,7 +223,7 @@ function permission_controller(event_registry: Registry, bot key: event.key, error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to set playlist general permissions for playlist %d and permission %d: %o"), playlist_id, event.key, error); + logError(LogCategory.CLIENT, tr("Failed to set playlist general permissions for playlist %d and permission %d: %o"), playlist_id, event.key, error); }); }); @@ -247,7 +246,7 @@ function permission_controller(event_registry: Registry, bot client_database_id: event.client_database_id, error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to query playlist client permissions for playlist %d and client %d: %o"), playlist_id, client_id, error); + logError(LogCategory.CLIENT, tr("Failed to query playlist client permissions for playlist %d and client %d: %o"), playlist_id, client_id, error); }); }); @@ -277,7 +276,7 @@ function permission_controller(event_registry: Registry, bot client_database_id: client_id, error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to set playlist client permissions for playlist %d, permission %d and client id %d: %o"), playlist_id, event.key, client_id, error); + logError(LogCategory.CLIENT, tr("Failed to set playlist client permissions for playlist %d, permission %d and client id %d: %o"), playlist_id, event.key, client_id, error); }); }); @@ -301,7 +300,7 @@ function permission_controller(event_registry: Registry, bot status: "error", error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to query special client list for playlist %d: %o"), playlist_id, error); + logError(LogCategory.CLIENT, tr("Failed to query special client list for playlist %d: %o"), playlist_id, error); }) }); @@ -344,7 +343,7 @@ function permission_controller(event_registry: Registry, bot status: "error", error_msg: error_msg(error) }); - log.error(LogCategory.CLIENT, tr("Failed to lookup search text \"%s\": %o"), text, error); + logError(LogCategory.CLIENT, tr("Failed to lookup search text \"%s\": %o"), text, error); }); }); @@ -375,7 +374,7 @@ function permission_controller(event_registry: Registry, bot error_msg: error_msg(error), permission_name: event.permission_name }); - log.error(LogCategory.CLIENT, tr("Failed to execute permfind for permission %s: %o"), event.permission_name, error); + logError(LogCategory.CLIENT, tr("Failed to execute permfind for permission %s: %o"), event.permission_name, error); }); }); } @@ -911,7 +910,6 @@ function build_settings_container(event_registry: Registry, input.on("keyup", event => event.key === "Enter" && input.trigger("focusout")); input.on("change", event => { const value = parseInt(input.val() as string); - console.log(value); if (isNaN(value)) return; update_value(tr("applying...")); @@ -1741,7 +1739,7 @@ function build_permission_container(event_registry: Registry let hide_indicator = false; if (typeof permission_needed_name !== "string") { - log.warn(LogCategory.GENERAL, tr("Missing permission needed mapping for %s"), permission_name); + logWarn(LogCategory.GENERAL, tr("Missing permission needed mapping for %s"), permission_name); return; } diff --git a/shared/js/ui/modal/ModalPoke.ts b/shared/js/ui/modal/ModalPoke.ts index 317a0d46..a2ab32be 100644 --- a/shared/js/ui/modal/ModalPoke.ts +++ b/shared/js/ui/modal/ModalPoke.ts @@ -3,7 +3,7 @@ import {createModal, Modal} from "../../ui/elements/Modal"; import * as htmltags from "../../ui/htmltags"; import * as moment from "moment"; import {renderBBCodeAsJQuery} from "../../text/bbcode"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; let global_modal: PokeModal; diff --git a/shared/js/ui/modal/ModalQuery.ts b/shared/js/ui/modal/ModalQuery.ts index 6d06f72f..551e893f 100644 --- a/shared/js/ui/modal/ModalQuery.ts +++ b/shared/js/ui/modal/ModalQuery.ts @@ -2,7 +2,7 @@ import {createErrorModal, createModal} from "../../ui/elements/Modal"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import {ConnectionHandler} from "../../ConnectionHandler"; import {SingleCommandHandler} from "../../connection/ConnectionBase"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function spawnQueryCreate(connection: ConnectionHandler, callback_created?: (user, pass) => any) { let modal; diff --git a/shared/js/ui/modal/ModalQueryManage.ts b/shared/js/ui/modal/ModalQueryManage.ts index 18706cbf..bed4ad4c 100644 --- a/shared/js/ui/modal/ModalQueryManage.ts +++ b/shared/js/ui/modal/ModalQueryManage.ts @@ -162,14 +162,13 @@ import {CommandResult, QueryListEntry} from "../../connection/ServerConnectionDe import {SingleCommandHandler} from "../../connection/ConnectionBase"; import {copyToClipboard} from "../../utils/helpers"; import {spawnYesNo} from "../../ui/modal/ModalYesNo"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logError} from "../../log"; import PermissionType from "../../permission/PermissionType"; import {ConnectionHandler} from "../../ConnectionHandler"; import {spawnQueryCreate, spawnQueryCreated} from "../../ui/modal/ModalQuery"; import {formatMessage} from "../../ui/frames/chat"; import {ErrorCode} from "../../connection/ErrorCode"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function spawnQueryManage(client: ConnectionHandler) { let modal: Modal; @@ -265,12 +264,12 @@ export function spawnQueryManage(client: ConnectionHandler) { set_error(tr("No permissions")); return; } - log.error(LogCategory.CLIENT, tr("Failed to request the query list: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to request the query list: %o"), error); set_error(tr("Failed to request list")); }); }).catch(error => { button_update.prop('disabled', false); - log.error(LogCategory.CLIENT, tr("Failed to get own virtual server id: %o"), error); + logError(LogCategory.CLIENT, tr("Failed to get own virtual server id: %o"), error); set_error(tr("Failed to query server id")); }); }; diff --git a/shared/js/ui/modal/ModalServerEdit.ts b/shared/js/ui/modal/ModalServerEdit.ts index 6d92c0f2..3a200a86 100644 --- a/shared/js/ui/modal/ModalServerEdit.ts +++ b/shared/js/ui/modal/ModalServerEdit.ts @@ -7,7 +7,7 @@ import * as tooltip from "../../ui/elements/Tooltip"; import {spawnIconSelect} from "../../ui/modal/ModalIconSelect"; import {network} from "../../ui/frames/chat"; import {generateIconJQueryTag, getIconManager} from "tc-shared/file/Icons"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function createServerModal(server: ServerEntry, callback: (properties?: ServerProperties) => Promise) { const properties = Object.assign({}, server.properties); @@ -124,7 +124,7 @@ function apply_general_listener(tag: JQuery, server: ServerEntry, properties: Se icon_node.children().remove(); icon_node.append(generateIconJQueryTag(getIconManager().resolveIcon(id, server.properties.virtualserver_unique_identifier, server.channelTree.client.handlerId))); - console.log("Selected icon ID: %d", id); + logTrace(LogCategory.GENERAL, "Selected icon ID: %d", id); properties.virtualserver_icon_id = id; callback_valid(undefined); //Toggle save button update }, properties.virtualserver_icon_id); @@ -135,7 +135,7 @@ function apply_general_listener(tag: JQuery, server: ServerEntry, properties: Se icon_node.children().remove(); icon_node.append(generateIconJQueryTag(getIconManager().resolveIcon(0, server.properties.virtualserver_unique_identifier))); - console.log("Remove server icon"); + logTrace(LogCategory.GENERAL, "Remove server icon"); properties.virtualserver_icon_id = 0; callback_valid(undefined); //Toggle save button update }); @@ -218,7 +218,7 @@ function apply_general_listener(tag: JQuery, server: ServerEntry, properties: Se }; input.on('change', event => { - console.log(tr("Welcome message edited: %o"), input.val()); + logTrace(LogCategory.GENERAL, tr("Welcome message edited: %o"), input.val()); properties.virtualserver_welcomemessage = input.val() as string; callback_valid(undefined); //Toggle save button update }).prop("disabled", !permission).firstParent(".input-boxed").toggleClass("disabled", !permission); diff --git a/shared/js/ui/modal/ModalServerInfo.ts b/shared/js/ui/modal/ModalServerInfo.ts index d82df6f4..2d13badf 100644 --- a/shared/js/ui/modal/ModalServerInfo.ts +++ b/shared/js/ui/modal/ModalServerInfo.ts @@ -6,14 +6,13 @@ import { import {ServerEntry} from "../../tree/Server"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import {createErrorModal, createModal, Modal} from "../../ui/elements/Modal"; -import * as log from "../../log"; -import {LogCategory} from "../../log"; +import {LogCategory, logWarn} from "../../log"; import * as tooltip from "../../ui/elements/Tooltip"; import * as i18nc from "../../i18n/country"; import {format_time, formatMessage} from "../../ui/frames/chat"; import * as moment from "moment"; import {ErrorCode} from "../../connection/ErrorCode"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export function openServerInfo(server: ServerEntry) { let modal: Modal; @@ -40,7 +39,7 @@ export function openServerInfo(server: ServerEntry) { update_callbacks = []; update_values(); }).catch(error => { - log.warn(LogCategory.CLIENT, tr("Failed to refresh server properties: %o"), error); + logWarn(LogCategory.CLIENT, tr("Failed to refresh server properties: %o"), error); if (error instanceof CommandResult) error = error.extra_message || error.message; createErrorModal(tr("Refresh failed"), formatMessage(tr("Failed to refresh server properties.{:br:}Error: {}"), error)).open(); diff --git a/shared/js/ui/modal/ModalServerInfoBandwidth.ts b/shared/js/ui/modal/ModalServerInfoBandwidth.ts index be800cbb..68b17f82 100644 --- a/shared/js/ui/modal/ModalServerInfoBandwidth.ts +++ b/shared/js/ui/modal/ModalServerInfoBandwidth.ts @@ -5,7 +5,7 @@ import {Graph} from "../../ui/elements/NetGraph"; import * as tooltip from "../../ui/elements/Tooltip"; import {network} from "../../ui/frames/chat"; import {ErrorCode} from "../../connection/ErrorCode"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export enum RequestInfoStatus { SUCCESS, diff --git a/shared/js/ui/modal/ModalSettings.tsx b/shared/js/ui/modal/ModalSettings.tsx index 85ac139a..7f6f0224 100644 --- a/shared/js/ui/modal/ModalSettings.tsx +++ b/shared/js/ui/modal/ModalSettings.tsx @@ -9,8 +9,7 @@ import {IdentitifyType} from "tc-shared/profiles/Identity"; import {TeaForumIdentity} from "tc-shared/profiles/identities/TeaForumIdentity"; import {TeaSpeakIdentity} from "tc-shared/profiles/identities/TeamSpeakIdentity"; import {NameIdentity} from "tc-shared/profiles/identities/NameIdentity"; -import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logDebug, logError, logTrace, logWarn} from "tc-shared/log"; import * as i18n from "tc-shared/i18n/localize"; import {RepositoryTranslation, TranslationRepository} from "tc-shared/i18n/localize"; import * as events from "tc-shared/events"; @@ -28,7 +27,6 @@ import * as ReactDOM from "react-dom"; import {NotificationSettings} from "tc-shared/ui/modal/settings/Notifications"; import {initialize_audio_microphone_controller, MicrophoneSettingsEvents} from "tc-shared/ui/modal/settings/Microphone"; import {MicrophoneSettings} from "tc-shared/ui/modal/settings/MicrophoneRenderer"; -import {server_connections} from "tc-shared/ConnectionManager"; export function spawnSettingsModal(default_page?: string): Modal { let modal: Modal; @@ -110,7 +108,7 @@ function settings_general_application(container: JQuery, modal: Modal) { select.on('change', event => { const value = parseInt(select.val() as string); settings.setValue(Settings.KEY_FONT_SIZE, value); - console.log("Changed font size to %dpx", value); + logDebug(LogCategory.GENERAL, "Changed font size to %dpx", value); }); } @@ -296,7 +294,7 @@ function settings_general_language(container: JQuery, modal: Modal) { tag.insertAfter(repo_tag); } }).then(() => tag_loading.hide()).catch(error => { - console.error(error); + logError(LogCategory.GENERAL, "Enexpected error happened: %o", error); /* this should NEVER happen */ }) } @@ -429,7 +427,7 @@ function settings_general_chat(container: JQuery, modal: Modal) { container_slider.on('change', event => { const value = parseInt(container_slider.attr("value") as string); settings.setValue(Settings.KEY_ICON_SIZE, value); - console.log("Changed icon size to %sem", (value / 100).toFixed(2)); + logDebug(LogCategory.GENERAL, "Changed icon size to %sem", (value / 100).toFixed(2)); set_icon_size((value / 100).toFixed(2) + "em"); }); @@ -500,12 +498,12 @@ function settings_audio_speaker(container: JQuery, modal: Modal) { tag.addClass("selected"); aplayer.set_device(device ? device.device_id : null).then(() => { - console.debug(tr("Changed default speaker device")); + logDebug(LogCategory.AUDIO, tr("Changed default speaker device")); }).catch((error) => { _old.addClass("selected"); tag.removeClass("selected"); - console.error(tr("Failed to change speaker to device %o: %o"), device, error); + logError(LogCategory.AUDIO, tr("Failed to change speaker to device %o: %o"), device, error); createErrorModal(tr("Failed to change speaker"), formatMessage(tr("Failed to change the speaker device to the target speaker{:br:}{}"), error)).open(); }); }); @@ -521,7 +519,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) { if (typeof (error) === "string") contianer_error.text(error).show(); - console.log(tr("Failed to query available speaker devices: %o"), error); + logDebug(LogCategory.GENERAL, tr("Failed to query available speaker devices: %o"), error); contianer_error.text(tr("Errors occurred (View console)")).show(); }); }; @@ -533,7 +531,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) { try { update_devices(); } catch (error) { - console.error(tr("Failed to build new speaker device list: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to build new speaker device list: %o"), error); } button_update.prop("disabled", false); }); @@ -649,7 +647,7 @@ function settings_audio_sounds(contianer: JQuery, modal: Modal) { tag_input_muted.on('change', event => { const volume = tag_input_muted.prop("checked") ? 1 : 0; sound.set_sound_volume(_sound, volume); - console.log(tr("Changed sound volume to %o for sound %o"), volume, _sound); + logDebug(LogCategory.GENERAL, tr("Changed sound volume to %o for sound %o"), volume, _sound); }); return tag; @@ -710,7 +708,7 @@ export namespace modal_settings { event_registry.on("delete-profile", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("delete-profile-result", event.profile_id, tr("Unknown profile")); return; } @@ -753,7 +751,7 @@ export namespace modal_settings { event_registry.on("query-profile", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("query-profile-result", event.profile_id, tr("Unknown profile")); return; } @@ -768,7 +766,7 @@ export namespace modal_settings { event_registry.on("set-default-profile", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("set-default-profile-result", event.profile_id, tr("Unknown profile")); return; } @@ -784,7 +782,7 @@ export namespace modal_settings { event_registry.on("set-profile-name", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("set-profile-name-result", event.profile_id, tr("Unknown profile")); return; } @@ -801,7 +799,7 @@ export namespace modal_settings { event_registry.on("set-default-name", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("set-default-name-result", event.profile_id, tr("Unknown profile")); return; } @@ -818,7 +816,7 @@ export namespace modal_settings { event_registry.on("set-identity-name-name", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("set-identity-name-name-result", event.profile_id, tr("Unknown profile")); return; } @@ -839,7 +837,7 @@ export namespace modal_settings { event_registry.on("query-profile-validity", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("query-profile-validity-result", event.profile_id, tr("Unknown profile")); return; } @@ -854,7 +852,7 @@ export namespace modal_settings { event_registry.on("query-identity-teamspeak", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("query-identity-teamspeak-result", event.profile_id, tr("Unknown profile")); return; } @@ -888,7 +886,7 @@ export namespace modal_settings { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); return; } @@ -899,7 +897,7 @@ export namespace modal_settings { event_registry.on("generate-identity-teamspeak", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); send_error("generate-identity-teamspeak-result", event.profile_id, tr("Unknown profile")); return; } @@ -916,11 +914,11 @@ export namespace modal_settings { level: level }); }).catch(error => { - console.error(tr("Failed to calculate level for a new identity. Error object: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to calculate level for a new identity. Error object: %o"), error); send_error("generate-identity-teamspeak-result", event.profile_id, tr("failed to calculate level: ") + error); }) }).catch(error => { - console.error(tr("Failed to generate a new identity. Error object: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to generate a new identity. Error object: %o"), error); send_error("generate-identity-teamspeak-result", event.profile_id, tr("failed to generate identity: ") + error); }); }); @@ -928,7 +926,7 @@ export namespace modal_settings { event_registry.on("import-identity-teamspeak", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); return; } @@ -937,7 +935,7 @@ export namespace modal_settings { profiles.mark_need_save(); identity.level().catch(error => { - console.error(tr("Failed to calculate level for a new imported identity. Error object: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to calculate level for a new imported identity. Error object: %o"), error); return Promise.resolve(undefined); }).then(level => { event_registry.fire_react("import-identity-teamspeak-result", { @@ -952,7 +950,7 @@ export namespace modal_settings { event_registry.on("improve-identity-teamspeak-level", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); return; } @@ -968,7 +966,7 @@ export namespace modal_settings { new_level: level }); }).catch(error => { - log.error(LogCategory.CLIENT, tr("Failed to calculate identity level after improvement (%o)"), error); + logError(LogCategory.CLIENT, tr("Failed to calculate identity level after improvement (%o)"), error); }); }); }); @@ -976,7 +974,7 @@ export namespace modal_settings { event_registry.on("export-identity-teamspeak", event => { const profile = profiles.findConnectProfile(event.profile_id); if (!profile) { - log.warn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); + logWarn(LogCategory.CLIENT, tr("Received profile event with unknown profile id (event: %s, id: %s)"), event.type, event.profile_id); return; } @@ -993,7 +991,7 @@ export namespace modal_settings { element[0].click(); element.remove(); }).catch(error => { - console.error(error); + logError(LogCategory.IDENTITIES, tr("Failed to export identity: %o"), error); createErrorModal(tr("Failed to export identity"), tr("Failed to export and save identity.
Error: ") + error).open(); }); }); @@ -1119,7 +1117,7 @@ export namespace modal_settings { }); event_registry.on(["set-default-name-result", "set-profile-name-result", "set-identity-name-name-result", "generate-identity-teamspeak-result"], event => { if (!('status' in event) || !('profile_id' in event)) { - log.warn(LogCategory.CLIENT, tr("Profile status watcher encountered an unuseal event!")); + logWarn(LogCategory.CLIENT, tr("Profile status watcher encountered an unuseal event!")); return; } if ((event as any).status !== "success") return; @@ -1807,7 +1805,7 @@ function settings_identity_forum(container: JQuery, modal: Modal, update_profile forum.login(input_username.val() as string, input_password.val() as string, typeof (captcha) === "string" ? captcha : undefined).then(state => { captcha = false; - console.debug(tr("Forum login result: %o"), state); + logTrace(LogCategory.GENERAL, tr("Forum login result: %o"), state); if (state.status === "success") { update_state(); update_profiles(); @@ -1827,15 +1825,15 @@ function settings_identity_forum(container: JQuery, modal: Modal, update_profile captcha = ""; - console.log(tr("Showing captcha for site-key: %o"), state.captcha.data); + logDebug(LogCategory.GENERAL, tr("Showing captcha for site-key: %o"), state.captcha.data); forum.gcaptcha.spawn(container_captcha_g, state.captcha.data, token => { captcha = token; - console.debug(tr("Got captcha token: %o"), token); + logTrace(LogCategory.GENERAL, tr("Got captcha token: %o"), token); container_captcha_g.hide(); button_login.show(); update_button_state(); }).catch(error => { - console.error(tr("Failed to initialize forum captcha: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to initialize forum captcha: %o"), error); container_error.text("Failed to initialize GReCaptcha! No authentication possible.").addClass("shown"); container_captcha_g.hide(); button_login.hide(); @@ -1845,7 +1843,7 @@ function settings_identity_forum(container: JQuery, modal: Modal, update_profile container_error.text(state.error_message || tr("Unknown error")).addClass("shown"); } }).catch(error => { - console.error(tr("Failed to login within the forum. Error: %o"), error); + logError(LogCategory.GENERAL, tr("Failed to login within the forum. Error: %o"), error); createErrorModal(tr("Forum login failed."), tr("Forum login failed. Lookup the console for more information")).open(); }).then(() => { input_username.prop("disabled", false); @@ -1860,7 +1858,7 @@ function settings_identity_forum(container: JQuery, modal: Modal, update_profile { container.find(".button-logout").on('click', event => { forum.logout().catch(error => { - console.error(tr("Failed to logout from forum: %o"), error); + logError(LogCategory.IDENTITIES, tr("Failed to logout from forum: %o"), error); createErrorModal(tr("Forum logout failed"), formatMessage(tr("Failed to logout from forum account.{:br:}Error: {}"), error)).open(); }).then(() => { if (modal.shown) diff --git a/shared/js/ui/modal/channel-edit/Controller.ts b/shared/js/ui/modal/channel-edit/Controller.ts index 676ddf1d..dbe9d45f 100644 --- a/shared/js/ui/modal/channel-edit/Controller.ts +++ b/shared/js/ui/modal/channel-edit/Controller.ts @@ -8,7 +8,7 @@ import { } from "tc-shared/ui/modal/channel-edit/Definitions"; import {Registry} from "tc-shared/events"; import {ChannelPropertyProviders} from "tc-shared/ui/modal/channel-edit/ControllerProperties"; -import {LogCategory, logDebug, logError, logInfo} from "tc-shared/log"; +import {LogCategory, logDebug, logError} from "tc-shared/log"; import {ChannelPropertyPermissionsProviders} from "tc-shared/ui/modal/channel-edit/ControllerPermissions"; import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; import {ChannelEditModal} from "tc-shared/ui/modal/channel-edit/Renderer"; @@ -301,7 +301,6 @@ class ChannelEditController { }).catch(error => { if(error instanceof CommandResult) { if(error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) { - console.error(error); this.cachedChannelPermissions = { state: "no-permissions", failedPermission: this.connection.permissions.getFailedPermission(error) diff --git a/shared/js/ui/modal/channel-edit/Renderer.tsx b/shared/js/ui/modal/channel-edit/Renderer.tsx index 40a286ef..32c7bcb9 100644 --- a/shared/js/ui/modal/channel-edit/Renderer.tsx +++ b/shared/js/ui/modal/channel-edit/Renderer.tsx @@ -1,14 +1,16 @@ import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import * as React from "react"; +import {useContext, useEffect, useRef, useState} from "react"; import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; import {Registry} from "tc-shared/events"; import { - ChannelEditablePermissions, ChannelEditablePermissionValue, + ChannelEditablePermissions, + ChannelEditablePermissionValue, ChannelEditableProperty, - ChannelEditEvents, ChannelEditPermissionsState, + ChannelEditEvents, + ChannelEditPermissionsState, ChannelPropertyPermission } from "tc-shared/ui/modal/channel-edit/Definitions"; -import {useContext, useEffect, useRef, useState} from "react"; import {BoxedInputField, Select} from "tc-shared/ui/react-elements/InputField"; import {Switch} from "tc-shared/ui/react-elements/Switch"; import {Button} from "tc-shared/ui/react-elements/Button"; diff --git a/shared/js/ui/modal/connect/Definitions.ts b/shared/js/ui/modal/connect/Definitions.ts index 982e263f..31ec994d 100644 --- a/shared/js/ui/modal/connect/Definitions.ts +++ b/shared/js/ui/modal/connect/Definitions.ts @@ -1,5 +1,5 @@ import {kUnknownHistoryServerUniqueId} from "tc-shared/connectionlog/History"; -import { RemoteIconInfo} from "tc-shared/file/Icons"; +import {RemoteIconInfo} from "tc-shared/file/Icons"; export type ConnectProfileEntry = { id: string, diff --git a/shared/js/ui/modal/connect/Renderer.tsx b/shared/js/ui/modal/connect/Renderer.tsx index 0ffa3aab..cf74ca7d 100644 --- a/shared/js/ui/modal/connect/Renderer.tsx +++ b/shared/js/ui/modal/connect/Renderer.tsx @@ -2,7 +2,8 @@ import { ConnectHistoryEntry, ConnectHistoryServerInfo, ConnectProperties, - ConnectUiEvents, PropertyValidState + ConnectUiEvents, + PropertyValidState } from "tc-shared/ui/modal/connect/Definitions"; import * as React from "react"; import {useContext, useState} from "react"; diff --git a/shared/js/ui/modal/css-editor/Controller.ts b/shared/js/ui/modal/css-editor/Controller.ts index 4ae51d24..5a1654b8 100644 --- a/shared/js/ui/modal/css-editor/Controller.ts +++ b/shared/js/ui/modal/css-editor/Controller.ts @@ -4,7 +4,7 @@ import {CssEditorEvents, CssVariable} from "../../../ui/modal/css-editor/Definit import {spawnExternalModal} from "../../../ui/react-elements/external-modal"; import {Registry} from "../../../events"; import {LogCategory, logWarn} from "../../../log"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; interface CustomVariable { name: string; @@ -204,7 +204,7 @@ function cssVariableEditorController(events: Registry) { events.fire_react("action_select_entry", {variable: undefined}); events.fire_react("query_css_variables"); } catch (error) { - console.warn("Failed to import CSS variable values: %o", error); + logWarn(LogCategory.GENERAL, "Failed to import CSS variable values: %o", error); events.fire_react("notify_import_result", {success: false}); } }); diff --git a/shared/js/ui/modal/css-editor/Renderer.tsx b/shared/js/ui/modal/css-editor/Renderer.tsx index 75fdc9cc..0156e42e 100644 --- a/shared/js/ui/modal/css-editor/Renderer.tsx +++ b/shared/js/ui/modal/css-editor/Renderer.tsx @@ -163,7 +163,7 @@ const CssVariableListRenderer = (props: { events: Registry }) = -
console.error(event.key)}> +
diff --git a/shared/js/ui/modal/global-settings-editor/Controller.tsx b/shared/js/ui/modal/global-settings-editor/Controller.tsx index 929bd6e4..98af6467 100644 --- a/shared/js/ui/modal/global-settings-editor/Controller.tsx +++ b/shared/js/ui/modal/global-settings-editor/Controller.tsx @@ -2,7 +2,7 @@ import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; import {ModalGlobalSettingsEditor} from "tc-shared/ui/modal/global-settings-editor/Renderer"; import {Registry} from "tc-shared/events"; import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions"; -import {RegistryValueType, settings, Settings, RegistryKey} from "tc-shared/settings"; +import {RegistryKey, RegistryValueType, Settings, settings} from "tc-shared/settings"; export function spawnGlobalSettingsEditor() { const events = new Registry(); diff --git a/shared/js/ui/modal/global-settings-editor/Renderer.tsx b/shared/js/ui/modal/global-settings-editor/Renderer.tsx index b498c530..d2de2032 100644 --- a/shared/js/ui/modal/global-settings-editor/Renderer.tsx +++ b/shared/js/ui/modal/global-settings-editor/Renderer.tsx @@ -1,7 +1,7 @@ import {Translatable} from "tc-shared/ui/react-elements/i18n"; import * as React from "react"; -import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {createContext, useContext, useRef, useState} from "react"; +import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {Registry} from "tc-shared/events"; import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; diff --git a/shared/js/ui/modal/permission/ModalPermissionEditor.tsx b/shared/js/ui/modal/permission/ModalPermissionEditor.tsx index 782c2f7f..e08c5588 100644 --- a/shared/js/ui/modal/permission/ModalPermissionEditor.tsx +++ b/shared/js/ui/modal/permission/ModalPermissionEditor.tsx @@ -33,6 +33,7 @@ import {spawnModalGroupPermissionCopy} from "tc-shared/ui/modal/ModalGroupPermis import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {ErrorCode} from "tc-shared/connection/ErrorCode"; import {PermissionEditorTab} from "tc-shared/events/GlobalEvents"; +import {LogCategory, logError, logWarn} from "tc-shared/log"; const cssStyle = require("./ModalPermissionEditor.scss"); @@ -540,7 +541,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even connection.serverConnection.send_command(event.target + "grouprename", payload).then(() => { events.fire("action_rename_group_result", {id: groupId, status: "success", target: event.target}); }).catch(error => { - console.warn(tr("Failed to rename group: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to rename group: %o"), error); events.fire("action_rename_group_result", { id: groupId, status: "error", @@ -567,7 +568,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even connection.serverConnection.send_command(event.target + "groupdel", payload).then(() => { events.fire("action_delete_group_result", {id: groupId, status: "success", target: event.target}); }).catch(error => { - console.warn(tr("Failed to delete group: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to delete group: %o"), error); events.fire("action_delete_group_result", { id: groupId, status: "error", @@ -628,7 +629,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even return; } - console.warn(tr("Failed to request server group client list: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to request server group client list: %o"), error); events.fire("query_group_clients_result", {id: event.id, status: "error", error: stringifyError(error)}); }); }); @@ -658,7 +659,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even return; } - console.warn(tr("Failed to add client %s to server group %d: %o"), event.client.toString(), event.id, error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to add client %s to server group %d: %o"), event.client.toString(), event.id, error); events.fire("action_server_group_add_client_result", { id: event.id, client: event.client, @@ -679,7 +680,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even status: "success" }); }).catch(error => { - console.log(tr("Failed to delete client %d from server group %d: %o"), event.client, event.id, error); + logError(LogCategory.GENERAL, tr("Failed to delete client %d from server group %d: %o"), event.client, event.id, error); events.fire("action_server_group_remove_client_result", { id: event.id, client: event.client, @@ -751,7 +752,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even return; } - console.warn(tr("Failed to query client info for %o: %o"), event.client, error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to query client info for %o: %o"), event.client, error); events.fire("query_client_info_result", { client: event.client, state: "error", @@ -969,7 +970,7 @@ function initializePermissionEditor(connection: ConnectionHandler, modalEvents: return; } - console.warn(tr("Failed to query permissions: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to query permissions: %o"), error); events.fire("query_permission_values_result", {status: "error", error: stringifyError(error)}); }); }); @@ -1066,7 +1067,7 @@ function initializePermissionEditor(connection: ConnectionHandler, modalEvents: } } - console.warn(tr("Failed to set permissions: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to set permissions: %o"), error); events.fire("action_set_permissions_result", { permissions: event.permissions.map(permission => { return { @@ -1165,7 +1166,7 @@ function initializePermissionEditor(connection: ConnectionHandler, modalEvents: } } - console.warn(tr("Failed to remove permissions: %o"), error); + logWarn(LogCategory.PERMISSIONS, tr("Failed to remove permissions: %o"), error); events.fire("action_remove_permissions_result", { permissions: event.permissions.map(permission => { return { diff --git a/shared/js/ui/modal/permission/PermissionEditor.tsx b/shared/js/ui/modal/permission/PermissionEditor.tsx index 426bfa35..c4667035 100644 --- a/shared/js/ui/modal/permission/PermissionEditor.tsx +++ b/shared/js/ui/modal/permission/PermissionEditor.tsx @@ -5,8 +5,7 @@ import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {EventHandler, ReactEventHandler, Registry} from "tc-shared/events"; import {Switch} from "tc-shared/ui/react-elements/Switch"; import PermissionType from "tc-shared/permission/PermissionType"; -import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logDebug, logWarn} from "tc-shared/log"; import ResizeObserver from "resize-observer-polyfill"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; @@ -879,14 +878,14 @@ class PermissionList extends React.Component<{ events: Registry { if (entries.length !== 1) { if (entries.length === 0) - log.warn(LogCategory.PERMISSIONS, tr("Permission editor resize observer fired resize event with no entries!")); + logWarn(LogCategory.PERMISSIONS, tr("Permission editor resize observer fired resize event with no entries!")); else - log.warn(LogCategory.PERMISSIONS, tr("Permission editor resize observer fired resize event with more than one entry which should not be possible (%d)!"), entries.length); + logWarn(LogCategory.PERMISSIONS, tr("Permission editor resize observer fired resize event with more than one entry which should not be possible (%d)!"), entries.length); return; } const bounds = entries[0].contentRect; if (this.state.viewHeight !== bounds.height) { - log.debug(LogCategory.PERMISSIONS, tr("Handling height update and change permission view height to %d from %d"), bounds.height, this.state.viewHeight); + logDebug(LogCategory.PERMISSIONS, tr("Handling height update and change permission view height to %d from %d"), bounds.height, this.state.viewHeight); this.setState({ viewHeight: bounds.height }); @@ -1090,7 +1089,7 @@ class PermissionList extends React.Component<{ events: Registry) { keycontrol.setKey(event.action, event.key); event_registry.fire_react("set_keymap_result", {status: "success", action: event.action, key: event.key}); } catch (error) { - console.warn("Failed to change key for action %s: %o", event.action, error); + logWarn(LogCategory.GENERAL, tr("Failed to change key for action %s: %o"), event.action, error); event_registry.fire_react("set_keymap_result", { status: "error", action: event.action, diff --git a/shared/js/ui/modal/settings/Microphone.tsx b/shared/js/ui/modal/settings/Microphone.tsx index aa3de6a5..094d92f3 100644 --- a/shared/js/ui/modal/settings/Microphone.tsx +++ b/shared/js/ui/modal/settings/Microphone.tsx @@ -2,8 +2,7 @@ import * as aplayer from "tc-backend/audio/player"; import * as React from "react"; import {Registry} from "tc-shared/events"; import {LevelMeter} from "tc-shared/voice/RecorderBase"; -import * as log from "tc-shared/log"; -import {LogCategory, logWarn} from "tc-shared/log"; +import {LogCategory, logTrace, logWarn} from "tc-shared/log"; import {defaultRecorder} from "tc-shared/voice/RecorderProfile"; import {DeviceListState, getRecorderBackend, IDevice} from "tc-shared/audio/recorder"; import {Settings, settings} from "tc-shared/settings"; @@ -133,7 +132,7 @@ export function initialize_audio_microphone_controller(events: Registry { - console.debug(tr("Changed default microphone device to %s"), event.deviceId); + logTrace(LogCategory.GENERAL, tr("Changed default microphone device to %s"), event.deviceId); events.fire_react("action_set_selected_device_result", {status: "success", deviceId: event.deviceId}); }).catch((error) => { - log.warn(LogCategory.AUDIO, tr("Failed to change microphone to device %s: %o"), device ? device.deviceId : IDevice.NoDeviceId, error); + logWarn(LogCategory.AUDIO, tr("Failed to change microphone to device %s: %o"), device ? device.deviceId : IDevice.NoDeviceId, error); events.fire_react("action_set_selected_device_result", {status: "success", deviceId: event.deviceId}); }); }); @@ -323,8 +322,6 @@ export function initialize_audio_microphone_controller(events: Registry recorderBackend.getDeviceList().requestPermissions().then(result => { - console.error("Permission request result: %o", result); - if (result === "granted") { /* we've nothing to do, the device change event will already update out list */ } else { diff --git a/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts b/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts index e7cfb694..33c4d364 100644 --- a/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts +++ b/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts @@ -3,8 +3,7 @@ import {Registry} from "../../../events"; import {FileType} from "../../../file/FileManager"; import {CommandResult} from "../../../connection/ServerConnectionDeclaration"; import PermissionType from "../../../permission/PermissionType"; -import * as log from "../../../log"; -import {LogCategory, logTrace} from "../../../log"; +import {LogCategory, logError, logTrace} from "../../../log"; import {Entry, MenuEntry, MenuEntryType, spawn_context_menu} from "../../../ui/elements/ContextMenu"; import * as ppt from "tc-backend/ppt"; import {SpecialKey} from "../../../PPTListener"; @@ -21,8 +20,10 @@ import {createErrorModal} from "../../../ui/elements/Modal"; import {ErrorCode} from "../../../connection/ErrorCode"; import { avatarsPathPrefix, - channelPathPrefix, FileBrowserEvents, - iconPathPrefix, ListedFileInfo, + channelPathPrefix, + FileBrowserEvents, + iconPathPrefix, + ListedFileInfo, PathInfo } from "tc-shared/ui/modal/transfer/FileDefinitions"; @@ -253,7 +254,7 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand } else if (typeof error === "string") { message = error; } else { - log.error(LogCategory.FILE_TRANSFER, tr("Failed to query channel directory files: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to query channel directory files: %o"), error); message = tr("lookup the console"); } @@ -358,7 +359,7 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand } else if (typeof error === "string") { message = error; } else { - log.error(LogCategory.FILE_TRANSFER, tr("Failed to rename/move files: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to rename/move files: %o"), error); message = tr("lookup the console"); } events.fire_react("action_rename_file_result", { @@ -598,7 +599,7 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand } else if (typeof result === "string") { message = result; } else { - log.error(LogCategory.FILE_TRANSFER, tr("Failed to create directory: %o"), result); + logError(LogCategory.FILE_TRANSFER, tr("Failed to create directory: %o"), result); message = tr("lookup the console"); } @@ -676,7 +677,7 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand } else if (typeof error === "string") { message = error; } else { - log.error(LogCategory.FILE_TRANSFER, tr("Failed to create directory: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to create directory: %o"), error); message = tr("lookup the console"); } events.fire_react("action_create_directory_result", { @@ -717,7 +718,7 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand } }); } catch (error) { - log.error(LogCategory.FILE_TRANSFER, tr("Failed to parse path for file download: %s"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to parse path for file download: %s"), error); } }); }); diff --git a/shared/js/ui/modal/transfer/FileBrowserRenderer.tsx b/shared/js/ui/modal/transfer/FileBrowserRenderer.tsx index e45c442e..9e2fcd24 100644 --- a/shared/js/ui/modal/transfer/FileBrowserRenderer.tsx +++ b/shared/js/ui/modal/transfer/FileBrowserRenderer.tsx @@ -12,10 +12,8 @@ import {Translatable} from "tc-shared/ui/react-elements/i18n"; import * as Moment from "moment"; import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu"; import {BoxedInputField} from "tc-shared/ui/react-elements/InputField"; -import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logWarn} from "tc-shared/log"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; -import React = require("react"); import { FileBrowserEvents, FileTransferUrlMediaType, @@ -23,6 +21,7 @@ import { TransferStatus } from "tc-shared/ui/modal/transfer/FileDefinitions"; import {joinClassList} from "tc-shared/ui/react-elements/Helper"; +import React = require("react"); export interface FileBrowserRendererClasses { navigation?: { @@ -130,7 +129,7 @@ const NavigationEntry = (props: { events: Registry, path: str files: [...event.dataTransfer.files] }); } else { - log.warn(LogCategory.FILE_TRANSFER, tr("Received an unknown drop media type (%o)"), types); + logWarn(LogCategory.FILE_TRANSFER, tr("Received an unknown drop media type (%o)"), types); event.preventDefault(); return; } @@ -1169,7 +1168,6 @@ export class FileBrowserRenderer extends ReactComponentBase decodeURIComponent(e)); for (const fileUrl of fileUrls) { const name = fileUrl.split("/").last(); @@ -1189,7 +1187,7 @@ export class FileBrowserRenderer extends ReactComponentBase e.name === event.name); if (!entry) { if (event.mode !== "upload") { - log.warn(LogCategory.FILE_TRANSFER, tr("Having file download start notification for current path, but target file is unknown (%s%s)"), event.path, event.name); + logWarn(LogCategory.FILE_TRANSFER, tr("Having file download start notification for current path, but target file is unknown (%s%s)"), event.path, event.name); return; } diff --git a/shared/js/ui/modal/video-source/Renderer.tsx b/shared/js/ui/modal/video-source/Renderer.tsx index c07c40aa..5efad38e 100644 --- a/shared/js/ui/modal/video-source/Renderer.tsx +++ b/shared/js/ui/modal/video-source/Renderer.tsx @@ -1,22 +1,25 @@ import {Registry} from "tc-shared/events"; import * as React from "react"; +import {useContext, useEffect, useRef, useState} from "react"; import { DeviceListResult, - ModalVideoSourceEvents, ScreenCaptureDeviceList, SettingBitrate, SettingFrameRate, - VideoPreviewStatus, VideoSourceState + ModalVideoSourceEvents, + ScreenCaptureDeviceList, + SettingBitrate, + SettingFrameRate, + VideoPreviewStatus, + VideoSourceState } from "tc-shared/ui/modal/video-source/Definitions"; import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n"; import {BoxedInputField, Select} from "tc-shared/ui/react-elements/InputField"; import {Button} from "tc-shared/ui/react-elements/Button"; -import {useContext, useEffect, useRef, useState} from "react"; import {VideoBroadcastType} from "tc-shared/connection/VideoConnection"; import {Slider} from "tc-shared/ui/react-elements/Slider"; import {Checkbox} from "tc-shared/ui/react-elements/Checkbox"; import {Tab, TabEntry} from "tc-shared/ui/react-elements/Tab"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; import {ScreenCaptureDevice} from "tc-shared/video/VideoSource"; -import {useTr} from "tc-shared/ui/react-elements/Helper"; const cssStyle = require("./Renderer.scss"); const ModalEvents = React.createContext>(undefined); diff --git a/shared/js/ui/react-elements/Avatar.tsx b/shared/js/ui/react-elements/Avatar.tsx index 7e2dd862..4e76f70b 100644 --- a/shared/js/ui/react-elements/Avatar.tsx +++ b/shared/js/ui/react-elements/Avatar.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import {ClientAvatar, kDefaultAvatarImage, kLoadingAvatarImage} from "tc-shared/file/Avatars"; import {useEffect, useState} from "react"; +import {ClientAvatar, kDefaultAvatarImage, kLoadingAvatarImage} from "tc-shared/file/Avatars"; import * as image_preview from "tc-shared/ui/frames/image_preview"; const ImageStyle = { height: "100%", width: "100%", cursor: "pointer" }; diff --git a/shared/js/ui/react-elements/Button.tsx b/shared/js/ui/react-elements/Button.tsx index a8068e83..c5cb9142 100644 --- a/shared/js/ui/react-elements/Button.tsx +++ b/shared/js/ui/react-elements/Button.tsx @@ -1,5 +1,6 @@ import {ReactComponentBase} from "tc-shared/ui/react-elements/ReactComponentBase"; import * as React from "react"; + const cssStyle = require("./Button.scss"); export interface ButtonProperties { diff --git a/shared/js/ui/react-elements/ChatBox.tsx b/shared/js/ui/react-elements/ChatBox.tsx index 0a8a3124..852cfe4c 100644 --- a/shared/js/ui/react-elements/ChatBox.tsx +++ b/shared/js/ui/react-elements/ChatBox.tsx @@ -3,7 +3,7 @@ import {useEffect, useRef, useState} from "react"; import {Registry} from "tc-shared/events"; import '!style-loader!css-loader!emoji-mart/css/emoji-mart.css' -import { Picker } from 'emoji-mart' +import {Picker} from 'emoji-mart' import {settings, Settings} from "tc-shared/settings"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; diff --git a/shared/js/ui/react-elements/Checkbox.tsx b/shared/js/ui/react-elements/Checkbox.tsx index 3eb1d538..033b83e0 100644 --- a/shared/js/ui/react-elements/Checkbox.tsx +++ b/shared/js/ui/react-elements/Checkbox.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import {ReactElement} from "react"; + const cssStyle = require("./Checkbox.scss"); export interface CheckboxProperties { diff --git a/shared/js/ui/react-elements/ContextDivider.tsx b/shared/js/ui/react-elements/ContextDivider.tsx index a41a6ac1..3e2f8b15 100644 --- a/shared/js/ui/react-elements/ContextDivider.tsx +++ b/shared/js/ui/react-elements/ContextDivider.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import {Settings, settings} from "tc-shared/settings"; + const cssStyle = require("./ContextDivider.scss"); export interface ContextDividerProperties { diff --git a/shared/js/ui/react-elements/Helper.ts b/shared/js/ui/react-elements/Helper.ts index c9e42f34..efbfc54a 100644 --- a/shared/js/ui/react-elements/Helper.ts +++ b/shared/js/ui/react-elements/Helper.ts @@ -1,5 +1,5 @@ import {Dispatch, SetStateAction, useEffect, useMemo, useState} from "react"; -import {RegistryValueType, settings, RegistryKey, ValuedRegistryKey} from "tc-shared/settings"; +import {RegistryKey, RegistryValueType, settings, ValuedRegistryKey} from "tc-shared/settings"; export function useDependentState( factory: (prevState?: S) => S, diff --git a/shared/js/ui/react-elements/Icon.tsx b/shared/js/ui/react-elements/Icon.tsx index 28d975c0..044dd42e 100644 --- a/shared/js/ui/react-elements/Icon.tsx +++ b/shared/js/ui/react-elements/Icon.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import {RemoteIcon} from "tc-shared/file/Icons"; import {useState} from "react"; +import {RemoteIcon} from "tc-shared/file/Icons"; const cssStyle = require("./Icon.scss"); diff --git a/shared/js/ui/react-elements/LoadingDots.tsx b/shared/js/ui/react-elements/LoadingDots.tsx index 9e2eca29..acacaafb 100644 --- a/shared/js/ui/react-elements/LoadingDots.tsx +++ b/shared/js/ui/react-elements/LoadingDots.tsx @@ -1,5 +1,5 @@ -import {useEffect, useState} from "react"; import * as React from "react"; +import {useEffect, useState} from "react"; export const LoadingDots = (props: { maxDots?: number, speed?: number, textOnly?: boolean, enabled?: boolean }) => { let { maxDots, speed } = props; diff --git a/shared/js/ui/react-elements/ModalDefinitions.ts b/shared/js/ui/react-elements/ModalDefinitions.ts index c2044c35..f47bdc18 100644 --- a/shared/js/ui/react-elements/ModalDefinitions.ts +++ b/shared/js/ui/react-elements/ModalDefinitions.ts @@ -1,7 +1,6 @@ import * as React from "react"; import {ReactElement} from "react"; import {Registry} from "../../events"; -import {Translatable} from "../../ui/react-elements/i18n"; export type ModalType = "error" | "warning" | "info" | "none"; diff --git a/shared/js/ui/react-elements/ProgressBar.tsx b/shared/js/ui/react-elements/ProgressBar.tsx index c9ddbb44..1b842bec 100644 --- a/shared/js/ui/react-elements/ProgressBar.tsx +++ b/shared/js/ui/react-elements/ProgressBar.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import {ReactElement} from "react"; + const cssStyle = require("./ProgressBar.scss"); export interface ProgressBarState { diff --git a/shared/js/ui/react-elements/Slider.tsx b/shared/js/ui/react-elements/Slider.tsx index d9d1e33d..14a4c87b 100644 --- a/shared/js/ui/react-elements/Slider.tsx +++ b/shared/js/ui/react-elements/Slider.tsx @@ -1,6 +1,7 @@ import * as React from "react"; -import {Tooltip} from "tc-shared/ui/react-elements/Tooltip"; import {ReactElement} from "react"; +import {Tooltip} from "tc-shared/ui/react-elements/Tooltip"; + const cssStyle = require("./Slider.scss"); export interface SliderProperties { diff --git a/shared/js/ui/react-elements/Switch.tsx b/shared/js/ui/react-elements/Switch.tsx index 82635682..3b53bd4d 100644 --- a/shared/js/ui/react-elements/Switch.tsx +++ b/shared/js/ui/react-elements/Switch.tsx @@ -1,4 +1,5 @@ import * as React from "react"; + const cssStyle = require("./Switch.scss"); export interface SwitchProperties { diff --git a/shared/js/ui/react-elements/TimestampRenderer.tsx b/shared/js/ui/react-elements/TimestampRenderer.tsx index d511a215..706aff27 100644 --- a/shared/js/ui/react-elements/TimestampRenderer.tsx +++ b/shared/js/ui/react-elements/TimestampRenderer.tsx @@ -1,5 +1,5 @@ -import {useEffect, useState} from "react"; import * as React from "react"; +import {useEffect, useState} from "react"; import {format_chat_time} from "tc-shared/utils/DateUtils"; export const TimestampRenderer = (props: { timestamp: number }) => { diff --git a/shared/js/ui/react-elements/Tooltip.tsx b/shared/js/ui/react-elements/Tooltip.tsx index 525cbc10..ee1a7e85 100644 --- a/shared/js/ui/react-elements/Tooltip.tsx +++ b/shared/js/ui/react-elements/Tooltip.tsx @@ -1,8 +1,7 @@ import * as React from "react"; -import * as ReactDOM from "react-dom"; import {ReactElement} from "react"; +import * as ReactDOM from "react-dom"; import {guid} from "tc-shared/crypto/uid"; -import {Translatable} from "tc-shared/ui/react-elements/i18n"; const cssStyle = require("./Tooltip.scss"); diff --git a/shared/js/ui/react-elements/external-modal/Controller.ts b/shared/js/ui/react-elements/external-modal/Controller.ts index 2291a63b..9bac92eb 100644 --- a/shared/js/ui/react-elements/external-modal/Controller.ts +++ b/shared/js/ui/react-elements/external-modal/Controller.ts @@ -1,5 +1,4 @@ -import * as log from "../../../log"; -import {LogCategory} from "../../../log"; +import {LogCategory, logDebug, logTrace, logWarn} from "../../../log"; import * as ipc from "../../../ipc/BrowserIPC"; import {ChannelMessage} from "../../../ipc/BrowserIPC"; import {Registry, RegistryMap} from "../../../events"; @@ -127,7 +126,7 @@ export abstract class AbstractExternalModalController extends EventControllerBas return; if(this.ipcRemoteId === undefined) { - log.debug(LogCategory.IPC, tr("Remote window connected with id %s"), remoteId); + logDebug(LogCategory.IPC, tr("Remote window connected with id %s"), remoteId); this.ipcRemoteId = remoteId; } else if(this.ipcRemoteId !== remoteId) { this.ipcRemoteId = remoteId; @@ -142,7 +141,7 @@ export abstract class AbstractExternalModalController extends EventControllerBas switch (type) { case "hello-popout": { const tpayload = payload as PopoutIPCMessage["hello-popout"]; - log.trace(LogCategory.IPC, "Received Hello World from popup with version %s (expected %s).", tpayload.version, __build.version); + logTrace(LogCategory.IPC, "Received Hello World from popup with version %s (expected %s).", tpayload.version, __build.version); if(tpayload.version !== __build.version) { this.sendIPCMessage("hello-controller", { accepted: false, message: tr("version miss match") }); if(this.callbackWindowInitialized) { @@ -171,7 +170,7 @@ export abstract class AbstractExternalModalController extends EventControllerBas break; default: - log.warn(LogCategory.IPC, "Received unknown message type from popup window: %s", type); + logWarn(LogCategory.IPC, "Received unknown message type from popup window: %s", type); return; } } diff --git a/shared/js/ui/react-elements/external-modal/PopoutController.ts b/shared/js/ui/react-elements/external-modal/PopoutController.ts index b9ddae47..6b4d5f92 100644 --- a/shared/js/ui/react-elements/external-modal/PopoutController.ts +++ b/shared/js/ui/react-elements/external-modal/PopoutController.ts @@ -1,7 +1,8 @@ import {getIpcInstance as getIPCInstance} from "../../../ipc/BrowserIPC"; import {AppParameters} from "../../../settings"; import { - Controller2PopoutMessages, EventControllerBase, + Controller2PopoutMessages, + EventControllerBase, PopoutIPCMessage } from "../../../ui/react-elements/external-modal/IPCMessage"; import {Registry, RegistryMap} from "../../../events"; diff --git a/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts b/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts index be10ae8e..ff2af0e7 100644 --- a/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts +++ b/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts @@ -1,8 +1,7 @@ import * as loader from "tc-loader"; +import {Stage} from "tc-loader"; import * as ipc from "../../../ipc/BrowserIPC"; import * as i18n from "../../../i18n/localize"; - -import {Stage} from "tc-loader"; import {AbstractModal, ModalRenderer} from "../../../ui/react-elements/ModalDefinitions"; import {AppParameters} from "../../../settings"; import {getPopoutController} from "./PopoutController"; diff --git a/shared/js/ui/react-elements/external-modal/index.ts b/shared/js/ui/react-elements/external-modal/index.ts index df12fd91..795cbe14 100644 --- a/shared/js/ui/react-elements/external-modal/index.ts +++ b/shared/js/ui/react-elements/external-modal/index.ts @@ -1,4 +1,4 @@ -import {Registry, RegistryMap} from "../../../events"; +import {RegistryMap} from "../../../events"; import "./Controller"; import {ModalController} from "../../../ui/react-elements/ModalDefinitions"; /* we've to reference him here, else the client would not */ diff --git a/shared/js/ui/react-elements/i18n/index.tsx b/shared/js/ui/react-elements/i18n/index.tsx index 27456d06..21bbeddd 100644 --- a/shared/js/ui/react-elements/i18n/index.tsx +++ b/shared/js/ui/react-elements/i18n/index.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import {parseMessageWithArguments} from "tc-shared/ui/frames/chat"; import {cloneElement} from "react"; +import {parseMessageWithArguments} from "tc-shared/ui/frames/chat"; let instances = []; export class Translatable extends React.Component<{ diff --git a/shared/js/ui/react-elements/internal-modal/Controller.ts b/shared/js/ui/react-elements/internal-modal/Controller.ts index 6c6d294d..ffaa3f71 100644 --- a/shared/js/ui/react-elements/internal-modal/Controller.ts +++ b/shared/js/ui/react-elements/internal-modal/Controller.ts @@ -1,9 +1,15 @@ import {Registry} from "../../../events"; import * as React from "react"; import * as ReactDOM from "react-dom"; -import {AbstractModal, ModalController, ModalEvents, ModalOptions, ModalState} from "../../../ui/react-elements/ModalDefinitions"; +import { + AbstractModal, + ModalController, + ModalEvents, + ModalOptions, + ModalState +} from "../../../ui/react-elements/ModalDefinitions"; import {InternalModalRenderer} from "../../../ui/react-elements/internal-modal/Renderer"; -import { tr } from "tc-shared/i18n/localize"; +import {tr} from "tc-shared/i18n/localize"; export class InternalModalController implements ModalController { readonly events: Registry; diff --git a/shared/js/ui/tree/Controller.tsx b/shared/js/ui/tree/Controller.tsx index 8742ce23..e4a614b8 100644 --- a/shared/js/ui/tree/Controller.tsx +++ b/shared/js/ui/tree/Controller.tsx @@ -4,8 +4,11 @@ import {EventHandler, Registry} from "tc-shared/events"; import { ChannelEntryInfo, ChannelIcons, - ChannelTreeUIEvents, ClientIcons, ClientNameInfo, - ClientTalkIconState, FullChannelTreeEntry, + ChannelTreeUIEvents, + ClientIcons, + ClientNameInfo, + ClientTalkIconState, + FullChannelTreeEntry, ServerState } from "tc-shared/ui/tree/Definitions"; import * as React from "react"; diff --git a/shared/js/ui/tree/Renderer.tsx b/shared/js/ui/tree/Renderer.tsx index e0201ec9..a33d0ff0 100644 --- a/shared/js/ui/tree/Renderer.tsx +++ b/shared/js/ui/tree/Renderer.tsx @@ -1,9 +1,9 @@ import {Registry} from "tc-shared/events"; import {ChannelTreeUIEvents} from "tc-shared/ui/tree/Definitions"; import * as React from "react"; +import {useEffect, useRef} from "react"; import {ChannelTreeView, PopoutButton} from "tc-shared/ui/tree/RendererView"; import {RDPChannel, RDPChannelTree} from "./RendererDataProvider"; -import {useEffect, useRef} from "react"; const viewStyle = require("./View.scss"); diff --git a/shared/js/ui/tree/RendererClient.tsx b/shared/js/ui/tree/RendererClient.tsx index 05b5833a..622d6d6b 100644 --- a/shared/js/ui/tree/RendererClient.tsx +++ b/shared/js/ui/tree/RendererClient.tsx @@ -8,6 +8,7 @@ import {UnreadMarkerRenderer} from "tc-shared/ui/tree/RendererTreeEntry"; import {RDPClient} from "tc-shared/ui/tree/RendererDataProvider"; import * as DOMPurify from "dompurify"; import {ChannelTreeView} from "tc-shared/ui/tree/RendererView"; +import {LogCategory, logWarn} from "tc-shared/log"; const clientStyle = require("./Client.scss"); const viewStyle = require("./View.scss"); @@ -133,7 +134,7 @@ function selectText(node: HTMLElement) { selection.removeAllRanges(); selection.addRange(range); } else { - console.warn("Could not select text in node: Unsupported browser."); + logWarn(LogCategory.GENERAL, tr("Could not select text in node: Unsupported browser.")); } } diff --git a/shared/js/ui/tree/RendererDataProvider.tsx b/shared/js/ui/tree/RendererDataProvider.tsx index 745b98e0..28ef4042 100644 --- a/shared/js/ui/tree/RendererDataProvider.tsx +++ b/shared/js/ui/tree/RendererDataProvider.tsx @@ -1,7 +1,8 @@ import {EventHandler, Registry} from "tc-shared/events"; import { ChannelEntryInfo, - ChannelIcons, ChannelTreeDragEntry, + ChannelIcons, + ChannelTreeDragEntry, ChannelTreeUIEvents, ClientIcons, ClientNameInfo, diff --git a/shared/js/ui/tree/RendererView.tsx b/shared/js/ui/tree/RendererView.tsx index a637633a..a690a886 100644 --- a/shared/js/ui/tree/RendererView.tsx +++ b/shared/js/ui/tree/RendererView.tsx @@ -84,9 +84,9 @@ export class ChannelTreeView extends ReactComponentBase { if (entries.length !== 1) { if (entries.length === 0) { - console.warn(tr("Channel resize observer fired resize event with no entries!")); + logWarn(LogCategory.GENERAL, tr("Channel resize observer fired resize event with no entries!")); } else { - console.warn(tr("Channel resize observer fired resize event with more than one entry which should not be possible (%d)!"), entries.length); + logWarn(LogCategory.GENERAL, tr("Channel resize observer fired resize event with more than one entry which should not be possible (%d)!"), entries.length); } return; } diff --git a/shared/js/ui/tree/popout/Controller.ts b/shared/js/ui/tree/popout/Controller.ts index c802ae2d..782f74eb 100644 --- a/shared/js/ui/tree/popout/Controller.ts +++ b/shared/js/ui/tree/popout/Controller.ts @@ -3,14 +3,12 @@ import {ChannelTreeUIEvents} from "tc-shared/ui/tree/Definitions"; import {spawnExternalModal} from "tc-shared/ui/react-elements/external-modal"; import {initializeChannelTreeController} from "tc-shared/ui/tree/Controller"; import {ControlBarEvents} from "tc-shared/ui/frames/control-bar/Definitions"; -import { - initializePopoutControlBarController -} from "tc-shared/ui/frames/control-bar/Controller"; +import {initializePopoutControlBarController} from "tc-shared/ui/frames/control-bar/Controller"; import {ChannelTree} from "tc-shared/tree/ChannelTree"; import {ModalController} from "tc-shared/ui/react-elements/ModalDefinitions"; import {ChannelTreePopoutEvents} from "tc-shared/ui/tree/popout/Definitions"; import {ConnectionState} from "tc-shared/ConnectionHandler"; -import { tr, tra } from "tc-shared/i18n/localize"; +import {tr, tra} from "tc-shared/i18n/localize"; export class ChannelTreePopoutController { readonly channelTree: ChannelTree; diff --git a/shared/js/ui/tree/popout/RendererModal.tsx b/shared/js/ui/tree/popout/RendererModal.tsx index a5aa6ecd..6593887d 100644 --- a/shared/js/ui/tree/popout/RendererModal.tsx +++ b/shared/js/ui/tree/popout/RendererModal.tsx @@ -2,11 +2,11 @@ import {AbstractModal} from "tc-shared/ui/react-elements/ModalDefinitions"; import {Registry, RegistryMap} from "tc-shared/events"; import {ChannelTreeUIEvents} from "tc-shared/ui/tree/Definitions"; import * as React from "react"; +import {useState} from "react"; import {ChannelTreeRenderer} from "tc-shared/ui/tree/Renderer"; import {ControlBarEvents} from "tc-shared/ui/frames/control-bar/Definitions"; import {ControlBar2} from "tc-shared/ui/frames/control-bar/Renderer"; import {ChannelTreePopoutEvents} from "tc-shared/ui/tree/popout/Definitions"; -import {useState} from "react"; const TitleRenderer = (props: { events: Registry }) => { const [ title, setTitle ] = useState(() => { diff --git a/shared/js/utils/helpers.ts b/shared/js/utils/helpers.ts index 808fde34..fd68a431 100644 --- a/shared/js/utils/helpers.ts +++ b/shared/js/utils/helpers.ts @@ -1,5 +1,6 @@ import * as sha1 from "../crypto/sha"; -import { tr } from "tc-shared/i18n/localize"; +import {LogCategory, logDebug} from "tc-shared/log"; +import {tr} from "tc-shared/i18n/localize"; export function hashPassword(password: string) : Promise { return new Promise((resolve, reject) => { @@ -10,7 +11,7 @@ export function hashPassword(password: string) : Promise { } export const copyToClipboard = str => { - console.log(tr("Copy text to clipboard: %s"), str); + logDebug(LogCategory.GENERAL, tr("Copy text to clipboard: %s"), str); const element = document.createElement('textarea'); element.value = str; diff --git a/shared/js/video-viewer/Controller.ts b/shared/js/video-viewer/Controller.ts index b723750a..dd60aeb4 100644 --- a/shared/js/video-viewer/Controller.ts +++ b/shared/js/video-viewer/Controller.ts @@ -1,5 +1,5 @@ import * as log from "../log"; -import {LogCategory, logError} from "../log"; +import {LogCategory, logError, logWarn} from "../log"; import {spawnExternalModal} from "../ui/react-elements/external-modal"; import {EventHandler, Registry} from "../events"; import {VideoViewerEvents} from "./Definitions"; @@ -213,7 +213,7 @@ class VideoViewer { } } - log.warn(LogCategory.GENERAL, tr("Video viewer queried the watcher status of an unknown client: %s (%o)"), event.watcherId, info); + logWarn(LogCategory.GENERAL, tr("Video viewer queried the watcher status of an unknown client: %s (%o)"), event.watcherId, info); } @EventHandler("query_watcher_info") @@ -245,7 +245,7 @@ class VideoViewer { } } - log.warn(LogCategory.GENERAL, tr("Video viewer queried the watcher info of an unknown client: %s (%o)"), event.watcherId, info); + logWarn(LogCategory.GENERAL, tr("Video viewer queried the watcher info of an unknown client: %s (%o)"), event.watcherId, info); } @EventHandler("query_followers") @@ -262,7 +262,7 @@ class VideoViewer { return; } - log.warn(LogCategory.GENERAL, tr("Video viewer queried the watcher followers of an unknown client: %s (%o)"), event.watcherId, info); + logWarn(LogCategory.GENERAL, tr("Video viewer queried the watcher followers of an unknown client: %s (%o)"), event.watcherId, info); } @EventHandler("query_video") @@ -291,7 +291,7 @@ class VideoViewer { return; } - log.warn(LogCategory.GENERAL, tr("Video viewer tried to follow an unknown client: %s (%o)"), event.watcherId, info); + logWarn(LogCategory.GENERAL, tr("Video viewer tried to follow an unknown client: %s (%o)"), event.watcherId, info); } else { this.plugin.setLocalWatcherStatus(this.currentVideoUrl, { status: "paused" }); } diff --git a/shared/js/video-viewer/Renderer.tsx b/shared/js/video-viewer/Renderer.tsx index d54e3fd4..bd7c4752 100644 --- a/shared/js/video-viewer/Renderer.tsx +++ b/shared/js/video-viewer/Renderer.tsx @@ -1,5 +1,4 @@ -import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logDebug, logTrace} from "tc-shared/log"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import * as React from "react"; import {useEffect, useRef, useState} from "react"; @@ -199,7 +198,6 @@ const FollowerList = React.memo((props: { events: Registry, w if(followers.indexOf(event.followerId) !== -1) return; - console.error("Added follower"); followers.push(event.followerId); setFollowerRevision(followerRevision + 1); }); @@ -212,7 +210,6 @@ const FollowerList = React.memo((props: { events: Registry, w if(index === -1) return; - console.error("Removed follower"); followers.splice(index, 1); setFollowerRevision(followerRevision + 1); }); @@ -321,7 +318,7 @@ const PlayerController = React.memo((props: { events: Registry 7; - log.trace(LogCategory.GENERAL, tr("Follower sync. Remote timestamp %d, Local timestamp: %d. Difference: %d, Do seek: %o"), + logTrace(LogCategory.GENERAL, tr("Follower sync. Remote timestamp %d, Local timestamp: %d. Difference: %d, Do seek: %o"), player.current.getCurrentTime(), event.status.timestampPlay, distance, @@ -353,9 +350,9 @@ const PlayerController = React.memo((props: { events: Registry console.log("onError(%o, %o, %o, %o)", error, data, hlsInstance, hlsGlobal)} + onError={(error, data, hlsInstance, hlsGlobal) => logTrace(LogCategory.GENERAL, "onError(%o, %o, %o, %o)", error, data, hlsInstance, hlsGlobal)} onBuffer={() => { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onBuffer()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onBuffer()")); playerState.current = "buffering"; props.events.fire("notify_local_status", { status: { status: "buffering" } }); }} @@ -363,18 +360,18 @@ const PlayerController = React.memo((props: { events: Registry { if(playerState.current === "buffering") playerState.current = "playing"; - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onBufferEnd()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onBufferEnd()")); }} onDisablePIP={() => { /* console.log("onDisabledPIP()") */ }} onEnablePIP={() => { /* console.log("onEnablePIP()") */ }} onDuration={duration => { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onDuration(%d)"), duration); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onDuration(%d)"), duration); }} onEnded={() => { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onEnded()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onEnded()")); playerState.current = "stopped"; props.events.fire("notify_local_status", { status: { status: "stopped" } }); @@ -383,7 +380,7 @@ const PlayerController = React.memo((props: { events: Registry { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onPause()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onPause()")); if(videoEnded.current) { videoEnded.current = false; @@ -395,7 +392,7 @@ const PlayerController = React.memo((props: { events: Registry { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onPlay()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onPlay()")); if(videoEnded.current) { /* it's just the seek to the beginning */ @@ -412,7 +409,7 @@ const PlayerController = React.memo((props: { events: Registry 5; - log.debug(LogCategory.GENERAL, tr("Player started, at second %d. Watcher is at %s. So sync: %o"), currentSeconds, expectedSeconds, doSync); + logDebug(LogCategory.GENERAL, tr("Player started, at second %d. Watcher is at %s. So sync: %o"), currentSeconds, expectedSeconds, doSync); doSync && player.current.seekTo(expectedSeconds, "seconds"); } @@ -421,7 +418,7 @@ const PlayerController = React.memo((props: { events: Registry { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onProgress %d seconds played, %d seconds buffered. Player state: %s"), state.playedSeconds, state.loadedSeconds, playerState.current); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onProgress %d seconds played, %d seconds buffered. Player state: %s"), state.playedSeconds, state.loadedSeconds, playerState.current); currentTime.current = { buffer: state.loadedSeconds, play: state.playedSeconds }; if(playerState.current !== "playing") @@ -437,15 +434,15 @@ const PlayerController = React.memo((props: { events: Registry { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onReady()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onReady()")); }} onSeek={seconds => { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onSeek(%d)"), seconds); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onSeek(%d)"), seconds); }} onStart={() => { - kLogPlayerEvents && log.trace(LogCategory.GENERAL, tr("ReactPlayer::onStart()")); + kLogPlayerEvents && logTrace(LogCategory.GENERAL, tr("ReactPlayer::onStart()")); }} controls={true} diff --git a/shared/js/voice/RecorderProfile.ts b/shared/js/voice/RecorderProfile.ts index b485eebf..d0d2f2b4 100644 --- a/shared/js/voice/RecorderProfile.ts +++ b/shared/js/voice/RecorderProfile.ts @@ -1,5 +1,5 @@ import * as log from "../log"; -import {LogCategory, logError, logWarn} from "../log"; +import {LogCategory, logDebug, logError, logWarn} from "../log"; import {AbstractInput, FilterMode} from "../voice/RecorderBase"; import {KeyDescriptor, KeyHook} from "../PPTListener"; import {Settings, settings} from "../settings"; @@ -141,13 +141,13 @@ export class RecorderProfile { this.input = getRecorderBackend().createInput(); this.input.events.on("notify_voice_start", () => { - log.debug(LogCategory.VOICE, "Voice start"); + logDebug(LogCategory.VOICE, "Voice start"); if(this.callback_start) this.callback_start(); }); this.input.events.on("notify_voice_end", () => { - log.debug(LogCategory.VOICE, "Voice end"); + logDebug(LogCategory.VOICE, "Voice end"); if(this.callback_stop) this.callback_stop(); }); @@ -249,7 +249,7 @@ export class RecorderProfile { try { await this.input.setConsumer(undefined); } catch(error) { - log.warn(LogCategory.VOICE, tr("Failed to unmount input consumer for profile (%o)"), error); + logWarn(LogCategory.VOICE, tr("Failed to unmount input consumer for profile (%o)"), error); } /* this.input.setFilterMode(FilterMode.Block); */ diff --git a/web/app/FileTransfer.ts b/web/app/FileTransfer.ts index a2a55031..988779cb 100644 --- a/web/app/FileTransfer.ts +++ b/web/app/FileTransfer.ts @@ -13,7 +13,7 @@ import { TransferTargetType } from "tc-shared/file/Transfer"; import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logError} from "tc-shared/log"; import { tr } from "tc-shared/i18n/localize"; TransferProvider.setProvider(new class extends TransferProvider { @@ -40,7 +40,7 @@ TransferProvider.setProvider(new class extends TransferProvider { /* let the server notify us when the transfer has been finished */ response.catch(error => { if(typeof error !== "string") - log.error(LogCategory.FILE_TRANSFER, tr("Failed to upload object via HTTPS connection: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to upload object via HTTPS connection: %o"), error); transfer.setFailed({ error: "connection", @@ -50,7 +50,7 @@ TransferProvider.setProvider(new class extends TransferProvider { }); } catch (error) { if(typeof error !== "string") - log.error(LogCategory.FILE_TRANSFER, tr("Failed to initialize transfer source: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to initialize transfer source: %o"), error); transfer.setFailed({ error: "io", @@ -85,7 +85,7 @@ TransferProvider.setProvider(new class extends TransferProvider { } }).catch(error => { if(typeof error !== "string") - log.error(LogCategory.FILE_TRANSFER, tr("Failed to download file to response object: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to download file to response object: %o"), error); transfer.setFailed({ error: "connection", @@ -95,7 +95,7 @@ TransferProvider.setProvider(new class extends TransferProvider { }); } catch (error) { if(typeof error !== "string") - log.error(LogCategory.FILE_TRANSFER, tr("Failed to initialize transfer target: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to initialize transfer target: %o"), error); transfer.setFailed({ error: "io", @@ -190,7 +190,7 @@ async function performHTTPSTransfer(transfer: FileTransfer, body: FormData | und transfer.setTransferState(FileTransferState.FINISHED); }).catch(error => { if(typeof error !== "string") - log.error(LogCategory.FILE_TRANSFER, tr("Failed to transfer data throw a HTTPS request: %o"), error); + logError(LogCategory.FILE_TRANSFER, tr("Failed to transfer data throw a HTTPS request: %o"), error); transfer.setFailed({ error: "io", reason: "buffer-transfer-failed", diff --git a/web/app/UnloadHandler.ts b/web/app/UnloadHandler.ts index 57d2d973..8fe2a95a 100644 --- a/web/app/UnloadHandler.ts +++ b/web/app/UnloadHandler.ts @@ -6,7 +6,7 @@ window.addEventListener("beforeunload", event => { return; } - const active_connections = server_connections.all_connections().filter(e => e.connected); + const active_connections = server_connections.getAllConnectionHandlers().filter(e => e.connected); if(active_connections.length == 0) return; event.returnValue = "Are you really sure?
You're still connected!"; diff --git a/web/app/audio/Recorder.ts b/web/app/audio/Recorder.ts index cb5dcca4..b5de313d 100644 --- a/web/app/audio/Recorder.ts +++ b/web/app/audio/Recorder.ts @@ -12,7 +12,7 @@ import { NodeInputConsumer } from "tc-shared/voice/RecorderBase"; import * as log from "tc-shared/log"; -import {LogCategory, logDebug} from "tc-shared/log"; +import {LogCategory, logDebug, logWarn} from "tc-shared/log"; import * as aplayer from "./player"; import {JAbstractFilter, JStateFilter, JThresholdFilter} from "./RecorderFilter"; import {Filter, FilterType, FilterTypeClass} from "tc-shared/voice/Filter"; @@ -157,7 +157,7 @@ class JavascriptInput implements AbstractInput { } if(this.consumer.callbackBuffer) { - log.warn(LogCategory.AUDIO, tr("AudioInput has callback buffer, but this isn't supported yet!")); + logWarn(LogCategory.AUDIO, tr("AudioInput has callback buffer, but this isn't supported yet!")); } } @@ -198,7 +198,6 @@ class JavascriptInput implements AbstractInput { deviceId = this.deviceId; } - console.error("Starting input recorder on %o - %o", this.deviceId, deviceId); const requestResult = await requestMediaStream(deviceId, undefined, "audio"); if(!(requestResult instanceof MediaStream)) { this.setState(InputState.PAUSED); @@ -289,7 +288,7 @@ class JavascriptInput implements AbstractInput { try { await this.stop(); } catch(error) { - log.warn(LogCategory.AUDIO, tr("Failed to stop previous record session (%o)"), error); + logWarn(LogCategory.AUDIO, tr("Failed to stop previous record session (%o)"), error); } const oldDeviceId = deviceId; diff --git a/web/app/audio/RecorderDeviceList.ts b/web/app/audio/RecorderDeviceList.ts index db2a6baf..13a9b2fc 100644 --- a/web/app/audio/RecorderDeviceList.ts +++ b/web/app/audio/RecorderDeviceList.ts @@ -6,7 +6,7 @@ import { PermissionState } from "tc-shared/audio/recorder"; import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logDebug, logError} from "tc-shared/log"; import {Registry} from "tc-shared/events"; import {WebIDevice} from "tc-backend/web/audio/Recorder"; import * as loader from "tc-loader"; @@ -21,7 +21,7 @@ async function requestMicrophonePermissions() : Promise { } catch (error) { const end = Date.now(); const isSystem = (end - begin) < 250; - log.debug(LogCategory.AUDIO, tr("Microphone device request took %d milliseconds. System answered: %s"), end - begin, isSystem); + logDebug(LogCategory.AUDIO, tr("Microphone device request took %d milliseconds. System answered: %s"), end - begin, isSystem); return "denied"; } } @@ -88,7 +88,7 @@ class WebInputDeviceList extends AbstractDeviceList { } this.deviceListQueryPromise = this.doQueryDevices(askPermissions).catch(error => { - log.error(LogCategory.AUDIO, tr("Failed to query microphone devices (%o)"), error); + logError(LogCategory.AUDIO, tr("Failed to query microphone devices (%o)"), error); if(this.listState !== "healthy") { this.setState("error"); diff --git a/web/app/audio/player.ts b/web/app/audio/player.ts index e29b2828..84d4aa91 100644 --- a/web/app/audio/player.ts +++ b/web/app/audio/player.ts @@ -1,6 +1,6 @@ import {Device} from "tc-shared/audio/player"; import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logError, logInfo} from "tc-shared/log"; import { tr } from "tc-shared/i18n/localize"; /* lets try without any gestures, maybe the user already clicked the page */ @@ -24,7 +24,7 @@ export function initialized() : boolean { } function fire_initialized() { - log.info(LogCategory.AUDIO, tr("Fire audio player initialized for %d listeners"), audioContextInitializeCallbacks.length); + logInfo(LogCategory.AUDIO, tr("Fire audio player initialized for %d listeners"), audioContextInitializeCallbacks.length); while(audioContextInitializeCallbacks.length > 0) audioContextInitializeCallbacks.pop_front()(); } @@ -112,7 +112,7 @@ export function initializeFromGesture() { if(audioContextInstance) { if(audioContextInstance.state !== "running") { audioContextInstance.resume().catch(error => { - log.error(LogCategory.AUDIO, tr("Failed to initialize audio context instance from gesture: %o"), error); + logError(LogCategory.AUDIO, tr("Failed to initialize audio context instance from gesture: %o"), error); }); } } else { diff --git a/web/app/audio/sounds.ts b/web/app/audio/sounds.ts index c59a8ea6..daf95807 100644 --- a/web/app/audio/sounds.ts +++ b/web/app/audio/sounds.ts @@ -1,4 +1,4 @@ -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logError, logWarn} from "tc-shared/log"; import * as log from "tc-shared/log"; import {SoundFile} from "tc-shared/sound/Sounds"; import * as aplayer from "./player"; @@ -57,17 +57,17 @@ function get_song_entry(file: SoundFile) : Promise { try { entry.cached = await context.decodeAudioData(xhr.response); } catch(error) { - log.error(LogCategory.AUDIO, error); + logError(LogCategory.AUDIO, error); throw tr("failed to decode audio data"); } } catch(error) { - log.error(LogCategory.AUDIO, tr("Failed to load audio file %s. Error: %o"), file, error); + logError(LogCategory.AUDIO, tr("Failed to load audio file %s. Error: %o"), file, error); throw error_already_handled; } } else { if(!warned) { warned = true; - log.warn(LogCategory.AUDIO, tr("Your browser does not support decodeAudioData! Using a node to playback! This bypasses the audio output and volume regulation!")); + logWarn(LogCategory.AUDIO, tr("Your browser does not support decodeAudioData! Using a node to playback! This bypasses the audio output and volume regulation!")); } const container = $("#sounds"); const node = $.spawn("audio").attr("src", file.path); @@ -82,7 +82,7 @@ function get_song_entry(file: SoundFile) : Promise { export async function play_sound(file: SoundFile) : Promise { const entry = get_song_entry(file); if(!entry) { - log.warn(LogCategory.AUDIO, tr("Failed to replay sound %s because it could not be resolved."), file.path); + logWarn(LogCategory.AUDIO, tr("Failed to replay sound %s because it could not be resolved."), file.path); return; } @@ -120,11 +120,11 @@ export async function play_sound(file: SoundFile) : Promise { } } catch(error) { if(error === error_already_handled) { - log.warn(LogCategory.AUDIO, tr("Failed to replay sound %s because of an error while loading (see log above)."), file.path); + logWarn(LogCategory.AUDIO, tr("Failed to replay sound %s because of an error while loading (see log above)."), file.path); return; } - log.warn(LogCategory.AUDIO, tr("Failed to replay sound %s: %o"), file.path, error); + logWarn(LogCategory.AUDIO, tr("Failed to replay sound %s: %o"), file.path, error); return; } } \ No newline at end of file diff --git a/web/app/connection/ServerConnection.ts b/web/app/connection/ServerConnection.ts index 79277cc7..696b6b42 100644 --- a/web/app/connection/ServerConnection.ts +++ b/web/app/connection/ServerConnection.ts @@ -10,7 +10,7 @@ import {ConnectionCommandHandler, ServerConnectionCommandBoss} from "tc-shared/c import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration"; import {settings, Settings} from "tc-shared/settings"; import * as log from "tc-shared/log"; -import {LogCategory, logDebug, logError, logTrace} from "tc-shared/log"; +import {LogCategory, logDebug, logError, logInfo, logTrace, logWarn} from "tc-shared/log"; import {Regex} from "tc-shared/ui/modal/ModalConnect"; import {AbstractCommandHandlerBoss} from "tc-shared/connection/AbstractCommandHandler"; import {WrappedWebSocket} from "tc-backend/web/connection/WrappedWebSocket"; @@ -89,7 +89,7 @@ export class ServerConnection extends AbstractServerConnection { destroy() { this.disconnect("handle destroyed").catch(error => { - log.warn(LogCategory.NETWORKING, tr("Failed to disconnect on server connection destroy: %o"), error); + logWarn(LogCategory.NETWORKING, tr("Failed to disconnect on server connection destroy: %o"), error); }).then(() => { clearInterval(this.pingStatistics.thread_id); if(this.connectCancelCallback) { @@ -100,7 +100,7 @@ export class ServerConnection extends AbstractServerConnection { try { listener.reject("handler destroyed"); } catch(error) { - log.warn(LogCategory.NETWORKING, tr("Failed to reject command promise: %o"), error); + logWarn(LogCategory.NETWORKING, tr("Failed to reject command promise: %o"), error); } clearTimeout(listener.timeout); } @@ -134,7 +134,7 @@ export class ServerConnection extends AbstractServerConnection { try { await this.disconnect(); } catch(error) { - log.error(LogCategory.NETWORKING, tr("Failed to close old connection properly. Error: %o"), error); + logError(LogCategory.NETWORKING, tr("Failed to close old connection properly. Error: %o"), error); throw "failed to cleanup old connection"; } @@ -190,13 +190,13 @@ export class ServerConnection extends AbstractServerConnection { await Promise.race([...availableSockets.map(e => e.awaitConnectResult()), timeoutPromise, cancelPromise]); if(cancelRaised) { - log.debug(LogCategory.NETWORKING, tr("Aborting connect attempt due to a cancel request.")); + logDebug(LogCategory.NETWORKING, tr("Aborting connect attempt due to a cancel request.")); availableSockets.forEach(e => e.closeConnection()); return } if(timeoutRaised) { - log.info(LogCategory.NETWORKING, tr("Connect timeout triggered. Aborting connect attempt!")); + logInfo(LogCategory.NETWORKING, tr("Connect timeout triggered. Aborting connect attempt!")); availableSockets.forEach(e => e.closeConnection()); this.updateConnectionState(ConnectionState.UNCONNECTED); /* firstly update the state, that fire event */ this.client.handleDisconnect(DisconnectReason.CONNECT_FAILURE); @@ -209,12 +209,12 @@ export class ServerConnection extends AbstractServerConnection { switch (finished.state) { case "unconnected": - log.debug(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s got aborted."), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.socketUrl()); + logDebug(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s got aborted."), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.socketUrl()); continue; case "errored": const error = finished.popError(); - log.info(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s failed:\n%o"), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.socketUrl(), error); + logInfo(LogCategory.NETWORKING, tr("Connection attempt to %s:%d via %s failed:\n%o"), this.remoteServerAddress.host, this.remoteServerAddress.port, finished.socketUrl(), error); continue; case "connected": @@ -229,7 +229,7 @@ export class ServerConnection extends AbstractServerConnection { } if(!this.socket) { - log.info(LogCategory.NETWORKING, tr("Failed to connect to %s:%d. No connection attempt succeeded."), this.remoteServerAddress.host, this.remoteServerAddress.port); + logInfo(LogCategory.NETWORKING, tr("Failed to connect to %s:%d. No connection attempt succeeded."), this.remoteServerAddress.host, this.remoteServerAddress.port); this.updateConnectionState(ConnectionState.UNCONNECTED); /* firstly update the state, that fire event */ this.client.handleDisconnect(DisconnectReason.CONNECT_FAILURE); return; @@ -240,7 +240,7 @@ export class ServerConnection extends AbstractServerConnection { try { this.disconnect(); } catch (error) { - log.warn(LogCategory.NETWORKING, tr("Failed to disconnect with an already closed socket: %o"), error); + logWarn(LogCategory.NETWORKING, tr("Failed to disconnect with an already closed socket: %o"), error); } this.client.handleDisconnect(DisconnectReason.CONNECTION_CLOSED, { @@ -250,25 +250,25 @@ export class ServerConnection extends AbstractServerConnection { }; this.socket.callbackErrored = () => { if(this.socket.hasError()) { - log.error(LogCategory.NETWORKING, tr("Server connection %s:%d has been terminated due to an unexpected error (%o)."), + logError(LogCategory.NETWORKING, tr("Server connection %s:%d has been terminated due to an unexpected error (%o)."), this.remoteServerAddress.host, this.remoteServerAddress.port, this.socket.popError() ); } else { - log.error(LogCategory.NETWORKING, tr("Server connection %s:%d has been terminated due to an unexpected error."), this.remoteServerAddress.host, this.remoteServerAddress.port); + logError(LogCategory.NETWORKING, tr("Server connection %s:%d has been terminated due to an unexpected error."), this.remoteServerAddress.host, this.remoteServerAddress.port); } try { this.disconnect(); } catch (error) { - log.warn(LogCategory.NETWORKING, tr("Failed to disconnect with an already closed socket: %o"), error); + logWarn(LogCategory.NETWORKING, tr("Failed to disconnect with an already closed socket: %o"), error); } this.client.handleDisconnect(DisconnectReason.CONNECTION_CLOSED); }; const connectEndTimestamp = Date.now(); - log.info(LogCategory.NETWORKING, tr("Successfully initialized a connection to %s:%d via %s within %d milliseconds."), + logInfo(LogCategory.NETWORKING, tr("Successfully initialized a connection to %s:%d via %s within %d milliseconds."), this.remoteServerAddress.host, this.remoteServerAddress.port, this.socket.socketUrl(), @@ -327,11 +327,11 @@ export class ServerConnection extends AbstractServerConnection { try { json = JSON.parse(data); } catch(e) { - log.warn(LogCategory.NETWORKING, tr("Could not parse message json!")); + logWarn(LogCategory.NETWORKING, tr("Could not parse message json!")); return; } if(json["type"] === undefined) { - log.warn(LogCategory.NETWORKING, tr("Missing data type in message!")); + logWarn(LogCategory.NETWORKING, tr("Missing data type in message!")); return; } if(json["type"] === "command") { @@ -371,27 +371,27 @@ export class ServerConnection extends AbstractServerConnection { } else if(json["type"] === "pong") { const id = parseInt(json["payload"]); if(id != this.pingStatistics.currentRequestId) { - log.warn(LogCategory.NETWORKING, tr("Received pong which is older than the last request. Delay may over %oms? (Index: %o, Current index: %o)"), this.pingStatistics.timeout, id, this.pingStatistics.currentRequestId); + logWarn(LogCategory.NETWORKING, tr("Received pong which is older than the last request. Delay may over %oms? (Index: %o, Current index: %o)"), this.pingStatistics.timeout, id, this.pingStatistics.currentRequestId); } else { this.pingStatistics.lastResponseTimestamp = 'now' in performance ? performance.now() : Date.now(); this.pingStatistics.currentJsValue = this.pingStatistics.lastResponseTimestamp - this.pingStatistics.lastRequestTimestamp; this.pingStatistics.currentNativeValue = parseInt(json["ping_native"]) / 1000; /* we're getting it in microseconds and not milliseconds */ this.events.fire("notify_ping_updated", { newPing: this.ping() }); - //log.debug(LogCategory.NETWORKING, tr("Received new pong. Updating ping to: JS: %o Native: %o"), this._ping.value.toFixed(3), this._ping.value_native.toFixed(3)); + //logDebug(LogCategory.NETWORKING, tr("Received new pong. Updating ping to: JS: %o Native: %o"), this._ping.value.toFixed(3), this._ping.value_native.toFixed(3)); } } else if(json["type"] === "WebRTC") { this.oldVoiceConnection?.handleControlPacket(json); } else { - log.warn(LogCategory.NETWORKING, tr("Unknown command type %o"), json["type"]); + logWarn(LogCategory.NETWORKING, tr("Unknown command type %o"), json["type"]); } } else { - log.warn(LogCategory.NETWORKING, tr("Received unknown message of type %s. Dropping message"), typeof(data)); + logWarn(LogCategory.NETWORKING, tr("Received unknown message of type %s. Dropping message"), typeof(data)); } } sendData(data: any) { if(!this.socket || this.socket.state !== "connected") { - log.warn(LogCategory.NETWORKING, tr("Tried to send data via a non connected server socket.")); + logWarn(LogCategory.NETWORKING, tr("Tried to send data via a non connected server socket.")); return; } @@ -443,7 +443,7 @@ export class ServerConnection extends AbstractServerConnection { send_command(command: string, data?: any | any[], _options?: CommandOptions) : Promise { if(!this.socket || !this.connected()) { - log.warn(LogCategory.NETWORKING, tr("Tried to send a command without a valid connection.")); + logWarn(LogCategory.NETWORKING, tr("Tried to send a command without a valid connection.")); return Promise.reject(tr("not connected")); } diff --git a/web/app/connection/WrappedWebSocket.ts b/web/app/connection/WrappedWebSocket.ts index 4eb70bf4..34c3eba8 100644 --- a/web/app/connection/WrappedWebSocket.ts +++ b/web/app/connection/WrappedWebSocket.ts @@ -1,5 +1,5 @@ import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logWarn} from "tc-shared/log"; import {ConnectionStatistics} from "tc-shared/connection/ConnectionBase"; import { tr } from "tc-shared/i18n/localize"; @@ -149,7 +149,7 @@ export class WrappedWebSocket { } } } catch (error) { - log.warn(LogCategory.NETWORKING, tr("Failed to close the web socket to %s: %o"), this.socketUrl(), error); + logWarn(LogCategory.NETWORKING, tr("Failed to close the web socket to %s: %o"), this.socketUrl(), error); } this.socket = undefined; diff --git a/web/app/dns/api.ts b/web/app/dns/api.ts index d822a017..121171a8 100644 --- a/web/app/dns/api.ts +++ b/web/app/dns/api.ts @@ -1,6 +1,6 @@ import {tr} from "tc-shared/i18n/localize"; import * as log from "tc-shared/log"; -import {LogCategory, logTrace} from "tc-shared/log"; +import {LogCategory, logError, logTrace} from "tc-shared/log"; export enum RRType { A = 1, // a host address,[RFC1035], @@ -162,7 +162,7 @@ export async function executeDnsRequest(address: string, type: RRType) : Promise response_string = await response.text(); responseData = JSON.parse(response_string); } catch(ex) { - log.error(LogCategory.DNS, tr("Failed to parse response data: %o. Data: %s"), ex, response_string); + logError(LogCategory.DNS, tr("Failed to parse response data: %o. Data: %s"), ex, response_string); throw "failed to parse response"; } diff --git a/web/app/dns/resolver.ts b/web/app/dns/resolver.ts index 18bcc40e..ee0fe0df 100644 --- a/web/app/dns/resolver.ts +++ b/web/app/dns/resolver.ts @@ -1,5 +1,5 @@ import * as log from "tc-shared/log"; -import {LogCategory, logTrace} from "tc-shared/log"; +import {LogCategory, logTrace, logWarn} from "tc-shared/log"; import {tr} from "tc-shared/i18n/localize"; import {ServerAddress} from "tc-shared/tree/Server"; import {AddressTarget, default_options, ResolveOptions} from "tc-shared/dns"; @@ -80,7 +80,7 @@ class SRVResolveMethod implements DNSResolveMethod { for(const record of answer) { const parts = record.data.split(" "); if(parts.length !== 4) { - log.warn(LogCategory.DNS, tr("Failed to parse SRV record %s. Invalid split length."), record); + logWarn(LogCategory.DNS, tr("Failed to parse SRV record %s. Invalid split length."), record); continue; } @@ -89,7 +89,7 @@ class SRVResolveMethod implements DNSResolveMethod { const port = parseInt(parts[2]); if((priority < 0 || priority > 65535) || (weight < 0 || weight > 65535) || (port < 0 || port > 65535)) { - log.warn(LogCategory.DNS, tr("Failed to parse SRV record %s. Malformed data."), record); + logWarn(LogCategory.DNS, tr("Failed to parse SRV record %s. Malformed data."), record); continue; } @@ -276,7 +276,7 @@ class TeaSpeakDNSResolve { if(this.finished_resolvers.findIndex(e => e === after) === -1) continue _main_loop; invoke_count++; - log.trace(LogCategory.DNS, tr(" Executing resolver %s"), resolver_name); + logTrace(LogCategory.DNS, tr(" Executing resolver %s"), resolver_name); this.resolving_resolvers.push(resolver_name); resolver.resolver.resolve(this.address).then(result => { @@ -284,12 +284,12 @@ class TeaSpeakDNSResolve { this.finished_resolvers.push(resolver_name); if(!result) { - log.trace(LogCategory.DNS, tr(" Resolver %s returned an empty response."), resolver_name); + logTrace(LogCategory.DNS, tr(" Resolver %s returned an empty response."), resolver_name); this.invoke_resolvers(); return; } - log.trace(LogCategory.DNS, tr(" Successfully resolved address %s:%d to %s:%d via resolver %s"), + logTrace(LogCategory.DNS, tr(" Successfully resolved address %s:%d to %s:%d via resolver %s"), this.address.host, this.address.port, result.host, result.port, resolver_name); @@ -298,7 +298,7 @@ class TeaSpeakDNSResolve { if(!this.resolving || !this.callback_success) return; /* resolve has been finished already */ this.finished_resolvers.push(resolver_name); - log.trace(LogCategory.DNS, tr(" Resolver %s ran into an error: %o"), resolver_name, error); + logTrace(LogCategory.DNS, tr(" Resolver %s ran into an error: %o"), resolver_name, error); this.invoke_resolvers(); }).then(() => { this.resolving_resolvers.remove(resolver_name); diff --git a/web/app/legacy/voice/VoiceHandler.ts b/web/app/legacy/voice/VoiceHandler.ts index 556e84df..d799ecb2 100644 --- a/web/app/legacy/voice/VoiceHandler.ts +++ b/web/app/legacy/voice/VoiceHandler.ts @@ -90,7 +90,7 @@ export class VoiceConnection extends AbstractVoiceConnection { this.connection.events.off(this.serverConnectionStateListener); this.dropVoiceBridge(); this.acquireVoiceRecorder(undefined, true).catch(error => { - log.warn(LogCategory.VOICE, tr("Failed to release voice recorder: %o"), error); + logWarn(LogCategory.VOICE, tr("Failed to release voice recorder: %o"), error); }).then(() => { for(const client of Object.keys(this.voiceClients).map(clientId => this.voiceClients[clientId])) { client.abortReplay(); @@ -270,7 +270,7 @@ export class VoiceConnection extends AbstractVoiceConnection { let client = this.findVoiceClient(packet.clientId); if(!client) { - log.error(LogCategory.VOICE, tr("Having voice from unknown audio client? (ClientID: %o)"), packet.clientId); + logError(LogCategory.VOICE, tr("Having voice from unknown audio client? (ClientID: %o)"), packet.clientId); return; } @@ -288,7 +288,7 @@ export class VoiceConnection extends AbstractVoiceConnection { if(chandler.isMicrophoneMuted()) return false; - log.info(LogCategory.VOICE, tr("Local voice ended")); + logInfo(LogCategory.VOICE, tr("Local voice ended")); this.localAudioStarted = false; this.voiceBridge?.sendStopSignal(this.encoderCodec); @@ -297,19 +297,19 @@ export class VoiceConnection extends AbstractVoiceConnection { private handleRecorderStart() { const chandler = this.connection.client; if(chandler.isMicrophoneMuted()) { - log.warn(LogCategory.VOICE, tr("Received local voice started event, even thou we're muted!")); + logWarn(LogCategory.VOICE, tr("Received local voice started event, even thou we're muted!")); return; } this.localAudioStarted = true; - log.info(LogCategory.VOICE, tr("Local voice started")); + logInfo(LogCategory.VOICE, tr("Local voice started")); const ch = chandler.getClient(); if(ch) ch.speaking = true; } private handleRecorderUnmount() { - log.info(LogCategory.VOICE, "Lost recorder!"); + logInfo(LogCategory.VOICE, "Lost recorder!"); this.currentAudioSource = undefined; this.acquireVoiceRecorder(undefined, true); /* we can ignore the promise because we should finish this directly */ } diff --git a/web/app/legacy/voice/bridge/NativeWebRTCVoiceBridge.ts b/web/app/legacy/voice/bridge/NativeWebRTCVoiceBridge.ts index 167ec79b..f5f31373 100644 --- a/web/app/legacy/voice/bridge/NativeWebRTCVoiceBridge.ts +++ b/web/app/legacy/voice/bridge/NativeWebRTCVoiceBridge.ts @@ -1,7 +1,7 @@ import {AbstractInput, InputConsumerType, NodeInputConsumer} from "tc-shared/voice/RecorderBase"; import * as aplayer from "tc-backend/web/audio/player"; import * as log from "tc-shared/log"; -import {LogCategory} from "tc-shared/log"; +import {LogCategory, logDebug, logWarn} from "tc-shared/log"; import {tr} from "tc-shared/i18n/localize"; import {WebRTCVoiceBridge} from "./WebRTCVoiceBridge"; import {VoiceWhisperPacket} from "./VoiceBridge"; @@ -122,9 +122,9 @@ export class NativeWebRTCVoiceBridge extends WebRTCVoiceBridge { node.disconnect(this.whispering ? this.localWhisperDestinationNode : this.localVoiceDestinationNode); } } as NodeInputConsumer); - log.debug(LogCategory.VOICE, tr("Successfully set/updated to the new input for the recorder")); + logDebug(LogCategory.VOICE, tr("Successfully set/updated to the new input for the recorder")); } catch (e) { - log.warn(LogCategory.VOICE, tr("Failed to set consumer to the new recorder input: %o"), e); + logWarn(LogCategory.VOICE, tr("Failed to set consumer to the new recorder input: %o"), e); } } } diff --git a/web/app/legacy/voice/bridge/WebRTCVoiceBridge.ts b/web/app/legacy/voice/bridge/WebRTCVoiceBridge.ts index 33ef6083..0998562a 100644 --- a/web/app/legacy/voice/bridge/WebRTCVoiceBridge.ts +++ b/web/app/legacy/voice/bridge/WebRTCVoiceBridge.ts @@ -297,7 +297,7 @@ export abstract class WebRTCVoiceBridge extends VoiceBridge { } private handleRtcConnectionStateChange() { - log.debug(LogCategory.WEBRTC, tr("Connection state changed to %s (Local connection state: %s)"), this.rtcConnection.connectionState, this.connectionState); + logDebug(LogCategory.WEBRTC, tr("Connection state changed to %s (Local connection state: %s)"), this.rtcConnection.connectionState, this.connectionState); switch (this.rtcConnection.connectionState) { case "connected": if(this.callbackRtcConnected) @@ -320,11 +320,11 @@ export abstract class WebRTCVoiceBridge extends VoiceBridge { } private handleIceGatheringStateChange() { - log.trace(LogCategory.WEBRTC, tr("ICE gathering state changed to %s"), this.rtcConnection.iceGatheringState); + logTrace(LogCategory.WEBRTC, tr("ICE gathering state changed to %s"), this.rtcConnection.iceGatheringState); } private handleIceConnectionStateChange() { - log.trace(LogCategory.WEBRTC, tr("ICE connection state changed to %s"), this.rtcConnection.iceConnectionState); + logTrace(LogCategory.WEBRTC, tr("ICE connection state changed to %s"), this.rtcConnection.iceConnectionState); } private handleIceCandidate(event: RTCPeerConnectionIceEvent) { @@ -334,7 +334,7 @@ export abstract class WebRTCVoiceBridge extends VoiceBridge { if(event.candidate) { this.localIceCandidateCount++; - log.debug(LogCategory.WEBRTC, tr("Gathered local ice candidate for stream %d: %s"), event.candidate.sdpMLineIndex, event.candidate.candidate); + logDebug(LogCategory.WEBRTC, tr("Gathered local ice candidate for stream %d: %s"), event.candidate.sdpMLineIndex, event.candidate.candidate); this.callback_send_control_data("ice", { msg: event.candidate.toJSON() }); } else if(this.localIceCandidateCount === 0) { logError(LogCategory.WEBRTC, tr("Failed to gather any local ice candidates... This is a fatal error.")); @@ -345,7 +345,7 @@ export abstract class WebRTCVoiceBridge extends VoiceBridge { this.callbackRtcConnectFailed(tr("failed to gather any local ICE candidates")); } } else { - log.debug(LogCategory.WEBRTC, tr("Local ICE candidate gathering finish.")); + logDebug(LogCategory.WEBRTC, tr("Local ICE candidate gathering finish.")); this.callback_send_control_data("ice_finish", {}); } @@ -353,10 +353,10 @@ export abstract class WebRTCVoiceBridge extends VoiceBridge { private handleIceCandidateError(event: RTCPeerConnectionIceErrorEvent) { if(this.rtcConnection.iceGatheringState === "gathering") { - log.warn(LogCategory.WEBRTC, tr("Received error while gathering the ice candidates: %d/%s for %s (url: %s)"), + logWarn(LogCategory.WEBRTC, tr("Received error while gathering the ice candidates: %d/%s for %s (url: %s)"), event.errorCode, event.errorText, event.hostCandidate, event.url); } else { - log.trace(LogCategory.WEBRTC, tr("Ice candidate %s (%s) errored: %d/%s"), + logTrace(LogCategory.WEBRTC, tr("Ice candidate %s (%s) errored: %d/%s"), event.url, event.hostCandidate, event.errorCode, event.errorText); } } diff --git a/web/app/ppt.ts b/web/app/ppt.ts index c94752f3..c4df7dd0 100644 --- a/web/app/ppt.ts +++ b/web/app/ppt.ts @@ -117,7 +117,7 @@ function listener_hook(event: KeyEvent) { new_hooks.push(hook); if(!old_hooks.remove(hook) && hook.callback_press) { hook.callback_press(); - log.trace(LogCategory.GENERAL, tr("Trigger key press for %o!"), hook); + logTrace(LogCategory.GENERAL, tr("Trigger key press for %o!"), hook); } } } @@ -128,7 +128,7 @@ function listener_hook(event: KeyEvent) { if(hook.key_code === event.key_code) { if(hook.callback_release) { hook.callback_release(); - log.trace(LogCategory.GENERAL, tr("Trigger key release for %o!"), hook); + logTrace(LogCategory.GENERAL, tr("Trigger key release for %o!"), hook); } } else { new_hooks.push(hook); diff --git a/web/app/ui/FaviconRenderer.tsx b/web/app/ui/FaviconRenderer.tsx index 699a2fee..aeed7121 100644 --- a/web/app/ui/FaviconRenderer.tsx +++ b/web/app/ui/FaviconRenderer.tsx @@ -88,7 +88,7 @@ function initializeFaviconController(events: Registry) { events.fire_later("notify_icon", { icon: icon }) }; - setCurrentHandler(server_connections.active_connection()); + setCurrentHandler(server_connections.getActiveConnectionHandler()); events.on("query_icon", () => sendFavicon()); } diff --git a/web/app/ui/context-menu/Ipc.ts b/web/app/ui/context-menu/Ipc.ts index f35a0b0a..379f5350 100644 --- a/web/app/ui/context-menu/Ipc.ts +++ b/web/app/ui/context-menu/Ipc.ts @@ -93,7 +93,6 @@ class IPCContextMenu implements ContextMenuFactory { if(!entry.uniqueId) { break; } entry.click = () => { - console.error("Click: %O", this.remoteContextMenuSupplierId); this.remoteContextMenuSupplierId && this.ipcChannel.sendMessage("notify-entry-click", { id: entry.uniqueId }, this.remoteContextMenuSupplierId); }; break; @@ -137,7 +136,6 @@ class IPCContextMenu implements ContextMenuFactory { /* close out context menu if we've any */ reactContextMenuInstance.closeContextMenu(); } else if(message.type === "notify-entry-click") { - console.error("Entry click: %o", message.data.id); const callback = this.menuCallbacks[message.data.id]; if(!callback) { return; } callback(); diff --git a/web/app/voice/Connection.ts b/web/app/voice/Connection.ts index 289b10da..f0118e20 100644 --- a/web/app/voice/Connection.ts +++ b/web/app/voice/Connection.ts @@ -14,8 +14,7 @@ import { import {RTCConnection, RTCConnectionEvents, RTPConnectionState} from "tc-shared/connection/rtc/Connection"; import {AbstractServerConnection, ConnectionStatistics} from "tc-shared/connection/ConnectionBase"; import {VoicePlayerState} from "tc-shared/voice/VoicePlayer"; -import * as log from "tc-shared/log"; -import {LogCategory, logDebug, logError, logTrace, logWarn} from "tc-shared/log"; +import {LogCategory, logDebug, logError, logInfo, logTrace, logWarn} from "tc-shared/log"; import * as aplayer from "../audio/player"; import {tr} from "tc-shared/i18n/localize"; import {RtpVoiceClient} from "tc-backend/web/voice/VoiceClient"; @@ -112,7 +111,7 @@ export class RtpVoiceConnection extends AbstractVoiceConnection { this.rtcConnection.getEvents().off("notify_state_changed", this.listenerRtcStateChanged); this.acquireVoiceRecorder(undefined, true).catch(error => { - log.warn(LogCategory.VOICE, tr("Failed to release voice recorder: %o"), error); + logWarn(LogCategory.VOICE, tr("Failed to release voice recorder: %o"), error); }).then(() => { for(const client of Object.values(this.voiceClients)) { client.abortReplay(); @@ -215,7 +214,7 @@ export class RtpVoiceConnection extends AbstractVoiceConnection { return false; } - log.info(LogCategory.VOICE, tr("Local voice ended")); + logInfo(LogCategory.VOICE, tr("Local voice ended")); this.rtcConnection.setTrackSource("audio", null).catch(error => { logError(LogCategory.AUDIO, tr("Failed to set current audio track: %o"), error); @@ -229,11 +228,11 @@ export class RtpVoiceConnection extends AbstractVoiceConnection { private handleRecorderStart() { const chandler = this.connection.client; if(chandler.isMicrophoneMuted()) { - log.warn(LogCategory.VOICE, tr("Received local voice started event, even thou we're muted!")); + logWarn(LogCategory.VOICE, tr("Received local voice started event, even thou we're muted!")); return; } - log.info(LogCategory.VOICE, tr("Local voice started")); + logInfo(LogCategory.VOICE, tr("Local voice started")); const ch = chandler.getClient(); if(ch) { ch.speaking = true; } @@ -245,7 +244,7 @@ export class RtpVoiceConnection extends AbstractVoiceConnection { } private handleRecorderUnmount() { - log.info(LogCategory.VOICE, "Lost recorder!"); + logInfo(LogCategory.VOICE, "Lost recorder!"); this.currentAudioSource = undefined; this.acquireVoiceRecorder(undefined, true); /* we can ignore the promise because we should finish this directly */ } @@ -291,7 +290,7 @@ export class RtpVoiceConnection extends AbstractVoiceConnection { throw "Invalid client type"; } - console.error("Destroy voice client %d", client.getClientId()); + logTrace(LogCategory.VOICE, tr("Destroy voice client %d"), client.getClientId()); client.events.off("notify_state_changed", this.voiceClientStateChangedEventListener); delete this.voiceClients[client.getClientId()]; client.destroy();