Skip to content

Commit 2f63984

Browse files
authored
Improve internal Logger (#2361)
1 parent 605e8fd commit 2f63984

35 files changed

+109
-73
lines changed

Sources/MapboxMaps/Annotations/Annotation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ extension Array where Element: Annotation {
8787
let duplicates = self.removeDuplicates(by: \.id)
8888
if !duplicates.isEmpty {
8989
let ids = duplicates.lazy.map(\.id).joined(separator: ", ")
90-
Log.error(forMessage: "Duplicated annotations: \(ids)", category: "Annotations")
90+
Log.error("Duplicated annotations: \(ids)", category: "Annotations")
9191
}
9292
}
9393
}

Sources/MapboxMaps/Annotations/AnnotationImagesManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal final class AnnotationImagesManager: AnnotationImagesManagerProtocol {
6060
addedAnnotationImages.insert(id)
6161
} catch {
6262
Log.warning(
63-
forMessage: "Could not add image to style due to error: \(error)",
63+
"Could not add image to style due to error: \(error)",
6464
category: "Annnotations")
6565
}
6666
}
@@ -75,7 +75,7 @@ internal final class AnnotationImagesManager: AnnotationImagesManagerProtocol {
7575
addedAnnotationImages.remove(imageName)
7676
} catch {
7777
Log.warning(
78-
forMessage: "Could not remove image from style due to error: \(error)",
78+
"Could not remove image from style due to error: \(error)",
7979
category: "Annnotations")
8080
}
8181
}

Sources/MapboxMaps/Annotations/AnnotationManagerImpl.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
9696
do {
9797
try style.moveLayer(withId: id, to: layerPosition ?? .default)
9898
} catch {
99-
Log.error(forMessage: "Failed to mover layer to a new position. Error: \(error)", category: "Annotations")
99+
Log.error("Failed to mover layer to a new position. Error: \(error)", category: "Annotations")
100100
}
101101
}
102102
}
@@ -135,7 +135,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
135135
try style.addPersistentLayer(layer, layerPosition: layerPosition)
136136
} catch {
137137
Log.error(
138-
forMessage: "Failed to create source / layer in \(implementationName). Error: \(error)",
138+
"Failed to create source / layer in \(implementationName). Error: \(error)",
139139
category: "Annotations")
140140
}
141141

@@ -160,7 +160,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
160160
)
161161
} catch {
162162
Log.error(
163-
forMessage: "Failed to add cluster layer in \(implementationName). Error: \(error)",
163+
"Failed to add cluster layer in \(implementationName). Error: \(error)",
164164
category: "Annotations")
165165
}
166166
}
@@ -197,7 +197,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
197197
try style.removeLayer(withId: "mapbox-iOS-cluster-text-layer-manager-" + id)
198198
} catch {
199199
Log.error(
200-
forMessage: "Failed to remove cluster layer in \(implementationName). Error: \(error)",
200+
"Failed to remove cluster layer in \(implementationName). Error: \(error)",
201201
category: "Annotations")
202202
}
203203
}
@@ -232,7 +232,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
232232
try body()
233233
} catch {
234234
Log.warning(
235-
forMessage: "Failed to remove \(what) for \(implementationName) with id \(id) due to error: \(error)",
235+
"Failed to remove \(what) for \(implementationName) with id \(id) due to error: \(error)",
236236
category: "Annotations")
237237
}
238238
}
@@ -326,7 +326,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
326326
}
327327
} catch {
328328
Log.error(
329-
forMessage: "Could not set layer properties in PointAnnotationManager due to error \(error)",
329+
"Could not set layer properties in PointAnnotationManager due to error \(error)",
330330
category: "Annotations")
331331
}
332332
}
@@ -500,7 +500,7 @@ final class AnnotationManagerImpl<AnnotationType: Annotation & AnnotationInterna
500500
try style.addSource(GeoJSONSource(id: dragId))
501501
try style.addPersistentLayer(AnnotationType.makeLayer(id: dragId), layerPosition: .above(id))
502502
} catch {
503-
Log.error(forMessage: "Add drag source/layer \(error)", category: "Annotations")
503+
Log.error("Add drag source/layer \(error)", category: "Annotations")
504504
}
505505
}
506506
}

Sources/MapboxMaps/Annotations/AnnotationOrchestrator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public final class AnnotationOrchestrator {
170170

171171
if let manager, warnIfRemoved {
172172
Log.warning(
173-
forMessage: "\(type(of: manager)) with id \(id) was removed implicitly when invoking \(function) with the same id.",
173+
"\(type(of: manager)) with id \(id) was removed implicitly when invoking \(function) with the same id.",
174174
category: "Annotations")
175175
}
176176
}

Sources/MapboxMaps/Annotations/ViewAnnotation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public final class ViewAnnotation {
357357
do {
358358
try body()
359359
} catch {
360-
Log.error(forMessage: "Failed to \(action) annotation \(id): \(error)", category: "ViewAnnotation")
360+
Log.error("Failed to \(action) annotation \(id): \(error)", category: "ViewAnnotation")
361361
}
362362
}
363363

Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ extension ViewAnnotationManager {
580580
func validateAnnotationSuperview(_ view: UIView, expected: UIView?) {
581581
// Re-add the view if the superview of the annotation view is different than the container
582582
if view.superview != expected {
583-
Log.warning(forMessage: "Superview changed for annotation view. Use `ViewAnnotationManager.remove(_ view: UIView)` instead to remove it from the layout calculation.", category: "Annotations")
583+
Log.warning("Superview changed for annotation view. Use `ViewAnnotationManager.remove(_ view: UIView)` instead to remove it from the layout calculation.", category: "Annotations")
584584
view.removeFromSuperview()
585585
expected?.addSubview(view)
586586
}
@@ -589,7 +589,7 @@ func validateAnnotationSuperview(_ view: UIView, expected: UIView?) {
589589
func validateAnnotationHidden(_ view: UIView, expected: Bool) {
590590
// View is still considered for layout calculation, users should not modify the visibility of view directly
591591
if view.isHidden != expected {
592-
Log.warning(forMessage: "Visibility changed for annotation view. Use `ViewAnnotationManager.update(view: UIView, options: ViewAnnotationOptions)` instead to update visibility and remove the view from layout calculation.", category: "Annotations")
592+
Log.warning("Visibility changed for annotation view. Use `ViewAnnotationManager.update(view: UIView, options: ViewAnnotationOptions)` instead to update visibility and remove the view from layout calculation.", category: "Annotations")
593593
view.isHidden = expected
594594
}
595595
}

Sources/MapboxMaps/Camera/SimpleCameraAnimator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal final class SimpleCameraAnimator: SimpleCameraAnimatorProtocol {
4444
hasNilMismatch(for: \.anchor) ||
4545
hasNilMismatch(for: \.bearing) ||
4646
hasNilMismatch(for: \.pitch) {
47-
Log.warning(forMessage: "Animator updated with differing non-nil to-value properties.", category: "maps-ios")
47+
Log.warning("Animator updated with differing non-nil to-value properties.", category: "maps-ios")
4848
}
4949
}
5050
}

Sources/MapboxMaps/ContentBuilders/MapContent/MapContentUniqueProperties.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extension MapContentUniqueProperties {
8181
case .flat:
8282
lights.flat = try? lightContainer.decode(FlatLight.self)
8383
default:
84-
Log.warning(forMessage: "Incorrect light configuration. Specify both directional and ambient lights OR flat light.", category: "StyleDSL")
84+
Log.warning("Incorrect light configuration. Specify both directional and ambient lights OR flat light.", category: "StyleDSL")
8585
}
8686
}
8787
}
@@ -96,7 +96,7 @@ private extension MapContentUniqueProperties.Lights {
9696
os_log(.debug, log: .contentDSL, "set 3d lights")
9797
try style.setLights(ambient: ambient, directional: directional)
9898
} else if directional != nil || ambient != nil {
99-
Log.warning(forMessage: "Incorrect 3D light configuration. Specify both directional and ambient lights.", category: "StyleDSL")
99+
Log.warning("Incorrect 3D light configuration. Specify both directional and ambient lights.", category: "StyleDSL")
100100
} else if let flat = flat {
101101
os_log(.debug, log: .contentDSL, "set flat light")
102102
try style.setLights(flat)

Sources/MapboxMaps/ContentBuilders/MapContent/MapStyleReconciler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ extension MapStyleReconciler {
124124
}
125125
}
126126
} catch {
127-
Log.error(forMessage: "Failed updating import config properties, \(error)")
127+
Log.error("Failed updating import config properties, \(error)")
128128
}
129129
}
130130
}

Sources/MapboxMaps/ContentBuilders/MapContent/MountedViewAnnotation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ final class MountedViewAnnotation: MapContentMountedComponent {
7070

7171
func unmount(with context: MapContentNodeContext) throws {
7272
guard let remove else {
73-
return Log.error(forMessage: "Could not remove the view annotation", category: "Annotations")
73+
return Log.error("Could not remove the view annotation", category: "Annotations")
7474
}
7575
remove()
7676
}

0 commit comments

Comments
 (0)