convert Log class to kotlin

@JvmStatic is necessary to keep the static behavior of the method calls

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-01-03 12:44:56 +01:00
parent 7680d51b09
commit 3874751fcb
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -4,48 +4,55 @@
* SPDX-FileCopyrightText: 2024 Daniel Calviño Sánchez <danxuliu@gmail.com> * SPDX-FileCopyrightText: 2024 Daniel Calviño Sánchez <danxuliu@gmail.com>
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
package android.util; package android.util
/** /**
* Dummy implementation of android.util.Log to be used in unit tests. * Dummy implementation of android.util.Log to be used in unit tests.
* <p> *
*
* The Android Gradle plugin provides a library with the APIs of the Android framework that throws an exception if any * The Android Gradle plugin provides a library with the APIs of the Android framework that throws an exception if any
* of them are called. This class is loaded before that library and therefore becomes the implementation used during the * of them are called. This class is loaded before that library and therefore becomes the implementation used during the
* tests, simply printing the messages to the system console. * tests, simply printing the messages to the system console.
*/ */
public class Log { object Log {
public static int d(String tag, String msg) { @JvmStatic
System.out.println("DEBUG: " + tag + ": " + msg); fun d(tag: String, msg: String): Int {
println("DEBUG: $tag: $msg")
return 1; return 1
} }
public static int e(String tag, String msg) { @JvmStatic
System.out.println("ERROR: " + tag + ": " + msg); fun e(tag: String, msg: String): Int {
println("ERROR: $tag: $msg")
return 1; return 1
} }
public static int i(String tag, String msg) { @JvmStatic
System.out.println("INFO: " + tag + ": " + msg); fun i(tag: String, msg: String): Int {
println("INFO: $tag: $msg")
return 1; return 1
} }
public static boolean isLoggable(String tag, int level) { @JvmStatic
return true; fun isLoggable(tag: String?, level: Int): Boolean {
return true
} }
public static int v(String tag, String msg) { @JvmStatic
System.out.println("VERBOSE: " + tag + ": " + msg); fun v(tag: String, msg: String): Int {
println("VERBOSE: $tag: $msg")
return 1; return 1
} }
public static int w(String tag, String msg) { @JvmStatic
System.out.println("WARN: " + tag + ": " + msg); fun w(tag: String, msg: String): Int {
println("WARN: $tag: $msg")
return 1; return 1
} }
} }