@@ -22,6 +22,7 @@ import io.getstream.log.Priority.INFO
22
22
import io.getstream.log.Priority.VERBOSE
23
23
import io.getstream.log.Priority.WARN
24
24
import kotlin.concurrent.Volatile
25
+ import kotlin.jvm.JvmOverloads
25
26
import kotlin.jvm.JvmStatic
26
27
27
28
/* *
@@ -112,25 +113,13 @@ public object StreamLog {
112
113
* @param message The function returning a message you would like logged.
113
114
*/
114
115
@JvmStatic
115
- public inline fun e (tag : String , throwable : Throwable , message : () -> String ) {
116
+ @JvmOverloads
117
+ public inline fun e (tag : String , throwable : Throwable ? = null, message : () -> String ) {
116
118
if (internalValidator.isLoggable(ERROR , tag)) {
117
119
internalLogger.log(ERROR , tag, message(), throwable)
118
120
}
119
121
}
120
122
121
- /* *
122
- * Send a [ERROR] log message.
123
- *
124
- * @param tag Used to identify the source of a log message.
125
- * @param message The function returning a message you would like logged.
126
- */
127
- @JvmStatic
128
- public inline fun e (tag : String , message : () -> String ) {
129
- if (internalValidator.isLoggable(ERROR , tag)) {
130
- internalLogger.log(ERROR , tag, message())
131
- }
132
- }
133
-
134
123
/* *
135
124
* Send a [WARN] log message.
136
125
*
@@ -206,17 +195,13 @@ public object StreamLog {
206
195
*/
207
196
@JvmStatic
208
197
public inline fun log (priority : Priority , tag : String , throwable : Throwable ? = null, message : () -> String ) {
209
- if (throwable != null ) {
210
- e(tag, throwable, message)
211
- } else {
212
- when (priority) {
213
- VERBOSE -> v(tag, message)
214
- DEBUG -> d(tag, message)
215
- INFO -> i(tag, message)
216
- WARN -> w(tag, message)
217
- ERROR -> e(tag, message)
218
- ASSERT -> a(tag, message)
219
- }
198
+ when (priority) {
199
+ VERBOSE -> v(tag, message)
200
+ DEBUG -> d(tag, message)
201
+ INFO -> i(tag, message)
202
+ WARN -> w(tag, message)
203
+ ERROR -> e(tag, throwable, message)
204
+ ASSERT -> a(tag, message)
220
205
}
221
206
}
222
207
}
@@ -250,23 +235,13 @@ public class TaggedLogger(
250
235
* @param throwable An exception to log.
251
236
* @param message The function returning a message you would like logged.
252
237
*/
253
- public inline fun e (throwable : Throwable , message : () -> String ) {
238
+ @JvmOverloads
239
+ public inline fun e (throwable : Throwable ? = null, message : () -> String ) {
254
240
if (validator.isLoggable(ERROR , tag)) {
255
241
delegate.log(ERROR , tag, message(), throwable)
256
242
}
257
243
}
258
244
259
- /* *
260
- * Send a [ERROR] log message.
261
- *
262
- * @param message The function returning a message you would like logged.
263
- */
264
- public inline fun e (message : () -> String ) {
265
- if (validator.isLoggable(ERROR , tag)) {
266
- delegate.log(ERROR , tag, message())
267
- }
268
- }
269
-
270
245
/* *
271
246
* Send a [WARN] log message.
272
247
*
0 commit comments