🔨 Add logger level to config

This commit is contained in:
Sebastien Clement 2021-01-05 10:36:44 +01:00
parent 57d0394dac
commit bdfecede62
3 changed files with 9 additions and 8 deletions

View File

@ -24,15 +24,10 @@
"hassio_role": "manager", "hassio_role": "manager",
"homeassistant_api": true, "homeassistant_api": true,
"options": { "options": {
"ssl": false, "log_level": "info"
"certfile": "fullchain.pem",
"keyfile": "privkey.pem"
}, },
"schema": { "schema": {
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)?", "log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)?",
"ssl": "bool",
"certfile": "str",
"keyfile": "str",
"leave_front_door_open": "bool?" "leave_front_door_open": "bool?"
}, },
"ports": { "ports": {

View File

@ -2,7 +2,7 @@ const appRoot = require("app-root-path");
const winston = require("winston"); const winston = require("winston");
const logger = winston.createLogger({ const logger = winston.createLogger({
level: "debug", level: process.env.LOG_LEVEL || 'info' ,
format: winston.format.combine( format: winston.format.combine(
winston.format.timestamp({ winston.format.timestamp({
format: "YYYY-MM-DD HH:mm:ss", format: "YYYY-MM-DD HH:mm:ss",
@ -11,6 +11,7 @@ const logger = winston.createLogger({
// winston.format.splat(), // winston.format.splat(),
winston.format.colorize(), winston.format.colorize(),
winston.format.align(),
winston.format.printf(({ level, message, timestamp }) => { winston.format.printf(({ level, message, timestamp }) => {
return `[${timestamp}] [${level}]: ${message}`; return `[${timestamp}] [${level}]: ${message}`;
}) })

View File

@ -9,4 +9,9 @@
# ============================================================================== # ==============================================================================
cd /opt/nextcloud_backup/ cd /opt/nextcloud_backup/
npm start if bashio::config.exists 'log_level'; then
LOG_LEVEL=$(bashio::config 'log_level')
else
LOG_LEVEL='info'
fi
LOG_LEVEL=$LOG_LEVEL npm start