2024-05-23 09:42:14 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-06-14 12:48:27 +00:00
|
|
|
interface Logger {
|
2024-06-14 13:17:14 +00:00
|
|
|
log: (s: any) => void
|
|
|
|
info: (s: any) => void
|
|
|
|
error: (s: any) => void
|
|
|
|
warn: (s: any) => void
|
2024-06-14 12:48:27 +00:00
|
|
|
createLogger: (p: string) => Logger
|
2021-12-14 14:41:34 +00:00
|
|
|
}
|
|
|
|
|
2024-06-14 12:48:27 +00:00
|
|
|
function createLogger (prefix: string): Logger {
|
|
|
|
return {
|
2024-06-14 13:17:14 +00:00
|
|
|
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)
|
|
|
|
},
|
2024-06-14 12:48:27 +00:00
|
|
|
createLogger: (p: string) => createLogger('peertube-plugin-livechat>' + p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const logger = createLogger('peertube-plugin-livechat')
|
|
|
|
|
2021-12-14 14:41:34 +00:00
|
|
|
export {
|
|
|
|
logger
|
|
|
|
}
|