Skip to content

Commit

Permalink
Add migrationLogLevel configuration (#756)
Browse files Browse the repository at this point in the history
* Add migrationLogLevel configuration
* Use .any() instead of .next() for ELG
  • Loading branch information
madsodgaard committed Feb 12, 2023
1 parent 44155a5 commit 4db22cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Expand Up @@ -10,7 +10,7 @@ let package = Package(
.library(name: "Fluent", targets: ["Fluent"]),
],
dependencies: [
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.36.0"),
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.38.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.50.0"),
],
targets: [
Expand Down
15 changes: 12 additions & 3 deletions Sources/Fluent/FluentProvider.swift
Expand Up @@ -52,7 +52,8 @@ extension Application {
databases: self.databases,
migrations: self.migrations,
logger: self.logger,
on: self.eventLoopGroup.next()
on: self.eventLoopGroup.any(),
migrationLogLevel: self.fluent.migrationLogLevel
)
}

Expand All @@ -76,13 +77,15 @@ extension Application {
final class Storage {
let databases: Databases
let migrations: Migrations
var migrationLogLevel: Logger.Level

init(threadPool: NIOThreadPool, on eventLoopGroup: EventLoopGroup) {
init(threadPool: NIOThreadPool, on eventLoopGroup: EventLoopGroup, migrationLogLevel: Logger.Level) {
self.databases = Databases(
threadPool: threadPool,
on: eventLoopGroup
)
self.migrations = .init()
self.migrationLogLevel = migrationLogLevel
}
}

Expand Down Expand Up @@ -128,11 +131,17 @@ extension Application {
func initialize() {
self.application.storage[Key.self] = .init(
threadPool: self.application.threadPool,
on: self.application.eventLoopGroup
on: self.application.eventLoopGroup,
migrationLogLevel: .info
)
self.application.lifecycle.use(Lifecycle())
self.application.commands.use(MigrateCommand(), as: "migrate")
}

public var migrationLogLevel: Logger.Level {
get { self.storage.migrationLogLevel }
nonmutating set { self.storage.migrationLogLevel = newValue }
}

public var history: History {
.init(fluent: self)
Expand Down

0 comments on commit 4db22cc

Please sign in to comment.