我在我的应用中使用logWithContext
,并使用public class RequestIdFilter implements WebFilter {
private Logger LOG = LoggerFactory.getLogger(RequestIdFilter.class);
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
HttpHeaders headers = exchange.getRequest().getHeaders();
return chain.filter(exchange)
.doAfterSuccessOrError((r, t) -> logWithContext(headers, httpHeaders -> LOG.info("Some message with MDC set")))
.subscriberContext(Context.of(HttpHeaders.class, headers));
}
static void logWithContext(HttpHeaders headers, Consumer<HttpHeaders> logAction) {
try {
headers.forEach((name, values) -> MDC.put(name, values.get(0)));
logAction.accept(headers);
} finally {
headers.keySet().forEach(MDC::remove);
}
}
}
正确设置了GoogleMaps
,Info.plist
中的所有内容
EXC_BAD_INSTRUCTION
即使我设置正确。这是下面的代码。
locationManager...didChangeAuthorization
这是我的locationManager代表
requestWhenInUseAuthorization
注意:似乎我两次要求locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
let camera = GMSCameraPosition.camera(withTarget: (self.locationManager.location?.coordinate)!, zoom: zoomLevel)
self.mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
self.view = self.mapView
self.initializeTheLocationManager()
self.mapView.isMyLocationEnabled = true
。
答案 0 :(得分:2)
这不起作用。
startUpdatingLocation
异步工作。您必须实现didUpdateLocations
。
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
...
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let camera = GMSCameraPosition.camera(withTarget: (locations[0].coordinate, zoom: zoomLevel)
self.locationManager.stopUpdatingLocation()
self.mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
self.view = self.mapView
self.initializeTheLocationManager()
self.mapView.isMyLocationEnabled = true
}