New in version 1.8.0.
You can set or change your app's log level when developing or debugging your application. You might want to change the log level to log different amounts of data depending on your development needs.
NoteThis page shows how to set a Realm logger, which was added in Realm Kotlin SDK v1.8.0. This supersedes setting the Sync client log level in earlier versions of the Realm Kotlin SDK. For information on how to set the Sync client log level in an earlier version, refer to Set the Client Log Level - Kotlin SDK.
You can set your app's log level using the global RealmLog singleton. You can set the RealmLog.level
property to an entry in the LogLevel enum to specify the level of data you want to receive. If the log level priority is equal to or higher than the priority defined in RealmLog.level
, Realm logs the event.
You can change the log level at any point during the app's lifecycle from this global singleton. This behavior differs from the deprecated sync client log level, which had to be set before opening a synced realm and could not be changed.
RealmLog.level = LogLevel.TRACEval app: App = App.create(YOUR_APP_ID) val user = app.login(Credentials.emailPassword(email, password))val config = SyncConfiguration.Builder(user, setOf(Toad::class)) .initialSubscriptions { realm -> add(realm.query<Toad>("name == $0", "name value"), "sync subscription") } .build()val realm = Realm.open(config)RealmLog.level = LogLevel.INFO
By default, all logs go to a default system logger that varies by system:
Android logs to Logcat.
JVM logs to stdout.
MacOS logs to NSLog.
iOS logs to NSLog.
To diagnose and troubleshoot errors while developing your application, set the log level to debug
or trace
. For production deployments, decrease the log level for improved performance.
You can create a custom logger that implements the RealmLogger interface. You might want to customize logging to add specific tags or set specific log levels during development, testing, or debugging.
class MyLogger() : RealmLogger { override val tag: String = "CUSTOM_LOG_ENTRY" override val level: LogLevel = LogLevel.DEBUG override fun log( level: LogLevel, throwable: Throwable?, message: String?, vararg args: Any? ) { println(message) }}
Then, you can initialize your custom logger and call the RealmLog.add() function to set it as a logger for your app.
You can also remove a specific logger or remove all loggers, including the system logger.
val myCustomLogger = MyLogger()RealmLog.add(myCustomLogger)RealmLog.remove(myCustomLogger)RealmLog.removeAll()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4