log_path / log_level configuration

This commit is contained in:
les
2021-05-27 00:04:10 +02:00
parent 9a864ec2eb
commit 197f031c41
4 changed files with 14 additions and 4 deletions

View File

@@ -162,6 +162,12 @@ async function setupQuestionnaire (is_docker, db) {
validate: notEmpty
})
questions.push({
name: 'log_path',
message: 'Log path',
default: '/opt/gancio/logs'
})
questions.push({
name: 'smtp_type',
message: 'How should we send the emails ?',
@@ -228,6 +234,8 @@ async function setupQuestionnaire (is_docker, db) {
if (is_docker) {
answers.server = { host: '0.0.0.0', port: 13120 }
answers.upload_path = '/opt/gancio/uploads'
answers.log_level = 'debug'
answers.log_path = '/opt/gancio/logs'
if (db === 'sqlite') {
answers.db = { dialect: db, storage: '/opt/gancio/db.sqlite' }
} else {
@@ -282,7 +290,7 @@ If this is your first run use 'gancio setup --config <CONFIG_FILE.json>' `)
}
const config = require('config')
await run_migrations(config.db)
consola.info(`Logging to ${path.resolve('./logs/gancio.log')} [level: ${config.loglevel}]`)
consola.info(`Logging to ${path.resolve(`${config.log_path}/gancio.log`)} [level: ${config.log_level}]`)
require('./index')
}

View File

@@ -27,6 +27,8 @@ module.exports = {
delete config.smtp_need_auth
config.admin_email = admin.email
config.db.logging = false
config.log_level = 'debug'
config.log_path = '/opt/gancio/logs'
consola.info(`Save configuration to ${config_path}`)
try {
fs.writeFileSync(config_path, JSON.stringify(config, null, 2))

View File

@@ -21,8 +21,8 @@ const logger = createLogger({
: [new DailyRotateFile({
handleExceptions: true,
handleRejections: true,
level: config.loglevel || 'info',
filename: './logs/gancio.%DATE%.log',
level: config.log_level || 'info',
filename: config.log_path + '/gancio.%DATE%.log',
symlinkName: 'gancio.log',
createSymlink: true,
zippedArchive: true,