Configure file log

This commit is contained in:
Christoph Hagen 2022-09-05 19:27:31 +02:00
parent 34edc88611
commit 2f0827a430

View File

@ -10,8 +10,6 @@ public func configure(_ app: Application) throws {
let resourcesFolderUrl = URL(fileURLWithPath: app.directory.resourcesDirectory)
let configUrl = resourcesFolderUrl.appendingPathComponent("config.json")
tokenStorage = .init(in: resourcesFolderUrl)
let config: ServerConfiguration
do {
let data = try Data(contentsOf: configUrl)
@ -20,6 +18,9 @@ public func configure(_ app: Application) throws {
print("Failed to load config from \(configUrl.path): \(error)")
return
}
Log.set(logFile: URL(fileURLWithPath: config.logPath))
tokenStorage = .init(in: resourcesFolderUrl)
app.http.server.configuration.port = config.port
@ -35,6 +36,7 @@ public func configure(_ app: Application) throws {
try routes(app)
serverStatus = .running
log(info: "Server is running")
}
private extension JSONDecoder {