From 4f26a43fda9380ddedc754fa2e7a01226bc242a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Thu, 28 May 2026 14:03:24 +0200 Subject: [PATCH] docs(react-native): add logging documentation --- docs.json | 1 + runtimes/logging.mdx | 3 +- runtimes/react-native/logging.mdx | 49 +++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 runtimes/react-native/logging.mdx diff --git a/docs.json b/docs.json index c17ab8b3..706ccdd4 100644 --- a/docs.json +++ b/docs.json @@ -602,6 +602,7 @@ "runtimes/react-native/fonts", "runtimes/react-native/caching-a-rive-file", "runtimes/react-native/playing-audio", + "runtimes/react-native/logging", { "group": "Legacy Features", "pages": [ diff --git a/runtimes/logging.mdx b/runtimes/logging.mdx index 56ee1734..af00c704 100644 --- a/runtimes/logging.mdx +++ b/runtimes/logging.mdx @@ -12,6 +12,7 @@ Select your runtime below to see the relevant guide. \ No newline at end of file diff --git a/runtimes/react-native/logging.mdx b/runtimes/react-native/logging.mdx new file mode 100644 index 00000000..31b2cd7c --- /dev/null +++ b/runtimes/react-native/logging.mdx @@ -0,0 +1,49 @@ +--- +title: 'Logging' +description: 'Debug logging for the Rive React Native runtime' +--- + +import Overview from '/snippets/runtimes/logging/overview.mdx' + + + +The React Native runtime forwards all native Rive logs to the JS console by default. Warnings and errors are shown; debug and info logs are suppressed unless you lower the log level. + +## Log Levels + +Set the minimum log level with `setLogLevel`. Messages below this level are suppressed. + +```ts +import { RiveLog } from '@rive-app/react-native'; + +// Show all logs (debug, info, warn, error) +RiveLog.setLogLevel('debug'); + +// Only warnings and errors (the default) +RiveLog.setLogLevel('warn'); + +// Only errors +RiveLog.setLogLevel('error'); +``` + +Available levels (from most to least verbose): `debug`, `info`, `warn`, `error`. + +## Custom Log Handler + +By default, logs are routed to `console.log` / `console.warn` / `console.error` with a `[Rive/]` prefix. You can replace this with your own handler: + +```ts +import { RiveLog } from '@rive-app/react-native'; + +RiveLog.setHandler((level, tag, message) => { + // level: 'debug' | 'info' | 'warn' | 'error' + // tag: e.g. 'Deprecation', 'RiveView', 'ViewModelInstance', 'Worker', 'File', etc. + myLogger.log(`[Rive/${tag}] ${message}`, level); +}); +``` + +To restore the default handler: + +```ts +RiveLog.resetHandler(); +```