RealmLog

object RealmLog

Global logger class used by all Realm components.

By default all logs will go to a default system logger that will depend on the system. See addDefaultSystemLogger for more details.

Custom loggers can be added by registering a class implementing RealmLogger using add.

When logging messages, it it possible to use a subset of String format options as known from Java. Only %s, %d and %f are supported. See https://stackoverflow.com/a/64499248/1389357 and https://youtrack.jetbrains.com/issue/KT-25506 for more information.

Functions

Link copied to clipboard
fun add(logger: RealmLogger)

Add a logger that will be notified on log events that are equal to or exceed the currently configured level.

Link copied to clipboard

Adds a default system logger. Where it report log events will depend on the system:

Link copied to clipboard
fun getLevel(category: LogCategory = LogCategory.Realm): LogLevel

Gets the current log level of a log category.

Link copied to clipboard
fun remove(logger: RealmLogger): Boolean

Removes the given logger if possible.

Link copied to clipboard

Removes all loggers, including the default system logger. The default logger can be re-added by calling addDefaultSystemLogger again.

Link copied to clipboard
fun setLevel(level: LogLevel, category: LogCategory = LogCategory.Realm)

Sets the log level of a log category. By setting the log level of a category all its subcategories would also be updated to match its level.