1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

chore: Add LOG_LEVEL to environment samples

This commit is contained in:
Maksim Eltyshev 2025-04-22 15:41:01 +02:00
parent 9f415e6b1e
commit 8e674f9269
4 changed files with 9 additions and 5 deletions

View file

@ -13,6 +13,8 @@ services:
- DATABASE_URL=postgresql://user:password@postgres:5432/planka_db - DATABASE_URL=postgresql://user:password@postgres:5432/planka_db
- SECRET_KEY=notsecretkey - SECRET_KEY=notsecretkey
# - LOG_LEVEL=warn
# - TRUST_PROXY=0 # - TRUST_PROXY=0
# - TOKEN_EXPIRES_IN=365 # In days # - TOKEN_EXPIRES_IN=365 # In days

View file

@ -15,6 +15,8 @@ services:
- DATABASE_URL=postgresql://postgres@postgres/planka - DATABASE_URL=postgresql://postgres@postgres/planka
- SECRET_KEY=notsecretkey - SECRET_KEY=notsecretkey
# - LOG_LEVEL=warn
# - TRUST_PROXY=0 # - TRUST_PROXY=0
# - TOKEN_EXPIRES_IN=365 # In days # - TOKEN_EXPIRES_IN=365 # In days

View file

@ -6,6 +6,7 @@ SECRET_KEY=notsecretkey
## Optional ## Optional
# LOG_LEVEL=warn
# LOG_FILE= # LOG_FILE=
# TRUST_PROXY=0 # TRUST_PROXY=0

View file

@ -6,16 +6,13 @@ const winston = require('winston');
*/ */
const defaultLogTimestampFormat = 'YYYY-MM-DD HH:mm:ss'; const defaultLogTimestampFormat = 'YYYY-MM-DD HH:mm:ss';
const logfile =
'LOG_FILE' in process.env ? process.env.LOG_FILE : `${process.cwd()}/logs/planka.log`;
/** /**
* Log level for both console and file log sinks. * Log level for both console and file log sinks.
* *
* Refer {@link https://github.com/winstonjs/winston#logging here} * Refer {@link https://github.com/winstonjs/winston#logging here}
* for more information on Winston log levels. * for more information on Winston log levels.
*/ */
const logLevel = 'LOG_LEVEL' in process.env ? process.env.LOG_LEVEL : 'warn'; const logLevel = process.env.LOG_LEVEL || 'warn';
const logFormat = winston.format.combine( const logFormat = winston.format.combine(
winston.format.uncolorize(), winston.format.uncolorize(),
@ -23,13 +20,15 @@ const logFormat = winston.format.combine(
winston.format.printf((log) => `${log.timestamp} [${log.level[0].toUpperCase()}] ${log.message}`), winston.format.printf((log) => `${log.timestamp} [${log.level[0].toUpperCase()}] ${log.message}`),
); );
const logFile = process.env.LOG_FILE || `${process.cwd()}/logs/planka.log`;
// eslint-disable-next-line new-cap // eslint-disable-next-line new-cap
const customLogger = new winston.createLogger({ const customLogger = new winston.createLogger({
transports: [ transports: [
new winston.transports.File({ new winston.transports.File({
level: logLevel, level: logLevel,
format: logFormat, format: logFormat,
filename: logfile, filename: logFile,
}), }),
new winston.transports.Console({ new winston.transports.Console({
level: logLevel, level: logLevel,