diff --git a/client/common/configuration/elements/channel-configuration.ts b/client/common/configuration/elements/channel-configuration.ts index 6a571f19..a5e5bb14 100644 --- a/client/common/configuration/elements/channel-configuration.ts +++ b/client/common/configuration/elements/channel-configuration.ts @@ -94,7 +94,7 @@ export class ChannelConfigurationElement extends LivechatElement { if (error instanceof ValidationError) { this.validationError = error } - console.warn(`A validation error occurred in saving configuration. ${error.name}: ${error.message}`) + this.logger.warn(`A validation error occurred in saving configuration. ${error.name}: ${error.message}`) this.ptNotifier.error( error.message ? error.message diff --git a/client/common/configuration/elements/channel-emojis.ts b/client/common/configuration/elements/channel-emojis.ts index 4cf4bfe9..afb9e566 100644 --- a/client/common/configuration/elements/channel-emojis.ts +++ b/client/common/configuration/elements/channel-emojis.ts @@ -237,7 +237,7 @@ export class ChannelEmojisElement extends LivechatElement { a.click() a.remove() } catch (err: any) { - console.error(err) + this.logger.error(err) this.ptNotifier.error(err.toString()) } finally { this.actionDisabled = false diff --git a/client/common/lib/elements/dynamic-table-form.ts b/client/common/lib/elements/dynamic-table-form.ts index ae7df63e..38ddd396 100644 --- a/client/common/lib/elements/dynamic-table-form.ts +++ b/client/common/lib/elements/dynamic-table-form.ts @@ -504,7 +504,7 @@ export class DynamicTableFormElement extends LivechatElement { } if (!formElement) { - console.warn(`value type '${(propertyValue.constructor.toString())}' is incompatible` + + this.logger.warn(`value type '${(propertyValue.constructor.toString())}' is incompatible` + `with field type '${propertySchema.inputType as string}' for form entry '${propertyName.toString()}'.`) } @@ -724,13 +724,13 @@ export class DynamicTableFormElement extends LivechatElement { : undefined if (value === undefined) { - console.warn('Could not update property : Target or value was undefined') + this.logger.warn('Could not update property : Target or value was undefined') return } const rowById = this._rowsById.find(rowById => rowById._id === rowId) if (!rowById) { - console.warn(`Could not update property : Did not find a property named '${propertyName}' in row '${rowId}'`) + this.logger.warn(`Could not update property : Did not find a property named '${propertyName}' in row '${rowId}'`) return } diff --git a/client/common/lib/elements/image-file-input.ts b/client/common/lib/elements/image-file-input.ts index 1d5e2581..2180cd0e 100644 --- a/client/common/lib/elements/image-file-input.ts +++ b/client/common/lib/elements/image-file-input.ts @@ -94,7 +94,7 @@ export class ImageFileInputElement extends LivechatElement { this.dispatchEvent(event) } catch (err) { // FIXME: use peertube notifier? - console.error(err) + this.logger.error(err) } } } diff --git a/client/common/lib/elements/tags-input.ts b/client/common/lib/elements/tags-input.ts index 0669c67e..2f71657a 100644 --- a/client/common/lib/elements/tags-input.ts +++ b/client/common/lib/elements/tags-input.ts @@ -347,7 +347,7 @@ export class TagsInputElement extends LivechatElement { private readonly _addTag = (value: string | undefined): void => { if (value === undefined) { - console.warn('Could not add tag : Target or value was undefined') + this.logger.warn('Could not add tag : Target or value was undefined') return } @@ -365,7 +365,7 @@ export class TagsInputElement extends LivechatElement { private readonly _removeTag = (index: number): void => { if (index < 0 || index >= this.value.length) { - console.warn('Could not remove tag : index out of range') + this.logger.warn('Could not remove tag : index out of range') return } diff --git a/client/common/room/register.ts b/client/common/room/register.ts index 9ea80ed3..f0e384a6 100644 --- a/client/common/room/register.ts +++ b/client/common/room/register.ts @@ -4,6 +4,7 @@ import type { RegisterClientOptions } from '@peertube/peertube-types/client' import { displayConverseJS } from '../../utils/conversejs' +import { logger } from '../../utils/logger' /** * Registers stuff related to "room" page. @@ -29,7 +30,7 @@ async function registerRoom (clientOptions: RegisterClientOptions): Promise void - info: (s: string) => void - error: (s: string) => void - warn: (s: string) => void + log: (s: any) => void + info: (s: any) => void + error: (s: any) => void + warn: (s: any) => void createLogger: (p: string) => Logger } function createLogger (prefix: string): Logger { return { - log: (s: string) => console.log('[' + prefix + '] ' + s), - info: (s: string) => console.info('[' + prefix + '] ' + s), - error: (s: string) => console.error('[' + prefix + '] ' + s), - warn: (s: string) => console.warn('[' + prefix + '] ' + s), + log: (s: any) => { + typeof s === 'string' ? console.log('[' + prefix + '] ' + s) : console.log('[' + prefix + ']', s) + }, + info: (s: any) => { + typeof s === 'string' ? console.info('[' + prefix + '] ' + s) : console.info('[' + prefix + ']', s) + }, + error: (s: any) => { + typeof s === 'string' ? console.error('[' + prefix + '] ' + s) : console.error('[' + prefix + ']', s) + }, + warn: (s: any) => { + typeof s === 'string' ? console.warn('[' + prefix + '] ' + s) : console.warn('[' + prefix + ']', s) + }, createLogger: (p: string) => createLogger('peertube-plugin-livechat>' + p) } }