forked from mongodb/docs-realm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOCSP-31396: Kotlin - Break Logging docs out from Sync logger (mongod…
…b#2922) ## Pull Request Info - Move v1.8.0 logging API content from Sync logging page to a new Logging page. - Note Sync logging page as deprecated ### Jira - https://jira.mongodb.org/browse/DOCSP-31396 ### Staged Changes - [Logging - Kotlin SDK](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/docsp-31396-logging/sdk/kotlin/logging/#std-label-kotlin-logging) - new page - [Set the Client Log Level - Kotlin SDK](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/docsp-31396-logging/sdk/kotlin/sync/log-level/) - updated page ### Reminder Checklist If your PR modifies the docs, you might need to also update some corresponding pages. Check if completed or N/A. - [x] Create Jira ticket for corresponding docs-app-services update(s), if any - [x] Checked/updated Admin API - [x] Checked/updated CLI reference ### Review Guidelines [REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)
- Loading branch information
1 parent
dd5676e
commit 63919d9
Showing
3 changed files
with
84 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
.. _kotlin-logging: | ||
.. _kotlin-set-custom-logger: | ||
|
||
==================== | ||
Logging - Kotlin SDK | ||
==================== | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 2 | ||
:class: singlecol | ||
|
||
.. versionadded:: 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. | ||
|
||
.. note:: | ||
|
||
This 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 | ||
:ref:`kotlin-client-log-level`. | ||
|
||
Set the Realm Log Level | ||
----------------------- | ||
|
||
You can set your app's log level using the global | ||
`RealmLog <{+kotlin-local-prefix+}io.realm.kotlin.log/-realm-log/index.html>`__ | ||
singleton. You can set the ``RealmLog.level`` property to an entry in the | ||
`LogLevel <{+kotlin-local-prefix+}io.realm.kotlin.log/-log-level/index.html>`__ | ||
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 | ||
:ref:`sync client log level <kotlin-client-log-level>`, which had to be set | ||
before opening a synced realm and could not be changed. | ||
|
||
.. literalinclude:: /examples/generated/kotlin/SyncTest.snippet.set-log-level-realmlog.kt | ||
:language: kotlin | ||
|
||
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. | ||
|
||
.. include:: /includes/tip-sync-log-levels.rst | ||
|
||
Set a Custom Logger | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
You can create a custom logger that implements the | ||
`RealmLogger <{+kotlin-local-prefix+}io.realm.kotlin.log/-realm-logger/index.html>`__ | ||
interface. You might want to customize logging to add specific tags or set | ||
specific log levels during development, testing, or debugging. | ||
|
||
.. literalinclude:: /examples/generated/kotlin/SyncTest.snippet.define-custom-logger.kt | ||
:language: kotlin | ||
|
||
Then, you can initialize your custom logger and call the | ||
`RealmLog.add() <{+kotlin-local-prefix+}io.realm.kotlin.log/-realm-log/add.html>`__ | ||
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. | ||
|
||
.. literalinclude:: /examples/generated/kotlin/SyncTest.snippet.set-custom-realmlog-logger.kt | ||
:language: kotlin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters