Skip to content

Commit eb86983

Browse files
kediarovgithub-actions[bot]
authored andcommitted
Logs review (#5739)
Added throttle methods to reduce the amount of the same logs spamming. Some heavy debug log messages computations and now not executed for non-debug builds. Changed level of frequent and lifecycle events to debug. Changed level of non blocking errors to warnings. Changed level of warnings that are non-actionable from user to info. Added more info for generic `log(it)` cc @mapbox/maps-android cc @mapbox/maps-ios GitOrigin-RevId: ca3ce3e02a724eaba85de6c1596dceb59bd16ec3
1 parent 57c9a75 commit eb86983

File tree

43 files changed

+159
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+159
-114
lines changed

app/src/main/java/com/mapbox/maps/testapp/examples/customlayer/ExampleCustomLayer.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ class ExampleCustomLayer : CustomLayerHost {
3535
}
3636

3737
override fun initialize() {
38-
val maxAttrib = IntArray(1)
39-
GLES20.glGetIntegerv(GLES20.GL_MAX_VERTEX_ATTRIBS, maxAttrib, 0)
40-
logD(TAG, "Max vertex attributes: ${maxAttrib[0]}")
38+
logD(TAG) {
39+
val maxAttrib = IntArray(1)
40+
GLES20.glGetIntegerv(GLES20.GL_MAX_VERTEX_ATTRIBS, maxAttrib, 0)
41+
"Max vertex attributes: ${maxAttrib[0]}"
42+
}
4143

4244
// load and compile shaders
4345
vertexShader = loadShader(

compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/basic/QueryRenderedFeatureActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public class QueryRenderedFeatureActivity : ComponentActivity() {
135135
logD(TAG, "Clicked outside of building")
136136
return null
137137
}
138-
logD(TAG, "Feature properties: ${selectedBuildings.first().properties}")
138+
logD(TAG) { "Feature properties: ${selectedBuildings.first().properties}" }
139139
return (selectedBuildings.first().geometry as? Polygon)?.coordinates()?.toList()
140140
}
141141

extension-androidauto/src/main/java/com/mapbox/maps/extension/androidauto/CarMapSurfaceOwner.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import androidx.car.app.SurfaceCallback
77
import androidx.car.app.SurfaceContainer
88
import com.mapbox.maps.EdgeInsets
99
import com.mapbox.maps.MapInitOptions
10-
import com.mapbox.maps.MapSurface
1110
import com.mapbox.maps.ScreenCoordinate
11+
import com.mapbox.maps.logD
1212
import com.mapbox.maps.logI
1313
import java.util.concurrent.CopyOnWriteArraySet
1414

@@ -48,25 +48,25 @@ internal class CarMapSurfaceOwner(
4848

4949
internal fun registerObserver(mapboxCarMapObserver: MapboxCarMapObserver) {
5050
carMapObservers.add(mapboxCarMapObserver)
51-
logI(TAG, "registerObserver + 1 = ${carMapObservers.size}")
51+
logD(TAG, "registerObserver + 1 = ${carMapObservers.size}")
5252

5353
mapboxCarMapSurface?.let { carMapSurface ->
5454
mapboxCarMapObserver.onAttached(carMapSurface)
5555
}
5656
ifNonNull(mapboxCarMapSurface, visibleArea, visibleEdgeInsets) { _, area, edge ->
57-
logI(TAG, "registerObserver visibleAreaChanged")
57+
logD(TAG, "registerObserver visibleAreaChanged")
5858
mapboxCarMapObserver.onVisibleAreaChanged(area, edge)
5959
}
6060
ifNonNull(mapboxCarMapSurface, stableArea, stableEdgeInsets) { _, area, edge ->
61-
logI(TAG, "registerObserver stableAreaChanged")
61+
logD(TAG, "registerObserver stableAreaChanged")
6262
mapboxCarMapObserver.onStableAreaChanged(area, edge)
6363
}
6464
}
6565

6666
internal fun unregisterObserver(mapboxCarMapObserver: MapboxCarMapObserver) {
6767
carMapObservers.remove(mapboxCarMapObserver)
6868
mapboxCarMapSurface?.let { mapboxCarMapObserver.onDetached(it) }
69-
logI(TAG, "unregisterObserver - 1 = ${carMapObservers.size}")
69+
logD(TAG, "unregisterObserver - 1 = ${carMapObservers.size}")
7070
}
7171

7272
internal fun clearObservers() {
@@ -131,7 +131,7 @@ internal class CarMapSurfaceOwner(
131131
* @see SurfaceCallback.onVisibleAreaChanged
132132
*/
133133
override fun onVisibleAreaChanged(visibleArea: Rect) {
134-
logI(TAG, "onVisibleAreaChanged visibleArea:$visibleArea")
134+
logI(TAG, "onVisibleAreaChanged visibleArea:$visibleArea $visibleEdgeInsets")
135135
this.visibleArea = visibleArea
136136
notifyVisibleAreaChanged()
137137
}
@@ -140,7 +140,7 @@ internal class CarMapSurfaceOwner(
140140
this.visibleEdgeInsets = visibleArea?.edgeInsets()
141141
this.visibleCenter = visibleCenter()
142142
ifNonNull(mapboxCarMapSurface, visibleArea, visibleEdgeInsets) { _, area, edge ->
143-
logI(TAG, "notifyVisibleAreaChanged $area $edge")
143+
logD(TAG, "notifyVisibleAreaChanged $area $edge")
144144
carMapObservers.forEach {
145145
it.onVisibleAreaChanged(area, edge)
146146
}
@@ -154,11 +154,11 @@ internal class CarMapSurfaceOwner(
154154
* @see SurfaceCallback.onStableAreaChanged
155155
*/
156156
override fun onStableAreaChanged(stableArea: Rect) {
157-
logI(TAG, "onStableAreaChanged stableArea:$stableArea")
157+
logI(TAG, "onStableAreaChanged stableArea:$stableArea $stableEdgeInsets")
158158
this.stableEdgeInsets = stableArea.edgeInsets()
159159
this.stableArea = stableArea
160160
ifNonNull(mapboxCarMapSurface, stableArea, stableEdgeInsets) { _, area, edge ->
161-
logI(TAG, "notifyStableAreaChanged $area $edge")
161+
logD(TAG, "notifyStableAreaChanged $area $edge")
162162
carMapObservers.forEach {
163163
it.onStableAreaChanged(area, edge)
164164
}
@@ -171,7 +171,7 @@ internal class CarMapSurfaceOwner(
171171
* @see SurfaceCallback.onScroll
172172
*/
173173
override fun onScroll(distanceX: Float, distanceY: Float) {
174-
logI(TAG, "onScroll $distanceX, $distanceY")
174+
logD(TAG, "onScroll $distanceX, $distanceY")
175175
val carMapSurface = mapboxCarMapSurface ?: return
176176
gestureHandler?.onScroll(carMapSurface, visibleCenter, distanceX, distanceY)
177177
}
@@ -182,7 +182,7 @@ internal class CarMapSurfaceOwner(
182182
* @see SurfaceCallback.onFling
183183
*/
184184
override fun onFling(velocityX: Float, velocityY: Float) {
185-
logI(TAG, "onFling $velocityX, $velocityY")
185+
logD(TAG, "onFling $velocityX, $velocityY")
186186
val carMapSurface = mapboxCarMapSurface ?: return
187187
gestureHandler?.onFling(carMapSurface, velocityX, velocityY)
188188
}
@@ -193,7 +193,7 @@ internal class CarMapSurfaceOwner(
193193
* @see SurfaceCallback.onScale
194194
*/
195195
override fun onScale(focusX: Float, focusY: Float, scaleFactor: Float) {
196-
logI(TAG, "onScroll $focusX, $focusY, $scaleFactor")
196+
logD(TAG, "onScroll $focusX, $focusY, $scaleFactor")
197197
val carMapSurface = mapboxCarMapSurface ?: return
198198
gestureHandler?.onScale(carMapSurface, focusX, focusY, scaleFactor)
199199
}

extension-androidauto/src/test/java/com/mapbox/maps/extension/androidauto/MapboxCarMapTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class MapboxCarMapTest {
4141
fun setup() {
4242
mockkStatic("com.mapbox.maps.MapboxLogger")
4343
every { logI(any(), any()) } just Runs
44+
every { logD(any(), any<String>()) } just Runs
4445
mockkObject(MapSurfaceProvider)
4546
every { MapSurfaceProvider.create(any(), any(), any()) } returns testMapSurface
4647
}

extension-compose/src/main/java/com/mapbox/maps/extension/compose/annotation/internal/BaseAnnotationNode.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.mapbox.maps.extension.compose.internal.MapNode
88
import com.mapbox.maps.extension.compose.internal.StyleLifecycleAwareNode
99
import com.mapbox.maps.extension.compose.style.internal.StyleSlotNode
1010
import com.mapbox.maps.logD
11-
import com.mapbox.maps.logE
11+
import com.mapbox.maps.logW
1212
import kotlinx.coroutines.CoroutineScope
1313

1414
internal abstract class BaseAnnotationNode(
@@ -27,7 +27,7 @@ internal abstract class BaseAnnotationNode(
2727
if (parent is StyleSlotNode) {
2828
getLayerIds().forEach { layerId ->
2929
mapboxStyleManager.setStyleLayerProperty(layerId, "slot", Value(parent.slotName)).onError {
30-
logE(TAG, "Failed to set slot property for layer $layerId: $it")
30+
logW(TAG, "Failed to set slot property for layer $layerId: $it")
3131
}
3232
}
3333
}

extension-compose/src/main/java/com/mapbox/maps/extension/compose/internal/LayerPositionAwareNode.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.mapbox.maps.LayerPosition
44
import com.mapbox.maps.MapboxStyleManager
55
import com.mapbox.maps.extension.compose.style.internal.StyleLayerPositionNode
66
import com.mapbox.maps.logD
7-
import com.mapbox.maps.logE
7+
import com.mapbox.maps.logI
88
import com.mapbox.maps.logW
99

1010
/**
@@ -45,8 +45,8 @@ internal interface LayerPositionAwareNode {
4545
TAG,
4646
"Failed to move layer $associatedLayers.last() to $layerPosition: $error"
4747
)
48-
logE(TAG, "Available layers in style:")
49-
styleManager.styleLayers.forEach { logE(TAG, "\t ${it.id}") }
48+
val layers = styleManager.styleLayers.joinToString(separator = "\t ") { it.id }
49+
logI(TAG, "Available layers in style: $layers")
5050
}
5151

5252
if (associatedLayers.size > 1) {

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/atmosphere/AtmosphereStateApplier.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.mapbox.bindgen.Value
44
import com.mapbox.maps.MapboxMap
55
import com.mapbox.maps.logD
66
import com.mapbox.maps.logE
7+
import com.mapbox.maps.logI
8+
import com.mapbox.maps.logW
79
import kotlinx.coroutines.CoroutineName
810
import kotlinx.coroutines.CoroutineScope
911
import kotlinx.coroutines.Dispatchers
@@ -81,16 +83,16 @@ internal class AtmosphereStateApplier internal constructor(
8183
mapboxMap.setStyleAtmosphere(Value.valueOf(hashMapOf())).onValue {
8284
atmosphereSet = true
8385
mapboxMap.setStyleAtmosphereProperty(name, value).onError {
84-
logE(TAG, "Failed to set atmosphere property $name as $value: $error")
86+
logW(TAG, "Failed to set atmosphere property $name as $value: $error")
8587
}.onValue {
8688
logD(TAG, "settingProperty: name=$name, value=$value executed")
8789
}
8890
}.onError {
89-
logE(TAG, "Failed to set atmosphere with no properties, error = $it")
90-
logE(TAG, "settingProperty: name=$name, value=$value ignored")
91+
logW(TAG, "Failed to set atmosphere with no properties, error = $it")
92+
logI(TAG, "settingProperty: name=$name, value=$value ignored")
9193
}
9294
} else {
93-
logE(TAG, "Failed to set atmosphere property $name as $value: $error")
95+
logW(TAG, "Failed to set atmosphere property $name as $value: $error")
9496
}
9597
}.onValue {
9698
logD(TAG, "settingProperty: name=$name, value=$value executed")

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/imports/StyleImportsScope.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import com.mapbox.maps.extension.compose.style.ImportConfigs
1616
import com.mapbox.maps.extension.compose.style.StyleColorTheme
1717
import com.mapbox.maps.extension.compose.style.internal.MapStyleNode
1818
import com.mapbox.maps.logD
19-
import com.mapbox.maps.logE
19+
import com.mapbox.maps.logW
2020
import kotlinx.coroutines.CoroutineScope
2121
import kotlinx.coroutines.flow.firstOrNull
2222
import kotlinx.coroutines.launch
@@ -56,8 +56,8 @@ internal class StyleImportNode(
5656
config = config?.configs,
5757
importPosition = getRelativePositionInfo()
5858
)
59-
}.onError {
60-
logE(TAG, it)
59+
}.onError { error ->
60+
logW(TAG, "addStyleImport error: $error")
6161
}.onValue {
6262
logD(TAG, "added StyleImport($importId, $style, $config, null)")
6363
}

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/layers/internal/LayerNode.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import com.mapbox.maps.extension.compose.style.internal.StyleLayerPositionNode
1212
import com.mapbox.maps.extension.compose.style.internal.StyleSlotNode
1313
import com.mapbox.maps.extension.compose.style.sources.SourceState
1414
import com.mapbox.maps.logD
15-
import com.mapbox.maps.logE
1615
import com.mapbox.maps.logW
1716
import kotlinx.coroutines.CoroutineScope
1817

@@ -106,7 +105,7 @@ internal class LayerNode(
106105
parameters = Value(parameters),
107106
position = layerPosition
108107
).onError { error ->
109-
logE(TAG, "Failed to add layer: $error")
108+
logW(TAG, "Failed to add layer: $error")
110109
}.onValue {
111110
logD(TAG, "Added layer: $parameters")
112111
attachSource()
@@ -122,7 +121,7 @@ internal class LayerNode(
122121
properties = Value(parameters),
123122
layerPosition = layerPosition
124123
).onError {
125-
logE(TAG, "Failed to add persistent layer: $it")
124+
logW(TAG, "Failed to add persistent layer: $it")
126125
}.onValue {
127126
logD(TAG, "Added persistent layer: $parameters")
128127
attachSource()

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/lights/generated/AmbientLightState.kt

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)