Prosody log level will be the same as the Peertube's one.

This commit is contained in:
John Livingston 2021-05-12 11:48:38 +02:00
parent bcf5066c90
commit c5bcf611d3
4 changed files with 24 additions and 4 deletions

View File

@ -7,6 +7,7 @@
* Builtin prosody use a working dir provided by Peertube (needs Peertube >= 3.2.0)
* Starting with Peertube 3.2.0, builtin prosody save room history on server. So when a user connects, he can get previously send messages.
* Starting with Peertube 3.2.0, builtin prosody also activate mod_muc_moderation, enabling moderators to moderate messages.
* Prosody log level will be the same as the Peertube's one.
### Fixes

View File

@ -11,7 +11,8 @@ This roadmap is given as an indication. It will be updated as we go along accord
[x] | [ ] | Builtin Prosody | Grant moderation rights to instance admins and video owner. Activate moderations commands in ConverseJS. | v2.1.0
[x] | [x] | Common | Chat should not be displayed in playlists | v2.2.0
[x] | [x] | Builtin Prosody | Do not use a temp folder, use the one provided by Peertube>=3.2.0. | Not Released Yet
[ ] | [x] | Builtin Prosody | Rotate prosody logs. Use Peertube log level for prosody.
[x] | [ ] | Builtin Prosody | Use Peertube log level for prosody. | Not Released Yet
[ ] | [x] | Builtin Prosody | Rotate prosody logs.
[x] | [x] | Builtin Prosody | Data Persistence | Not Released Yet
[ ] | [x] | Common | Add a checkbox per video to activate livechat. Only on lives.
[ ] | [x] | Builtin Prosody | Docker: check how to install and use Prosody on docker installations. Do the documentation.

View File

@ -5,6 +5,7 @@ import { ProsodyFilePaths } from './config/paths'
import { ProsodyConfigContent } from './config/content'
import { getProsodyDomain } from './config/domain'
import { getAPIKey } from '../apikey'
import type { ProsodyLogLevel } from './config/content'
async function _getTemporaryWorkingDir ({ peertubeHelpers, storageManager }: RegisterServerOptions): Promise<string> {
const tmpBaseDir = '/tmp/'
@ -134,7 +135,20 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
// TODO: add a settings so that admin can choose? (on/off and duration)
config.useMam('1w') // Remove archived messages after 1 week
}
config.setLog(process.env.NODE_ENV === 'test' ? 'debug' : 'info')
let logLevel: ProsodyLogLevel | undefined
if (logger.level && (typeof logger.level === 'string')) {
if (logger.level === 'error' || logger.level === 'info' || logger.level === 'debug') {
logLevel = logger.level
} else if (logger.level === 'warn' || logger.level === 'warning') {
// Should be 'warn', but just in case... (this value was buggy with peertube <= 3.2.0-rc1)
logLevel = 'warn'
}
}
if (logLevel === undefined) {
logger.info('No log level found in Peertube, will use default "info" for Prosody')
logLevel = 'info'
}
config.setLog(logLevel)
const content = config.write()
return {

View File

@ -94,7 +94,7 @@ class ProsodyConfigComponent extends ProsodyConfigBlock {
}
}
type ProsodyLogLevel = 'debug' | 'info'
type ProsodyLogLevel = 'debug' | 'info' | 'warn' | 'error'
class ProsodyConfigContent {
paths: ProsodyFilePaths
@ -233,7 +233,10 @@ class ProsodyConfigContent {
setLog (level: ProsodyLogLevel, syslog?: ProsodyLogLevel[]): void {
let log = ''
log += 'log = {\n'
log += ' ' + level + ' = ' + writeValue(this.paths.log)
if (level !== 'error') {
log += ' ' + level + ' = ' + writeValue(this.paths.log)
}
// always log error level in a separate file.
log += ' error = ' + writeValue(this.paths.error)
if (syslog) {
log += ' { to = "syslog"; levels = ' + writeValue(syslog) + ' };\n'
@ -260,5 +263,6 @@ class ProsodyConfigContent {
}
export {
ProsodyLogLevel,
ProsodyConfigContent
}