Skip to content

Commit

Permalink
convert Log class to kotlin
Browse files Browse the repository at this point in the history
@JvmStatic is necessary to keep the static behavior of the method calls

Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Jan 3, 2025
1 parent 7680d51 commit 3874751
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions app/src/test/java/android/util/Log.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,55 @@
* SPDX-FileCopyrightText: 2024 Daniel Calviño Sánchez <[email protected]>
* 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.
* <p>
*
*
* 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
* tests, simply printing the messages to the system console.
*/
public class Log {
object Log {

public static int d(String tag, String msg) {
System.out.println("DEBUG: " + tag + ": " + msg);
@JvmStatic
fun d(tag: String, msg: String): Int {
println("DEBUG: $tag: $msg")

return 1;
return 1
}

public static int e(String tag, String msg) {
System.out.println("ERROR: " + tag + ": " + msg);
@JvmStatic
fun e(tag: String, msg: String): Int {
println("ERROR: $tag: $msg")

return 1;
return 1
}

public static int i(String tag, String msg) {
System.out.println("INFO: " + tag + ": " + msg);
@JvmStatic
fun i(tag: String, msg: String): Int {
println("INFO: $tag: $msg")

return 1;
return 1
}

public static boolean isLoggable(String tag, int level) {
return true;
@JvmStatic
fun isLoggable(tag: String?, level: Int): Boolean {
return true
}

public static int v(String tag, String msg) {
System.out.println("VERBOSE: " + tag + ": " + msg);
@JvmStatic
fun v(tag: String, msg: String): Int {
println("VERBOSE: $tag: $msg")

return 1;
return 1
}

public static int w(String tag, String msg) {
System.out.println("WARN: " + tag + ": " + msg);
@JvmStatic
fun w(tag: String, msg: String): Int {
println("WARN: $tag: $msg")

return 1;
return 1
}
}

0 comments on commit 3874751

Please sign in to comment.