Skip to content

Commit a2bdf31

Browse files
committed
wip
1 parent 955b721 commit a2bdf31

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

bindings/ruby/ext/turso/src/setup.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use turso_sdk_kit::rsapi;
88

99
static LOGGER_CALLBACK: Lazy<Mutex<Option<Opaque<Value>>>> = Lazy::new(|| Mutex::new(None));
1010

11+
#[derive(Clone)]
1112
pub struct OwnedTursoLog {
1213
pub level: String,
1314
pub message: String,
@@ -73,7 +74,7 @@ pub fn _native_setup(ruby: &Ruby, level: String, callback: Value) -> Result<(),
7374
let mut logger_guard = LOGGER_CALLBACK.lock().unwrap();
7475
*logger_guard = Some(Opaque::from(callback));
7576

76-
let (tx, rx) = mpsc::sync_channel(2048);
77+
let (tx, rx) = mpsc::sync_channel(2048);//2048 should be fine.. we can bump if needed anyway.
7778
let mut channel_guard = LOG_CHANNEL.lock().unwrap();
7879
*channel_guard = Some((tx, Mutex::new(rx)));
7980

@@ -103,7 +104,7 @@ pub fn _native_setup(ruby: &Ruby, level: String, callback: Value) -> Result<(),
103104
pub fn _native_poll_logs(ruby: &Ruby) -> Result<(), Error> {
104105
let Ok(guard) = LOG_CHANNEL.try_lock() else { return Ok(()) };
105106
let Some((_, rx_mutex)) = &*guard else { return Ok(()) };
106-
let Ok(rx) = rx_mutex.try_lock() else { return Ok(()) };
107+
let rx = rx_mutex.lock().unwrap();
107108

108109
while let Ok(log) = rx.try_recv() {
109110
let callback_guard = LOGGER_CALLBACK.lock().unwrap();

bindings/ruby/lib/turso.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.setup(level: :info, logger: nil, &block)
2727

2828
# Start a background thread to consume logs from the native queue
2929
@log_thread = Thread.new do
30-
Thread.current.name = "turso-logger" if Thread.current.respond_to?(:name=)
30+
Thread.current.name = "turso-logger"
3131
loop do
3232
_native_poll_logs
3333
sleep 0.05

0 commit comments

Comments
 (0)