Skip to content

Commit fd09fb3

Browse files
committed
Timber logging
1 parent 3e6b94b commit fd09fb3

File tree

19 files changed

+64
-74
lines changed

19 files changed

+64
-74
lines changed

MPChartLib/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies {
4141
implementation("androidx.annotation:annotation:1.9.1")
4242
implementation("androidx.core:core:1.17.0")
4343
implementation("androidx.activity:activity-ktx:1.12.2")
44+
implementation("com.github.AppDevNext.Logcat:LogcatCoreLib:3.4")
4445
testImplementation("junit:junit:4.13.2")
4546
}
4647

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package com.github.mikephil.charting.charts
33
import android.content.Context
44
import android.graphics.RectF
55
import android.util.AttributeSet
6-
import android.util.Log
76
import com.github.mikephil.charting.components.YAxis
87
import com.github.mikephil.charting.data.BarData
98
import com.github.mikephil.charting.data.BarEntry
109
import com.github.mikephil.charting.highlight.BarHighlighter
1110
import com.github.mikephil.charting.highlight.Highlight
1211
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider
1312
import com.github.mikephil.charting.renderer.BarChartRenderer
13+
import timber.log.Timber
1414
import java.util.Locale
1515

1616
/**
@@ -105,7 +105,7 @@ open class BarChart : BarLineChartBase<BarData>, BarDataProvider {
105105
*/
106106
override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? {
107107
if (mData == null) {
108-
Log.e(LOG_TAG, "Can't select by touch. No data set.")
108+
Timber.e("Can't select by touch. No data set.")
109109
return null
110110
} else {
111111
highlighter?.let {

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.github.mikephil.charting.utils.UtilsKtKt;
3636

3737
import androidx.annotation.NonNull;
38+
import timber.log.Timber;
3839

3940
/**
4041
* Base-class of LineChart, BarChart, ScatterChart and CandleStickChart.
@@ -320,7 +321,7 @@ protected void onDraw(@NonNull Canvas canvas) {
320321
totalTime += drawtime;
321322
drawCycles += 1;
322323
long average = totalTime / drawCycles;
323-
Log.i(LOG_TAG, "Drawtime: " + drawtime + " ms, average: " + average + " ms, cycles: " + drawCycles);
324+
Timber.i("Drawtime: " + drawtime + " ms, average: " + average + " ms, cycles: " + drawCycles);
324325
}
325326
}
326327

@@ -335,7 +336,7 @@ public void resetTracking() {
335336
protected void prepareValuePxMatrix() {
336337

337338
if (isLogEnabled()) {
338-
Log.i(LOG_TAG, "Preparing Value-Px Matrix, xmin: " + mXAxis.mAxisMinimum + ", xmax: " + mXAxis.mAxisMaximum + ", xdelta: " + mXAxis.mAxisRange);
339+
Timber.i("Preparing Value-Px Matrix, xmin: " + mXAxis.mAxisMinimum + ", xmax: " + mXAxis.mAxisMaximum + ", xdelta: " + mXAxis.mAxisRange);
339340
}
340341

341342
mRightAxisTransformer.prepareMatrixValuePx(mXAxis.mAxisMinimum, mXAxis.mAxisRange, mAxisRight.mAxisRange, mAxisRight.mAxisMinimum);
@@ -353,12 +354,12 @@ public void notifyDataSetChanged() {
353354

354355
if (mData == null) {
355356
if (isLogEnabled()) {
356-
Log.i(LOG_TAG, "Preparing... DATA NOT SET.");
357+
Timber.i("Preparing... DATA NOT SET.");
357358
}
358359
return;
359360
} else {
360361
if (isLogEnabled()) {
361-
Log.i(LOG_TAG, "Preparing...");
362+
Timber.i("Preparing data...");
362363
}
363364
}
364365

@@ -520,8 +521,8 @@ public void calculateOffsets() {
520521
getViewPortHandler().restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom));
521522

522523
if (isLogEnabled()) {
523-
Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
524-
Log.i(LOG_TAG, "Content: " + getViewPortHandler().getContentRect());
524+
Timber.i("offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
525+
Timber.i("Content: " + getViewPortHandler().getContentRect());
525526
}
526527
}
527528

MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import android.graphics.RectF
1212
import android.graphics.Typeface
1313
import android.text.TextUtils
1414
import android.util.AttributeSet
15-
import android.util.Log
1615
import android.view.View
1716
import android.view.ViewGroup
1817
import android.view.accessibility.AccessibilityEvent
@@ -45,6 +44,7 @@ import com.github.mikephil.charting.utils.ViewPortHandler
4544
import com.github.mikephil.charting.utils.convertDpToPixel
4645
import com.github.mikephil.charting.utils.getDecimals
4746
import com.github.mikephil.charting.utils.initUtils
47+
import timber.log.Timber
4848
import kotlin.math.abs
4949
import kotlin.math.max
5050

@@ -274,7 +274,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
274274
mInfoPaint!!.textSize = 12f.convertDpToPixel()
275275

276276
if (this.isLogEnabled) {
277-
Log.i("", "Chart.init()")
277+
Timber.i("Chart.init()")
278278

279279
// enable being detected by ScreenReader
280280
setFocusable(true)
@@ -339,7 +339,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
339339
notifyDataSetChanged()
340340

341341
if (this.isLogEnabled) {
342-
Log.i(LOG_TAG, "Data is set.")
342+
Timber.i("Data is set.")
343343
}
344344
}
345345

@@ -649,7 +649,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
649649
this.highlighted = null
650650
} else {
651651
if (this.isLogEnabled) {
652-
Log.i(LOG_TAG, "Highlighted: $high")
652+
Timber.i("Highlighted: $high")
653653
}
654654

655655
entry = mData!!.getEntryForHighlight(high)
@@ -685,7 +685,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
685685
*/
686686
open fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? {
687687
if (mData == null) {
688-
Log.e(LOG_TAG, "Can't select by touch. No data set.")
688+
Timber.e("Can't select by touch. No data set.")
689689
return null
690690
} else {
691691
return this.highlighter!!.getHighlight(x, y)
@@ -1292,17 +1292,17 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
12921292

12931293
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
12941294
if (this.isLogEnabled) {
1295-
Log.i(LOG_TAG, "OnSizeChanged()")
1295+
Timber.i("OnSizeChanged()")
12961296
}
12971297

12981298
if (w > 0 && h > 0 && w < 10000 && h < 10000) {
12991299
if (this.isLogEnabled) {
1300-
Log.i(LOG_TAG, "Setting chart dimens, width: $w, height: $h")
1300+
Timber.i("Setting chart dimens, width: $w, height: $h")
13011301
}
13021302
viewPortHandler.setChartDimens(w.toFloat(), h.toFloat())
13031303
} else {
13041304
if (this.isLogEnabled) {
1305-
Log.w(LOG_TAG, "*Avoiding* setting chart dimens! width: $w, height: $h")
1305+
Timber.w("*Avoiding* setting chart dimens! width: $w, height: $h")
13061306
}
13071307
}
13081308

@@ -1334,7 +1334,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
13341334
override fun onDetachedFromWindow() {
13351335
super.onDetachedFromWindow()
13361336

1337-
//Log.i(LOG_TAG, "Detaching...");
1337+
//Timber.i("Detaching...");
13381338
if (mUnbind) {
13391339
unbindDrawables(this)
13401340
}
@@ -1380,7 +1380,7 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
13801380

13811381
override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean {
13821382
val completed = super.dispatchPopulateAccessibilityEvent(event)
1383-
Log.d(LOG_TAG, "Dispatch called for Chart <View> and completed as $completed")
1383+
Timber.d("Dispatch called for Chart <View> and completed as $completed")
13841384

13851385
event.text.add(this.accessibilityDescription)
13861386

@@ -1393,8 +1393,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
13931393
} // endregion
13941394

13951395
companion object {
1396-
const val LOG_TAG: String = "AndroidChart"
1397-
13981396
/**
13991397
* paint for the grid background (only line and barchart)
14001398
*/

MPChartLib/src/main/java/com/github/mikephil/charting/charts/CombinedChart.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.github.mikephil.charting.charts
33
import android.content.Context
44
import android.graphics.Canvas
55
import android.util.AttributeSet
6-
import android.util.Log
76
import com.github.mikephil.charting.data.BarData
87
import com.github.mikephil.charting.data.BubbleData
98
import com.github.mikephil.charting.data.CandleData
@@ -16,6 +15,7 @@ import com.github.mikephil.charting.highlight.Highlight
1615
import com.github.mikephil.charting.interfaces.dataprovider.CombinedDataProvider
1716
import com.github.mikephil.charting.interfaces.datasets.IDataSet
1817
import com.github.mikephil.charting.renderer.CombinedChartRenderer
18+
import timber.log.Timber
1919

2020
/**
2121
* This chart class allows the combination of lines, bars, scatter and candle
@@ -97,7 +97,7 @@ open class CombinedChart : BarLineChartBase<CombinedData>, CombinedDataProvider
9797
*/
9898
override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? {
9999
if (mData == null) {
100-
Log.e(LOG_TAG, "Can't select by touch. No data set.")
100+
Timber.e("Can't select by touch. No data set.")
101101
return null
102102
} else {
103103
highlighter?.let {

MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.github.mikephil.charting.charts
33
import android.content.Context
44
import android.graphics.RectF
55
import android.util.AttributeSet
6-
import android.util.Log
76
import com.github.mikephil.charting.components.Legend.LegendHorizontalAlignment
87
import com.github.mikephil.charting.components.Legend.LegendOrientation
98
import com.github.mikephil.charting.components.Legend.LegendVerticalAlignment
@@ -21,6 +20,7 @@ import com.github.mikephil.charting.utils.MPPointF
2120
import com.github.mikephil.charting.utils.MPPointF.Companion.getInstance
2221
import com.github.mikephil.charting.utils.TransformerHorizontalBarChart
2322
import com.github.mikephil.charting.utils.convertDpToPixel
23+
import timber.log.Timber
2424
import kotlin.math.max
2525
import kotlin.math.min
2626

@@ -154,17 +154,19 @@ open class HorizontalBarChart : BarChart {
154154
XAxisPosition.BOTTOM -> {
155155
offsetLeft += xLabelWidth
156156
}
157+
157158
XAxisPosition.TOP -> {
158159
offsetRight += xLabelWidth
159160
}
161+
160162
XAxisPosition.BOTH_SIDED -> {
161163
offsetLeft += xLabelWidth
162164
offsetRight += xLabelWidth
163165
}
164166

165167
XAxisPosition.TOP_INSIDE -> TODO()
166168
XAxisPosition.BOTTOM_INSIDE -> TODO()
167-
null -> Log.w(LOG_TAG, "XAxisPosition is null")
169+
null -> Timber.w("XAxisPosition is null")
168170
}
169171
}
170172

@@ -183,11 +185,8 @@ open class HorizontalBarChart : BarChart {
183185
)
184186

185187
if (isLogEnabled) {
186-
Log.i(
187-
LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " +
188-
offsetRight + ", offsetBottom: " + offsetBottom
189-
)
190-
Log.i(LOG_TAG, "Content: " + viewPortHandler.contentRect)
188+
Timber.i("offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom")
189+
Timber.i("Content: ${viewPortHandler.contentRect}")
191190
}
192191

193192
prepareOffsetMatrix()
@@ -255,7 +254,7 @@ open class HorizontalBarChart : BarChart {
255254
override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? {
256255
if (mData == null) {
257256
if (isLogEnabled) {
258-
Log.e(LOG_TAG, "Can't select by touch. No data set.")
257+
Timber.e("Can't select by touch. No data set.")
259258
}
260259
return null
261260
} else {

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.animation.ObjectAnimator
44
import android.annotation.SuppressLint
55
import android.content.Context
66
import android.util.AttributeSet
7-
import android.util.Log
87
import android.view.MotionEvent
98
import com.github.mikephil.charting.animation.Easing.EasingFunction
109
import com.github.mikephil.charting.components.Legend.LegendHorizontalAlignment
@@ -19,6 +18,7 @@ import com.github.mikephil.charting.utils.MPPointF.Companion.getInstance
1918
import com.github.mikephil.charting.utils.MPPointF.Companion.recycleInstance
2019
import com.github.mikephil.charting.utils.Utils
2120
import com.github.mikephil.charting.utils.convertDpToPixel
21+
import timber.log.Timber
2222
import kotlin.math.acos
2323
import kotlin.math.cos
2424
import kotlin.math.max
@@ -222,7 +222,7 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry>>>
222222
viewPortHandler.chartHeight * legend.maxSizePercent
223223
)
224224

225-
LegendVerticalAlignment.CENTER -> Log.e(LOG_TAG, "LegendCenter/VerticalCenter not supported for PieRadarChart")
225+
LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/VerticalCenter not supported for PieRadarChart")
226226
}
227227
}
228228
}
@@ -247,7 +247,7 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry>>>
247247
when (legend.verticalAlignment) {
248248
LegendVerticalAlignment.TOP -> legendTop = yLegendOffset
249249
LegendVerticalAlignment.BOTTOM -> legendBottom = yLegendOffset
250-
LegendVerticalAlignment.CENTER -> Log.e(LOG_TAG, "LegendCenter/HorizontalCenter not supported for PieRadarChart")
250+
LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/HorizontalCenter not supported for PieRadarChart")
251251
}
252252
}
253253
}
@@ -282,7 +282,7 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry>>>
282282
viewPortHandler.restrainViewPort(offsetLeft, offsetTop, offsetRight, offsetBottom)
283283

284284
if (isLogEnabled)
285-
Log.i(LOG_TAG, "offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom")
285+
Timber.i("offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom")
286286
}
287287

288288
/**

MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package com.github.mikephil.charting.components
33
import android.graphics.Color
44
import android.graphics.DashPathEffect
55
import android.graphics.Paint
6-
import android.util.Log
76
import com.github.mikephil.charting.formatter.DefaultAxisValueFormatter
87
import com.github.mikephil.charting.formatter.IAxisValueFormatter
98
import com.github.mikephil.charting.utils.convertDpToPixel
9+
import timber.log.Timber
1010
import kotlin.math.abs
1111

1212
/**
@@ -398,10 +398,7 @@ abstract class AxisBase : ComponentBase() {
398398
limitLines.add(l)
399399

400400
if (limitLines.size > 6) {
401-
Log.e(
402-
"MPAndroiChart",
403-
"Warning! You have more than 6 LimitLines on your axis, do you really want that?"
404-
)
401+
Timber.e("Warning! You have more than 6 LimitLines on your axis, do you really want that?")
405402
}
406403
}
407404

@@ -412,10 +409,7 @@ abstract class AxisBase : ComponentBase() {
412409
limitRanges.add(l)
413410

414411
if (limitRanges.size > 6) {
415-
Log.e(
416-
"MPAndroiChart",
417-
"Warning! You have more than 6 LimitLines on your axis, do you really want that?"
418-
)
412+
Timber.e("Warning! You have more than 6 LimitLines on your axis, do you really want that?")
419413
}
420414
}
421415

MPChartLib/src/main/java/com/github/mikephil/charting/data/ChartData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.github.mikephil.charting.data
22

33
import android.graphics.Typeface
4-
import android.util.Log
54
import com.github.mikephil.charting.components.YAxis.AxisDependency
65
import com.github.mikephil.charting.formatter.IValueFormatter
76
import com.github.mikephil.charting.highlight.Highlight
87
import com.github.mikephil.charting.interfaces.datasets.IDataSet
8+
import timber.log.Timber
99
import java.io.Serializable
1010
import java.util.Collections
1111

@@ -376,7 +376,7 @@ abstract class ChartData<T : IDataSet<out Entry>> : Serializable {
376376

377377
calcMinMax(entry, set.axisDependency)
378378
} else {
379-
Log.e("addEntry", "Cannot add Entry because dataSetIndex too high or too low.")
379+
Timber.e("Cannot add Entry because dataSetIndex too high or too low.")
380380
}
381381
}
382382

0 commit comments

Comments
 (0)