Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SpectralDragon committed Jun 18, 2024
1 parent 2206c5c commit 82753cb
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ ada_engine_deps = [
"@SPIRV-Cross",
":SPIRVCompiler",
"@swiftpkg_box2d_swift//:box2d",
"@swiftpkg_swift_log//:Logging",
":MiniAudioBindings"
]

Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ use_repo(
swift_deps,
"swiftpkg_box2d_swift",
"swiftpkg_swift_collections",
"swiftpkg_swift_log",
)
# swift_deps END
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@
"version" : "1.0.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ var adaEngineDependencies: [Target.Dependency] = [
"Math",
.product(name: "Collections", package: "swift-collections"),
.product(name: "BitCollections", package: "swift-collections"),
.product(name: "Logging", package: "swift-log"),
"MiniAudioBindings",
"AtlasFontGenerator",
"Yams",
Expand Down Expand Up @@ -265,6 +266,7 @@ let package = Package(
package.dependencies += [
.package(url: "https://github.com/apple/swift-collections", branch: "main"),
.package(url: "https://github.com/jpsim/Yams", from: "5.0.1"),
.package(url: "https://github.com/apple/swift-log", from: "1.5.4"),
// Plugins
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-syntax", from: "509.1.1")
Expand Down
1 change: 1 addition & 0 deletions Sources/AdaEditor/AdaEditorApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import AdaEngine
import Logging

@main
struct AdaEditorApp: App {
Expand Down
6 changes: 6 additions & 0 deletions Sources/AdaEngine/Application/AppCreate/AppContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by v.prusakov on 4/30/24.
//

import Logging

final class AppContext<T: App> {

private var app: T
Expand Down Expand Up @@ -37,11 +39,15 @@ final class AppContext<T: App> {
try ResourceManager.initialize()
try AudioServer.initialize()



RuntimeTypeLoader.loadTypes()

guard let appScene = app.scene as? InternalAppScene else {
fatalError("Incorrect object of App Scene")
}

LoggingSystem.bootstrap(StreamLogHandler.standardError)

Task { @MainActor in
var configuration = _AppSceneConfiguration()
Expand Down
6 changes: 5 additions & 1 deletion Sources/AdaEngine/Scene/2D/TileMap/TileMapSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
// Created by v.prusakov on 5/5/24.
//

import Logging

// FIXME: a lot of sprites drop fps.

public struct TileMapSystem: System {

let logger = Logger(label: "tilemap")

public static var dependencies: [SystemDependency] = [
.after(VisibilitySystem.self)
Expand Down Expand Up @@ -100,7 +104,7 @@ public struct TileMapSystem: System {
tileEntity = entitySource.getEntity(at: tile.atlasCoordinates)
tileEntity.components += Transform(scale: scale, position: position)
default:
print("TileSource isn't supported for id: \(tile.sourceId)")
logger.warning("TileSource isn't supported for id: \(tile.sourceId)")
continue
}

Expand Down
5 changes: 4 additions & 1 deletion Sources/AdaEngine/Scene/Resources/TileMap/LdtkTileMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by v.prusakov on 5/11/24.
//

import Logging

/// Namespace for LDtk
public enum LDtk { }

Expand Down Expand Up @@ -161,7 +163,8 @@ extension LDtk {
do {
try await loadLdtkProject(from: data)
} catch {
print("Failed to update ldtk file", error.localizedDescription)

Logger(label: "LDtk").critical("Failed to update ldtk file \(error.localizedDescription)")
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion bazel/swiftpm/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ let package = Package(
dependencies: [
// FIXME: If possible - move to local `vendors` folder
.package(url: "https://github.com/apple/swift-collections", branch: "main"),
.package(url: "https://github.com/AdaEngine/box2d-swift", branch: "main")
.package(url: "https://github.com/AdaEngine/box2d-swift", branch: "main"),
.package(url: "https://github.com/apple/swift-log", from: "1.5.4")
],
swiftLanguageVersions: [.v5],
cLanguageStandard: .c17,
Expand Down

0 comments on commit 82753cb

Please sign in to comment.