Skip to content

Commit

Permalink
Adopt LGNLog (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirilltitov authored Oct 24, 2021
1 parent e5714b6 commit dd685bd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
run: |
eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
sudo apt-get install -y wget
wget https://www.foundationdb.org/downloads/6.2.22/ubuntu/installers/foundationdb-clients_6.2.22-1_amd64.deb
wget https://www.foundationdb.org/downloads/6.2.22/ubuntu/installers/foundationdb-server_6.2.22-1_amd64.deb
sudo dpkg -i foundationdb-clients_6.2.22-1_amd64.deb foundationdb-server_6.2.22-1_amd64.deb
wget https://www.foundationdb.org/downloads/6.3.18/ubuntu/installers/foundationdb-clients_6.3.18-1_amd64.deb
wget https://www.foundationdb.org/downloads/6.3.18/ubuntu/installers/foundationdb-server_6.3.18-1_amd64.deb
sudo dpkg -i foundationdb-clients_6.3.18-1_amd64.deb foundationdb-server_6.3.18-1_amd64.deb
sudo service foundationdb start
git clone https://github.com/kirilltitov/FDBSwift.git
chmod +x FDBSwift/scripts/install_pkgconfig.sh
Expand Down
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ let package = Package(
.library(name: "Entita2FDB", targets: ["Entita2FDB"]),
],
dependencies: [
.package(url: "https://github.com/1711-Games/Entita2.git", .upToNextMajor(from: "1.0.0-RC-2")),
.package(url: "https://github.com/kirilltitov/FDBSwift.git", .upToNextMajor(from: "5.0.0-RC-1")),
.package(url: "https://github.com/1711-Games/Entita2.git", from: "1.0.0"),
.package(url: "https://github.com/kirilltitov/FDBSwift.git", .upToNextMajor(from: "5.0.0-RC-2")),
.package(url: "https://github.com/1711-Games/LGN-Log.git", .upToNextMinor(from: "0.2.0")),
],
targets: [
.target(
name: "Entita2FDB",
dependencies: [
.product(name: "Entita2", package: "Entita2"),
.product(name: "FDB", package: "FDBSwift"),
.product(name: "LGNLog", package: "LGN-Log"),
]
),
.testTarget(name: "Entita2FDBTests", dependencies: ["Entita2FDB"]),
Expand Down
10 changes: 5 additions & 5 deletions Sources/Entita2FDB/E2+Indices.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FDB
import Logging
import LGNLog

public typealias E2FDBIndexedEntity = Entita2FDBIndexedEntity

Expand Down Expand Up @@ -176,15 +176,15 @@ public extension Entita2FDBIndexedEntity {
)
}

Entita2.logger.debug("Creating \(index.unique ? "unique " : "")index '\(key.rawValue)' with value '\(value)'")
Logger.current.debug("Creating \(index.unique ? "unique " : "")index '\(key.rawValue)' with value '\(value)'")

let transaction = try await Self.storage.unwrapAnyTransactionOrBegin(maybeTransaction)
transaction.set(key: self.getIndexKeyForIndex(index, key: key, value: value), value: self.getIDAsKey())
transaction.set(key: self.getIndexIndexKeyForIndex(key: key, value: value), value: [])
}

func afterInsert0(within transaction: AnyTransaction?) async throws {
Entita2.logger.debug("Creating indices \(Self.indices.keys.map { $0.rawValue }) for entity '\(self.getID())'")
Logger.current.debug("Creating indices \(Self.indices.keys.map { $0.rawValue }) for entity '\(self.getID())'")

for (key, index) in Self.indices {
try await self.createIndex(
Expand Down Expand Up @@ -241,11 +241,11 @@ public extension Entita2FDBIndexedEntity {
)
}
guard let key = IndexKey(rawValue: keyName) else {
Entita2.logger.debug("Unknown index '\(keyName)' in entity '\(Self.entityName)', skipping")
Logger.current.debug("Unknown index '\(keyName)' in entity '\(Self.entityName)', skipping")
continue
}
guard let index = Self.indices[key] else {
Entita2.logger.debug("No index '\(key)' in entity '\(Self.entityName)', skipping")
Logger.current.debug("No index '\(key)' in entity '\(Self.entityName)', skipping")
continue
}
guard let propertyValue = self.getIndexValueFrom(index: index) else {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Entita2FDB/E2FDB+Storage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FDB
import LGNLog

public typealias E2FDBStorage = Entita2FDBStorage

Expand Down Expand Up @@ -45,7 +46,7 @@ extension FDB: Entita2FDBStorage {
if let transaction = anyTransaction {
return transaction
} else {
Entita2.logger.debug("Beginning a new transaction")
Logger.current.debug("Beginning a new transaction")
return try self.begin()
}
}
Expand Down
6 changes: 1 addition & 5 deletions Tests/Entita2FDBTests/Entita2FDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,13 @@ final class Entita2FDBTests: XCTestCase {

override class func setUp() {
super.setUp()
var logger = Logger(label: "testlogger")
logger.logLevel = .debug
FDB.logger = logger
E2.logger = logger
try! self.fdb.connect()
self.subspace = FDB.Subspace("test \(Int.random(in: 0 ..< Int.max))")
}

override class func tearDown() {
super.tearDown()
FDB.logger.notice("Cleanup")
Logger.current.notice("Cleanup")
// do {
// try self.fdb.clear(subspace: self.subspace)
// } catch {
Expand Down

0 comments on commit dd685bd

Please sign in to comment.