Logger:
* new createLogger function * custom elements have their own logger
This commit is contained in:
parent
75dd2e4d59
commit
d42bcf01a7
@ -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)}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user