Prosody log level will be the same as the Peertube's one.
This commit is contained in:
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user