From f020c13739b8d3818cd7e94e1fc5bf315c0a9951 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Thu, 13 Oct 2022 12:25:51 +0200 Subject: [PATCH] Specify production setting in configuration --- Sources/App/Management/Configuration.swift | 7 +++++++ Sources/App/configure.swift | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/App/Management/Configuration.swift b/Sources/App/Management/Configuration.swift index 1c9f451..f4915a1 100644 --- a/Sources/App/Management/Configuration.swift +++ b/Sources/App/Management/Configuration.swift @@ -6,6 +6,13 @@ struct Configuration { let mail: EMail + /** + Use a database file and reduce logging. + + If this property is set to `false`, then an in-memory database is used with increased logging. + */ + let production: Bool + struct EMail { /// The url to the root of the server diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 1f6a2e6..f7b63e8 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -16,11 +16,10 @@ public func configure(_ app: Application) throws { // Set target environment app.environment = .production - if app.environment == .development { + if !configuration.production { app.logger.logLevel = .info print("[DEVELOPMENT] Using in-memory database") app.databases.use(.sqlite(.memory), as: .sqlite) - } else { app.logger.logLevel = .notice let dbFile = storageFolder.appendingPathComponent("db.sqlite").path