Skip to content

Commit 1ab48ac

Browse files
committed
Allow multiple invocations
1 parent ac05a93 commit 1ab48ac

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

livekit-uniffi/generated/kotlin/uniffi/livekit_uniffi/livekit_uniffi.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,10 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
798798
if (lib.uniffi_livekit_uniffi_checksum_func_generate_token() != 29823.toShort()) {
799799
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
800800
}
801-
if (lib.uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 14091.toShort()) {
801+
if (lib.uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 28675.toShort()) {
802802
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
803803
}
804-
if (lib.uniffi_livekit_uniffi_checksum_func_log_forward_receive() != 30685.toShort()) {
804+
if (lib.uniffi_livekit_uniffi_checksum_func_log_forward_receive() != 7863.toShort()) {
805805
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
806806
}
807807
if (lib.uniffi_livekit_uniffi_checksum_func_verify_token() != 47517.toShort()) {
@@ -2003,8 +2003,8 @@ public object FfiConverterMapStringString: FfiConverterRustBuffer<Map<kotlin.Str
20032003
/**
20042004
* Bootstraps log forwarding.
20052005
*
2006-
* Call this once early in the processes's execution. Calling more
2007-
* than once will cause a panic.
2006+
* Generally, you will invoke this once early in program execution. However,
2007+
* subsequent invocations are allowed to change the log level.
20082008
20092009
*/ fun `logForwardBootstrap`(`level`: LogForwardFilter)
20102010
=
@@ -2022,8 +2022,6 @@ public object FfiConverterMapStringString: FfiConverterRustBuffer<Map<kotlin.Str
20222022
* Invoke repeatedly to receive log entries as they are produced
20232023
* until `None` is returned, indicating forwarding has ended. Clients will
20242024
* likely want to bridge this to the languages's equivalent of an asynchronous stream.
2025-
*
2026-
* If log forwarding hasn't been bootstrapped, this will panic.
20272025
20282026
*/
20292027
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")

livekit-uniffi/generated/python/livekit_uniffi.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ def _uniffi_check_api_checksums(lib):
483483
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
484484
if lib.uniffi_livekit_uniffi_checksum_func_generate_token() != 29823:
485485
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
486-
if lib.uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 14091:
486+
if lib.uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 28675:
487487
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
488-
if lib.uniffi_livekit_uniffi_checksum_func_log_forward_receive() != 30685:
488+
if lib.uniffi_livekit_uniffi_checksum_func_log_forward_receive() != 7863:
489489
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
490490
if lib.uniffi_livekit_uniffi_checksum_func_verify_token() != 47517:
491491
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
@@ -1931,8 +1931,8 @@ def log_forward_bootstrap(level: LogForwardFilter) -> None:
19311931
"""
19321932
Bootstraps log forwarding.
19331933
1934-
Call this once early in the processes's execution. Calling more
1935-
than once will cause a panic.
1934+
Generally, you will invoke this once early in program execution. However,
1935+
subsequent invocations are allowed to change the log level.
19361936
19371937
"""
19381938

@@ -1956,8 +1956,6 @@ async def log_forward_receive() -> typing.Optional[LogForwardEntry]:
19561956
until `None` is returned, indicating forwarding has ended. Clients will
19571957
likely want to bridge this to the languages's equivalent of an asynchronous stream.
19581958
1959-
If log forwarding hasn't been bootstrapped, this will panic.
1960-
19611959
"""
19621960
_uniffi_lowered_args = (
19631961
)

livekit-uniffi/generated/swift/livekit_uniffi.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,8 +1599,8 @@ public func generateToken(options: TokenOptions, credentials: ApiCredentials?)th
15991599
/**
16001600
* Bootstraps log forwarding.
16011601
*
1602-
* Call this once early in the processes's execution. Calling more
1603-
* than once will cause a panic.
1602+
* Generally, you will invoke this once early in program execution. However,
1603+
* subsequent invocations are allowed to change the log level.
16041604

16051605
*/
16061606
public func logForwardBootstrap(level: LogForwardFilter) {try! rustCall() {
@@ -1615,8 +1615,6 @@ public func logForwardBootstrap(level: LogForwardFilter) {try! rustCall() {
16151615
* Invoke repeatedly to receive log entries as they are produced
16161616
* until `None` is returned, indicating forwarding has ended. Clients will
16171617
* likely want to bridge this to the languages's equivalent of an asynchronous stream.
1618-
*
1619-
* If log forwarding hasn't been bootstrapped, this will panic.
16201618

16211619
*/
16221620
public func logForwardReceive()async -> LogForwardEntry? {
@@ -1671,10 +1669,10 @@ private let initializationResult: InitializationResult = {
16711669
if (uniffi_livekit_uniffi_checksum_func_generate_token() != 29823) {
16721670
return InitializationResult.apiChecksumMismatch
16731671
}
1674-
if (uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 14091) {
1672+
if (uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 28675) {
16751673
return InitializationResult.apiChecksumMismatch
16761674
}
1677-
if (uniffi_livekit_uniffi_checksum_func_log_forward_receive() != 30685) {
1675+
if (uniffi_livekit_uniffi_checksum_func_log_forward_receive() != 7863) {
16781676
return InitializationResult.apiChecksumMismatch
16791677
}
16801678
if (uniffi_livekit_uniffi_checksum_func_verify_token() != 47517) {

livekit-uniffi/src/log_forward.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ static LOGGER: OnceCell<Logger> = OnceCell::new();
2121

2222
/// Bootstraps log forwarding.
2323
///
24-
/// Call this once early in the processes's execution. Calling more
25-
/// than once will cause a panic.
24+
/// Generally, you will invoke this once early in program execution. However,
25+
/// subsequent invocations are allowed to change the log level.
2626
///
2727
#[uniffi::export]
2828
fn log_forward_bootstrap(level: LevelFilter) {
2929
let logger = LOGGER.get_or_init(|| Logger::new());
30-
log::set_logger(logger).expect("Log forwarding already bootstrapped");
30+
_ = log::set_logger(logger); // Returns an error if already set (ignore)
3131
log::set_max_level(level);
3232
}
3333

@@ -37,8 +37,6 @@ fn log_forward_bootstrap(level: LevelFilter) {
3737
/// until `None` is returned, indicating forwarding has ended. Clients will
3838
/// likely want to bridge this to the languages's equivalent of an asynchronous stream.
3939
///
40-
/// If log forwarding hasn't been bootstrapped, this will panic.
41-
///
4240
#[uniffi::export]
4341
async fn log_forward_receive() -> Option<LogForwardEntry> {
4442
let logger = LOGGER.get().expect("Log forwarding not bootstrapped");
@@ -76,6 +74,7 @@ pub struct LogForwardEntry {
7674
}
7775
// TODO: can we expose static strings?
7876

77+
#[derive(Debug)]
7978
struct Logger {
8079
tx: mpsc::UnboundedSender<LogForwardEntry>,
8180
rx: Mutex<mpsc::UnboundedReceiver<LogForwardEntry>>,

0 commit comments

Comments
 (0)