diff options
author | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2018-11-14 15:42:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 15:42:18 -0800 |
commit | c8fbcfd322e1af4520f0bdc7e5945f6ffd3b4b73 (patch) | |
tree | 9158facaa7fc8b728a69f87f494a71fb659d9727 /platform/macos/src/MGLMapView.mm | |
parent | 86677b97c6d5e7db75358e9f5745dab4cec5d0e4 (diff) | |
download | qtlocation-mapboxgl-c8fbcfd322e1af4520f0bdc7e5945f6ffd3b4b73.tar.gz |
[ios, macos] Logging. (#13235)
* [ios, macos] Update the logging subsystem to platform agnostic.
* [ios, macos] Add coordinate to string function.
* [ios, macos] Add BOOL to string function.
* [ios, macos] Add tracing logs.
* [ios, macos] Add tracing logs to generated style classes.
* [ios, macos] Split logging categories accordingly to MGLLoggingLevel.
* [ios, macos] Log network requests.
* [ios, macos] Migrate NSAssert to MGLAssert.
* [ios, macos] Include MGLLoggingConfiguration to filesource-files.txt.
* [ios, macos] Fix logger string specifier for the line parameter.
* [ios, macos] Add logs to shapes classes.
* [ios, macos] Add logs to offline classes.
* [ios, macos] Add logs to annotation classes.
* [ios, macos] Add logs to foundation classes.
* [ios, macos] Fix snapshotter size logging.
* [macos] Add logs to map view.
* [ios, macos] Fix string from boolean prefix, add custom function for NSCAssert.
* Log size test
* [ios, macos] Add logging conditional compilation flag.
* [ios, macos] Rename function NSStringFromMGLTransition to MGLStringFromMGLTransition.
* [ios, macos] Remove verbose logging for release builds.
* [ios, macos] Rename NSStringFromCLLocationCoordinate2D to MGLStringFromCLLocationCoordinate2D.
* [ios, macos] Clean unnecesary blank lines in MGLLight.mm set methods.
* [ios, macos] Fix logging grammar, format, function names.
* [ios, macos] Remove compilation flag, rename flags.
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index a1a5e8c2ab..486870f51c 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -222,23 +222,31 @@ public: - (instancetype)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + MGLLogDebug(@"Initializing frame: %@", NSStringFromRect(frameRect)); [self commonInit]; self.styleURL = nil; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } - (instancetype)initWithFrame:(NSRect)frame styleURL:(nullable NSURL *)styleURL { if (self = [super initWithFrame:frame]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + MGLLogDebug(@"Initializing frame: %@ styleURL: %@", NSStringFromRect(frame), styleURL); [self commonInit]; self.styleURL = styleURL; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } - (instancetype)initWithCoder:(nonnull NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); [self commonInit]; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } @@ -258,7 +266,6 @@ public: } - (void)commonInit { - MGLLogInfo(@"Initializing."); _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; // Set up cross-platform controllers and resources. @@ -319,7 +326,6 @@ public: _mbglMap->jumpTo(options); _pendingLatitude = NAN; _pendingLongitude = NAN; - MGLLogInfo(@"Initialization completed."); } - (mbgl::Size)size { @@ -633,7 +639,7 @@ public: if (!styleURL) { styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion]; } - + MGLLogDebug(@"Setting styleURL: %@", styleURL); // An access token is required to load any default style, including Streets. if (![MGLAccountManager accessToken] && [styleURL.scheme isEqualToString:@"mapbox"]) { NSLog(@"Cannot set the style URL to %@ because no access token has been specified.", styleURL); @@ -646,6 +652,7 @@ public: } - (IBAction)reloadStyle:(__unused id)sender { + MGLLogInfo(@"Reloading style."); NSURL *styleURL = self.styleURL; _mbglMap->getStyle().loadURL(""); self.styleURL = styleURL; @@ -979,10 +986,12 @@ public: } - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate { + MGLLogDebug(@"Setting centerCoordinate: %@", MGLStringFromCLLocationCoordinate2D(centerCoordinate)); [self setCenterCoordinate:centerCoordinate animated:NO]; } - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate animated:(BOOL)animated { + MGLLogDebug(@"Setting centerCoordinate: %@ animated: %@", MGLStringFromCLLocationCoordinate2D(centerCoordinate), MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"centerCoordinate"]; _mbglMap->setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), @@ -1028,10 +1037,12 @@ public: } - (void)setZoomLevel:(double)zoomLevel { + MGLLogDebug(@"Setting zoomLevel: %f", zoomLevel); [self setZoomLevel:zoomLevel animated:NO]; } - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated { + MGLLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"zoomLevel"]; _mbglMap->setZoom(zoomLevel, MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), @@ -1055,11 +1066,13 @@ public: - (void)setMinimumZoomLevel:(double)minimumZoomLevel { + MGLLogDebug(@"Setting minimumZoomLevel: %f", minimumZoomLevel); _mbglMap->setMinZoom(minimumZoomLevel); } - (void)setMaximumZoomLevel:(double)maximumZoomLevel { + MGLLogDebug(@"Setting maximumZoomLevel: %f", maximumZoomLevel); _mbglMap->setMaxZoom(maximumZoomLevel); } @@ -1096,10 +1109,12 @@ public: } - (void)setDirection:(CLLocationDirection)direction { + MGLLogDebug(@"Setting direction: %f", direction); [self setDirection:direction animated:NO]; } - (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated { + MGLLogDebug(@"Setting direction: %f animated: %@", direction, MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"direction"]; _mbglMap->setBearing(direction, MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), @@ -1121,14 +1136,17 @@ public: } - (void)setCamera:(MGLMapCamera *)camera { + MGLLogDebug(@"Setting camera: %@", camera); [self setCamera:camera animated:NO]; } - (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated { + MGLLogDebug(@"Setting camera: %@ animated: %@", camera, MGLStringFromBOOL(animated)); [self setCamera:camera withDuration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil completionHandler:NULL]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@", camera, duration, function); [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:self.contentInsets completionHandler:completion]; } @@ -1166,14 +1184,17 @@ public: } - (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ completionHandler: %@", camera, completion); [self flyToCamera:camera withDuration:-1 completionHandler:completion]; } - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ withDuration: %f completionHandler: %@", camera, duration, completion); [self flyToCamera:camera withDuration:duration peakAltitude:-1 completionHandler:completion]; } - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ withDuration: %f peakAltitude: %f completionHandler: %@", camera, duration, peakAltitude, completion); mbgl::AnimationOptions animationOptions; if (duration >= 0) { animationOptions.duration = MGLDurationFromTimeInterval(duration); @@ -1238,10 +1259,12 @@ public: } - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@", MGLStringFromCoordinateBounds(bounds)); [self setVisibleCoordinateBounds:bounds animated:NO]; } - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds animated:(BOOL)animated { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@ animated: %@", MGLStringFromCoordinateBounds(bounds), MGLStringFromBOOL(animated)); [self setVisibleCoordinateBounds:bounds edgePadding:NSEdgeInsetsZero animated:animated]; } @@ -2218,6 +2241,7 @@ public: } - (void)setSelectedAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Selecting annotation: %@", annotation); [self willChangeValueForKey:@"selectedAnnotations"]; _selectedAnnotationTag = [self annotationTagForAnnotation:annotation]; if (_selectedAnnotationTag != MGLAnnotationTagNotFound) { @@ -2232,6 +2256,7 @@ public: } - (void)setSelectedAnnotations:(NSArray<id <MGLAnnotation>> *)selectedAnnotations { + MGLLogDebug(@"Selecting: %lu annotations", selectedAnnotations.count); if (!selectedAnnotations.count) { return; } @@ -2252,16 +2277,19 @@ public: - (void)selectAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Selecting annotation: %@", annotation); [self selectAnnotation:annotation atPoint:NSZeroPoint]; } - (void)selectAnnotation:(id <MGLAnnotation>)annotation atPoint:(NSPoint)gesturePoint { + MGLLogDebug(@"Selecting annotation: %@ atPoint: %@", annotation, NSStringFromPoint(gesturePoint)); [self selectAnnotation:annotation atPoint:gesturePoint moveOnscreen:YES animateSelection:YES]; } - (void)selectAnnotation:(id <MGLAnnotation>)annotation atPoint:(NSPoint)gesturePoint moveOnscreen:(BOOL)moveOnscreen animateSelection:(BOOL)animateSelection { + MGLLogDebug(@"Selecting annotation: %@ atPoint: %@ moveOnscreen: %@ animateSelection: %@", annotation, NSStringFromPoint(gesturePoint), MGLStringFromBOOL(moveOnscreen), MGLStringFromBOOL(animateSelection)); id <MGLAnnotation> selectedAnnotation = self.selectedAnnotation; if (annotation == selectedAnnotation) { return; @@ -2373,6 +2401,7 @@ public: } - (void)showAnnotations:(NSArray<id <MGLAnnotation>> *)annotations animated:(BOOL)animated { + MGLLogDebug(@"Showing: %lu annotations animated: %@", annotations.count, MGLStringFromBOOL(animated)); CGFloat maximumPadding = 100; CGFloat yPadding = (NSHeight(self.bounds) / 5 <= maximumPadding) ? (NSHeight(self.bounds) / 5) : maximumPadding; CGFloat xPadding = (NSWidth(self.bounds) / 5 <= maximumPadding) ? (NSWidth(self.bounds) / 5) : maximumPadding; @@ -2598,11 +2627,13 @@ public: } - (void)addOverlay:(id <MGLOverlay>)overlay { + MGLLogDebug(@"Adding overlay: %@", overlay); [self addOverlays:@[overlay]]; } - (void)addOverlays:(NSArray<id <MGLOverlay>> *)overlays { + MGLLogDebug(@"Adding: %lu overlays", overlays.count); #if DEBUG for (id <MGLOverlay> overlay in overlays) { NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"Overlay does not conform to MGLOverlay"); @@ -2612,10 +2643,12 @@ public: } - (void)removeOverlay:(id <MGLOverlay>)overlay { + MGLLogDebug(@"Removing overlay: %@", overlay); [self removeOverlays:@[overlay]]; } - (void)removeOverlays:(NSArray<id <MGLOverlay>> *)overlays { + MGLLogDebug(@"Removing: %lu overlays", overlays.count); #if DEBUG for (id <MGLOverlay> overlay in overlays) { NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"Overlay does not conform to MGLOverlay"); @@ -2697,14 +2730,17 @@ public: #pragma mark Data - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(NSPoint)point { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@", NSStringFromPoint(point)); return [self visibleFeaturesAtPoint:point inStyleLayersWithIdentifiers:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@", NSStringFromPoint(point), styleLayerIdentifiers); return [self visibleFeaturesAtPoint:point inStyleLayersWithIdentifiers:styleLayerIdentifiers predicate:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(NSPoint)point inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers predicate:(NSPredicate *)predicate { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@ predicate: %@", NSStringFromPoint(point), styleLayerIdentifiers, predicate); // Cocoa origin is at the lower-left corner. mbgl::ScreenCoordinate screenCoordinate = { point.x, NSHeight(self.bounds) - point.y }; @@ -2728,14 +2764,17 @@ public: } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(NSRect)rect { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@", NSStringFromRect(rect)); return [self visibleFeaturesInRect:rect inStyleLayersWithIdentifiers:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@", NSStringFromRect(rect), styleLayerIdentifiers); return [self visibleFeaturesInRect:rect inStyleLayersWithIdentifiers:styleLayerIdentifiers predicate:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(NSRect)rect inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers predicate:(NSPredicate *)predicate { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@ predicate: %@", NSStringFromRect(rect), styleLayerIdentifiers, predicate); // Cocoa origin is at the lower-left corner. mbgl::ScreenBox screenBox = { { NSMinX(rect), NSHeight(self.bounds) - NSMaxY(rect) }, |