Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stream-log/api/android/stream-log.api
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public final class io/getstream/log/StreamLog {
public static final fun d (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
public static final fun e (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;)V
public static final fun e (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
public static synthetic fun e$default (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
public final fun getInternalLogger ()Lio/getstream/log/StreamLogger;
public final fun getInternalValidator ()Lio/getstream/log/IsLoggableValidator;
public static final fun getLogger (Ljava/lang/String;)Lio/getstream/log/TaggedLogger;
Expand Down Expand Up @@ -113,6 +114,7 @@ public final class io/getstream/log/TaggedLogger {
public final fun d (Lkotlin/jvm/functions/Function0;)V
public final fun e (Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;)V
public final fun e (Lkotlin/jvm/functions/Function0;)V
public static synthetic fun e$default (Lio/getstream/log/TaggedLogger;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
public final fun getDelegate ()Lio/getstream/log/StreamLogger;
public final fun getTag ()Ljava/lang/String;
public final fun getValidator ()Lio/getstream/log/IsLoggableValidator;
Expand Down
2 changes: 2 additions & 0 deletions stream-log/api/jvm/stream-log.api
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public final class io/getstream/log/StreamLog {
public static final fun d (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
public static final fun e (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;)V
public static final fun e (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
public static synthetic fun e$default (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
public final fun getInternalLogger ()Lio/getstream/log/StreamLogger;
public final fun getInternalValidator ()Lio/getstream/log/IsLoggableValidator;
public static final fun getLogger (Ljava/lang/String;)Lio/getstream/log/TaggedLogger;
Expand Down Expand Up @@ -111,6 +112,7 @@ public final class io/getstream/log/TaggedLogger {
public final fun d (Lkotlin/jvm/functions/Function0;)V
public final fun e (Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;)V
public final fun e (Lkotlin/jvm/functions/Function0;)V
public static synthetic fun e$default (Lio/getstream/log/TaggedLogger;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
public final fun getDelegate ()Lio/getstream/log/StreamLogger;
public final fun getTag ()Ljava/lang/String;
public final fun getValidator ()Lio/getstream/log/IsLoggableValidator;
Expand Down
49 changes: 12 additions & 37 deletions stream-log/src/commonMain/kotlin/io/getstream/log/StreamLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import io.getstream.log.Priority.INFO
import io.getstream.log.Priority.VERBOSE
import io.getstream.log.Priority.WARN
import kotlin.concurrent.Volatile
import kotlin.jvm.JvmOverloads
import kotlin.jvm.JvmStatic

/**
Expand Down Expand Up @@ -112,25 +113,13 @@ public object StreamLog {
* @param message The function returning a message you would like logged.
*/
@JvmStatic
public inline fun e(tag: String, throwable: Throwable, message: () -> String) {
@JvmOverloads
public inline fun e(tag: String, throwable: Throwable? = null, message: () -> String) {
if (internalValidator.isLoggable(ERROR, tag)) {
internalLogger.log(ERROR, tag, message(), throwable)
}
}

/**
* Send a [ERROR] log message.
*
* @param tag Used to identify the source of a log message.
* @param message The function returning a message you would like logged.
*/
@JvmStatic
public inline fun e(tag: String, message: () -> String) {
if (internalValidator.isLoggable(ERROR, tag)) {
internalLogger.log(ERROR, tag, message())
}
}

/**
* Send a [WARN] log message.
*
Expand Down Expand Up @@ -206,17 +195,13 @@ public object StreamLog {
*/
@JvmStatic
public inline fun log(priority: Priority, tag: String, throwable: Throwable? = null, message: () -> String) {
if (throwable != null) {
e(tag, throwable, message)
} else {
when (priority) {
VERBOSE -> v(tag, message)
DEBUG -> d(tag, message)
INFO -> i(tag, message)
WARN -> w(tag, message)
ERROR -> e(tag, message)
ASSERT -> a(tag, message)
}
when (priority) {
VERBOSE -> v(tag, message)
DEBUG -> d(tag, message)
INFO -> i(tag, message)
WARN -> w(tag, message)
ERROR -> e(tag, throwable, message)
ASSERT -> a(tag, message)
}
}
}
Expand Down Expand Up @@ -250,23 +235,13 @@ public class TaggedLogger(
* @param throwable An exception to log.
* @param message The function returning a message you would like logged.
*/
public inline fun e(throwable: Throwable, message: () -> String) {
@JvmOverloads
public inline fun e(throwable: Throwable? = null, message: () -> String) {
if (validator.isLoggable(ERROR, tag)) {
delegate.log(ERROR, tag, message(), throwable)
}
}

/**
* Send a [ERROR] log message.
*
* @param message The function returning a message you would like logged.
*/
public inline fun e(message: () -> String) {
if (validator.isLoggable(ERROR, tag)) {
delegate.log(ERROR, tag, message())
}
}

/**
* Send a [WARN] log message.
*
Expand Down