Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(backend): add option to enable log colorization

johaven1d3e5525387d
diff --git a/backend/src/configuration/config.logger.ts b/backend/src/configuration/config.logger.ts
index 6b4ca987..0ca4b71c 100644
--- a/backend/src/configuration/config.logger.ts
+++ b/backend/src/configuration/config.logger.ts
@@ -6,7 +6,7 @@
import { join } from 'node:path'
import type { Options } from 'pino-http'
-import { APP_RUN_PATH } from './config.constants'
+import { APP_LOGS_PATH } from './config.constants'
import type { LoggerConfig } from './config.validation'
export const configLogger = (loggerConfig: LoggerConfig) =>
@@ -53,13 +53,13 @@ export const configLogger = (loggerConfig: LoggerConfig) =>
ignore: 'hostname,context,reqId,req,res,user,userAgent,responseTime',
hideObject: false,
singleLine: false,
- colorize: loggerConfig.stdout,
+ colorize: loggerConfig.colorize,
colorizeObjects: false,
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',
messageFormat: `[{context}]{if user} <{user}> {end} ${
- loggerConfig.stdout ? '\x1b[37m' : ''
+ loggerConfig.colorize ? '\x1b[37m' : ''
}{msg}{if res} ({res.contentLength} bytes in {responseTime}ms) {userAgent}{end}{if reqId} | {reqId}{end}`,
- destination: loggerConfig.stdout ? 1 : join(APP_RUN_PATH, 'app.log'),
+ destination: loggerConfig.stdout ? 1 : join(APP_LOGS_PATH, 'server.log'),
mkdir: true,
sync: false
}
diff --git a/backend/src/configuration/config.validation.ts b/backend/src/configuration/config.validation.ts
index 4bd6898a..8f03eb58 100644
--- a/backend/src/configuration/config.validation.ts
+++ b/backend/src/configuration/config.validation.ts
@@ -22,7 +22,7 @@ export class ServerConfig {
@IsInt()
@Min(1024)
@Max(65535)
- port: number = 3000
+ port: number = 8080
@Transform(({ value }) => (value === 0 || value === 'auto' ? cpus().length : Math.max(Number(value), 2)))
@IsInt()
@@ -43,6 +43,9 @@ export class LoggerConfig {
@IsBoolean()
stdout: boolean = true
+
+ @IsBoolean()
+ colorize: boolean = true
}
export class Configuration {
diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yaml
index 1163cd31..ec101e4d 100755
--- a/environment/environment.dist.yaml
+++ b/environment/environment.dist.yaml
@@ -1,6 +1,8 @@
server:
+ # default host : 0.0.0.0
host: 0.0.0.0
- port: 3000
+ # default port : 8080
+ port: 8080
# workers: auto (use all cpus) | number
# regardless of the value, starts with at least 2 workers, 1 worker is dedicated to scheduled tasks
workers: 4
@@ -13,6 +15,8 @@ logger:
level: trace
# stdout : if false logs are written to the run directory (default: true)
stdout: true
+ # colorize output
+ colorize: true
mysql:
url: mysql://user:MySQLRootPassword@localhost:3306/database
logQueries: false