* new createLogger function
* custom elements have their own logger
This commit is contained in:
John Livingston 2024-06-14 14:48:27 +02:00
parent 75dd2e4d59
commit d42bcf01a7
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 23 additions and 5 deletions

View File

@ -101,6 +101,11 @@ export class ShareChatElement extends LivechatElement {
this._restorePreviousState() this._restorePreviousState()
} }
protected override updated (changedProperties: PropertyValues): void {
super.updated(changedProperties)
this.logger.info('Update!')
}
protected override render = (): TemplateResult => { protected override render = (): TemplateResult => {
return html` return html`
${tplShareChatTabs(this)} ${tplShareChatTabs(this)}

View File

@ -2,13 +2,26 @@
// //
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
const logger = { interface Logger {
log: (s: string) => console.log('[peertube-plugin-livechat] ' + s), log: (s: string) => void
info: (s: string) => console.info('[peertube-plugin-livechat] ' + s), info: (s: string) => void
error: (s: string) => console.error('[peertube-plugin-livechat] ' + s), error: (s: string) => void
warn: (s: string) => console.warn('[peertube-plugin-livechat] ' + s) warn: (s: string) => 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),
createLogger: (p: string) => createLogger('peertube-plugin-livechat>' + p)
}
}
const logger = createLogger('peertube-plugin-livechat')
export { export {
logger logger
} }