Skip to content

Commit

Permalink
Convert lookup Logger to an instance variable (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
bolsinga authored Mar 6, 2024
1 parent d6d2dff commit b26b0c3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Sources/Site/Music/Lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
import Foundation
import os

extension Logger {
static let lookup = Logger(category: "lookup")
}

private func createLookup<T: Identifiable>(_ sequence: [T]) -> [T.ID: T] {
sequence.reduce(into: [:]) { $0[$1.id] = $1 }
}
Expand All @@ -30,6 +26,8 @@ public struct Lookup: Sendable {
private let venueFirstSetsMap: [Venue.ID: FirstSet]
private let relationMap: [String: [String]] // Artist/Venue ID : [Artist/Venue ID]

private let lookup = Logger(category: "lookup")

public init(music: Music) {
// non-parallel, used for Previews, tests
let artistRanks = music.artistRankings
Expand Down Expand Up @@ -128,7 +126,7 @@ public struct Lookup: Sendable {

public func venueForShow(_ show: Show) -> Venue? {
guard let venue = venueMap[show.venue] else {
Logger.lookup.log("Show: \(show.id, privacy: .public) missing venue")
lookup.log("Show: \(show.id, privacy: .public) missing venue")
return nil
}
return venue
Expand All @@ -138,8 +136,7 @@ public struct Lookup: Sendable {
var showArtists = [Artist]()
for id in show.artists {
guard let artist = artistMap[id] else {
Logger.lookup.log(
"Show: \(show.id, privacy: .public) missing artist: \(id, privacy: .public)")
lookup.log("Show: \(show.id, privacy: .public) missing artist: \(id, privacy: .public)")
continue
}
showArtists.append(artist)
Expand Down

0 comments on commit b26b0c3

Please sign in to comment.