From a5feed08b01b482442c442b65df98f32ee4ff33b Mon Sep 17 00:00:00 2001 From: Zeke Foppa <196249+bfops@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:39:24 -0800 Subject: [PATCH] Remove IO macros (#1929) Co-authored-by: Zeke Foppa --- crates/bindings/src/io.rs | 63 ------------------- crates/bindings/src/lib.rs | 2 - crates/sdk/examples/quickstart-chat/main.rs | 18 +++--- modules/benchmarks/src/synthetic.rs | 16 ++--- modules/spacetimedb-quickstart/src/lib.rs | 8 +-- smoketests/tests/auto_inc.py | 14 ++--- smoketests/tests/auto_migration.py | 14 ++--- .../tests/connect_disconnect_from_cli.py | 8 +-- smoketests/tests/describe.py | 6 +- smoketests/tests/filtering.py | 26 ++++---- smoketests/tests/module_nested_op.py | 4 +- smoketests/tests/modules.py | 20 +++--- smoketests/tests/new_user_flow.py | 6 +- smoketests/tests/panic.py | 4 +- smoketests/tests/schedule_reducer.py | 8 +-- smoketests/tests/zz_docker.py | 12 ++-- 16 files changed, 82 insertions(+), 147 deletions(-) delete mode 100644 crates/bindings/src/io.rs diff --git a/crates/bindings/src/io.rs b/crates/bindings/src/io.rs deleted file mode 100644 index 403b0eaf103..00000000000 --- a/crates/bindings/src/io.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! Defines macros for basic IO corresponding to what the standard library provides. -//! These macros include `println`, `print`, `eprintln`, `eprint`, and `dbg`. - -/// Prints the provided arguments, terminated by a newline, as an `INFO` message to the console. -#[doc(hidden)] -#[macro_export] -macro_rules! println { - ($($arg:tt)*) => ($crate::log::info!($($arg)*)) -} - -/// Prints the provided arguments as an `INFO` message to the console. -/// -/// Each print invocation generates a separate `INFO` message. -/// Unlike `std::print`, a series of `print` invocations will not result in a single unbroken line. -#[doc(hidden)] -#[macro_export] -macro_rules! print { - ($($arg:tt)*) => ($crate::log::info!($($arg)*)) -} - -/// Prints the provided arguments, terminated by a newline, as an `ERROR` message to the console. -#[doc(hidden)] -#[macro_export] -macro_rules! eprintln { - ($($arg:tt)*) => ($crate::log::error!($($arg)*)) -} - -/// Prints the provided arguments as an `ERROR` message to the console. -/// -/// Each print invocation generates a separate `ERROR` message. -/// Unlike `std::eprint`, a series of `eprint` invocations will not result in a single unbroken line. -#[doc(hidden)] -#[macro_export] -macro_rules! eprint { - ($($arg:tt)*) => ($crate::log::error!($($arg)*)) -} - -/// Functions like the standard library's `dbg!` macro -/// but prints as a `DEBUG` message to the console. -#[macro_export] -macro_rules! dbg { - // NOTE: We cannot use `concat!` to make a static string as a format argument - // of `eprintln!` because `file!` could contain a `{` or - // `$val` expression could be a block (`{ .. }`), in which case the `eprintln!` - // will be malformed. - () => { - $crate::log::debug!("[{}:{}]", file!(), line!()) - }; - ($val:expr $(,)?) => { - // Use of `match` here is intentional because it affects the lifetimes - // of temporaries - https://stackoverflow.com/a/48732525/1063961 - match $val { - tmp => { - $crate::log::debug!("{} = {:#?}", - stringify!($val), &tmp); - tmp - } - } - }; - ($($val:expr),+ $(,)?) => { - ($($crate::dbg!($val)),+,) - }; -} diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index 0c674e1d719..7228aab8c87 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -1,8 +1,6 @@ //! Provides safe abstractions around `bindings-sys` //! and re-exports `#[spacetimedb]` and `#[duration]`. -#[macro_use] -mod io; pub mod log_stopwatch; mod logger; #[cfg(feature = "rand")] diff --git a/crates/sdk/examples/quickstart-chat/main.rs b/crates/sdk/examples/quickstart-chat/main.rs index 5d5732d1bb0..bdbcfba4308 100644 --- a/crates/sdk/examples/quickstart-chat/main.rs +++ b/crates/sdk/examples/quickstart-chat/main.rs @@ -45,7 +45,7 @@ fn creds_store() -> credentials::File { /// Our `on_connect` callback: save our credentials to a file. fn on_connected(_ctx: &DbConnection, identity: Identity, token: &str) { if let Err(e) = creds_store().save(identity, token) { - eprintln!("Failed to save credentials: {:?}", e); + log::error!("Failed to save credentials: {:?}", e); } } @@ -54,7 +54,7 @@ fn on_connected(_ctx: &DbConnection, identity: Identity, token: &str) { /// Our `User::on_insert` callback: if the user is online, print a notification. fn on_user_inserted(_ctx: &EventContext, user: &User) { if user.online { - println!("User {} connected.", user_name_or_identity(user)); + log::info!("User {} connected.", user_name_or_identity(user)); } } @@ -70,17 +70,17 @@ fn user_name_or_identity(user: &User) -> String { /// print a notification about name and status changes. fn on_user_updated(_ctx: &EventContext, old: &User, new: &User) { if old.name != new.name { - println!( + log::info!( "User {} renamed to {}.", user_name_or_identity(old), user_name_or_identity(new) ); } if old.online && !new.online { - println!("User {} disconnected.", user_name_or_identity(new)); + log::info!("User {} disconnected.", user_name_or_identity(new)); } if !old.online && new.online { - println!("User {} connected.", user_name_or_identity(new)); + log::info!("User {} connected.", user_name_or_identity(new)); } } @@ -101,7 +101,7 @@ fn print_message(ctx: &EventContext, message: &Message) { .find(&message.sender) .map(|u| user_name_or_identity(&u)) .unwrap_or_else(|| "unknown".to_string()); - println!("{}: {}", sender, message.text); + log::info!("{}: {}", sender, message.text); } // ## Print message backlog @@ -126,7 +126,7 @@ fn on_name_set(ctx: &EventContext, name: &String) { .. }) = &ctx.event { - eprintln!("Failed to change name to {:?}: {}", name, err); + log::error!("Failed to change name to {:?}: {}", name, err); } } @@ -139,7 +139,7 @@ fn on_message_sent(ctx: &EventContext, text: &String) { .. }) = &ctx.event { - eprintln!("Failed to send message {:?}: {}", text, err); + log::error!("Failed to send message {:?}: {}", text, err); } } @@ -150,7 +150,7 @@ fn on_disconnected(_ctx: &DbConnection, err: Option<&anyhow::Error>) { if let Some(err) = err { panic!("Disconnected abnormally: {err}") } else { - println!("Disconnected normally."); + log::info!("Disconnected normally."); std::process::exit(0) } } diff --git a/modules/benchmarks/src/synthetic.rs b/modules/benchmarks/src/synthetic.rs index a5306966ba1..10f2999c8d7 100644 --- a/modules/benchmarks/src/synthetic.rs +++ b/modules/benchmarks/src/synthetic.rs @@ -23,7 +23,7 @@ //! Obviously more could be added... #![allow(non_camel_case_types)] #![allow(clippy::too_many_arguments)] -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; use std::hint::black_box; // ---------- schemas ---------- @@ -372,32 +372,32 @@ pub fn clear_table_btree_each_column_u32_u64_u64(_ctx: &ReducerContext) { #[spacetimedb::reducer] pub fn count_unique_0_u32_u64_str(ctx: &ReducerContext) { - println!("COUNT: {}", ctx.db.unique_0_u32_u64_str().count()); + log::info!("COUNT: {}", ctx.db.unique_0_u32_u64_str().count()); } #[spacetimedb::reducer] pub fn count_no_index_u32_u64_str(ctx: &ReducerContext) { - println!("COUNT: {}", ctx.db.no_index_u32_u64_str().count()); + log::info!("COUNT: {}", ctx.db.no_index_u32_u64_str().count()); } #[spacetimedb::reducer] pub fn count_btree_each_column_u32_u64_str(ctx: &ReducerContext) { - println!("COUNT: {}", ctx.db.btree_each_column_u32_u64_str().count()); + log::info!("COUNT: {}", ctx.db.btree_each_column_u32_u64_str().count()); } #[spacetimedb::reducer] pub fn count_unique_0_u32_u64_u64(ctx: &ReducerContext) { - println!("COUNT: {}", ctx.db.unique_0_u32_u64_u64().count()); + log::info!("COUNT: {}", ctx.db.unique_0_u32_u64_u64().count()); } #[spacetimedb::reducer] pub fn count_no_index_u32_u64_u64(ctx: &ReducerContext) { - println!("COUNT: {}", ctx.db.no_index_u32_u64_u64().count()); + log::info!("COUNT: {}", ctx.db.no_index_u32_u64_u64().count()); } #[spacetimedb::reducer] pub fn count_btree_each_column_u32_u64_u64(ctx: &ReducerContext) { - println!("COUNT: {}", ctx.db.btree_each_column_u32_u64_u64().count()); + log::info!("COUNT: {}", ctx.db.btree_each_column_u32_u64_u64().count()); } // ---------- module-specific stuff ---------- @@ -445,6 +445,6 @@ pub fn fn_with_32_args( #[spacetimedb::reducer] pub fn print_many_things(_ctx: &ReducerContext, n: u32) { for _ in 0..n { - println!("hello again!"); + log::info!("hello again!"); } } diff --git a/modules/spacetimedb-quickstart/src/lib.rs b/modules/spacetimedb-quickstart/src/lib.rs index b40d0c92a66..73fcab547a6 100644 --- a/modules/spacetimedb-quickstart/src/lib.rs +++ b/modules/spacetimedb-quickstart/src/lib.rs @@ -1,4 +1,4 @@ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person, public)] pub struct Person { @@ -17,14 +17,14 @@ pub fn add(ctx: &ReducerContext, name: String, age: u8) { #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } #[spacetimedb::reducer] pub fn list_over_age(ctx: &ReducerContext, age: u8) { for person in ctx.db.person().iter().filter(|person| person.age >= age) { - println!("{} has age {} >= {}", person.name, person.age, age); + log::info!("{} has age {} >= {}", person.name, person.age, age); } } diff --git a/smoketests/tests/auto_inc.py b/smoketests/tests/auto_inc.py index 22af3379c96..1fe4ae0c86c 100644 --- a/smoketests/tests/auto_inc.py +++ b/smoketests/tests/auto_inc.py @@ -30,9 +30,9 @@ class IntTests: #[spacetimedb::reducer] pub fn say_hello_$KEY_TY(ctx: &ReducerContext) { for person in ctx.db.person_$KEY_TY().iter() { - println!("Hello, {}:{}!", person.key_col, person.name); + log::info!("Hello, {}:{}!", person.key_col, person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """) @@ -43,7 +43,7 @@ class AutoincBasic(IntTests, Smoketest): MODULE_CODE = f""" #![allow(non_camel_case_types)] -use spacetimedb::{{println, ReducerContext, Table}}; +use spacetimedb::{{log, ReducerContext, Table}}; {"".join(autoinc1_template.substitute(KEY_TY=int_ty) for int_ty in ints)} """ @@ -73,7 +73,7 @@ def do_test_autoinc(self, int_ty): #[spacetimedb::reducer] pub fn add_new_$KEY_TY(ctx: &ReducerContext, name: String) -> Result<(), Box> { let value = ctx.db.person_$KEY_TY().try_insert(Person_$KEY_TY { key_col: 0, name })?; - println!("Assigned Value: {} -> {}", value.key_col, value.name); + log::info!("Assigned Value: {} -> {}", value.key_col, value.name); Ok(()) } @@ -86,9 +86,9 @@ def do_test_autoinc(self, int_ty): #[spacetimedb::reducer] pub fn say_hello_$KEY_TY(ctx: &ReducerContext) { for person in ctx.db.person_$KEY_TY().iter() { - println!("Hello, {}:{}!", person.key_col, person.name); + log::info!("Hello, {}:{}!", person.key_col, person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """) @@ -99,7 +99,7 @@ class AutoincUnique(IntTests, Smoketest): MODULE_CODE = f""" #![allow(non_camel_case_types)] use std::error::Error; -use spacetimedb::{{println, ReducerContext, Table}}; +use spacetimedb::{{log, ReducerContext, Table}}; {"".join(autoinc2_template.substitute(KEY_TY=int_ty) for int_ty in ints)} """ diff --git a/smoketests/tests/auto_migration.py b/smoketests/tests/auto_migration.py index bad7a3d1a8c..69ec5e33586 100644 --- a/smoketests/tests/auto_migration.py +++ b/smoketests/tests/auto_migration.py @@ -5,7 +5,7 @@ class AddTableAutoMigration(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table, SpacetimeType}; +use spacetimedb::{log, ReducerContext, Table, SpacetimeType}; #[spacetimedb::table(name = person)] pub struct Person { @@ -20,7 +20,7 @@ class AddTableAutoMigration(Smoketest): #[spacetimedb::reducer] pub fn print_persons(ctx: &ReducerContext, prefix: String) { for person in ctx.db.person().iter() { - println!("{}: {}", prefix, person.name); + log::info!("{}: {}", prefix, person.name); } } @@ -56,7 +56,7 @@ class AddTableAutoMigration(Smoketest): #[spacetimedb::reducer] pub fn print_books(ctx: &ReducerContext, prefix: String) { for book in ctx.db.book().iter() { - println!("{}: {}", prefix, book.isbn); + log::info!("{}: {}", prefix, book.isbn); } } @@ -127,7 +127,7 @@ def test_add_table_auto_migration(self): class RejectTableChanges(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -142,13 +142,13 @@ class RejectTableChanges(Smoketest): #[spacetimedb::reducer] pub fn print_persons(ctx: &ReducerContext, prefix: String) { for person in ctx.db.person().iter() { - println!("{}: {}", prefix, person.name); + log::info!("{}: {}", prefix, person.name); } } """ MODULE_CODE_UPDATED = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -164,7 +164,7 @@ class RejectTableChanges(Smoketest): #[spacetimedb::reducer] pub fn print_persons(ctx: &ReducerContext, prefix: String) { for person in ctx.db.person().iter() { - println!("{}: {}", prefix, person.name); + log::info!("{}: {}", prefix, person.name); } } """ diff --git a/smoketests/tests/connect_disconnect_from_cli.py b/smoketests/tests/connect_disconnect_from_cli.py index c56d5fc4301..dc13d8756fa 100644 --- a/smoketests/tests/connect_disconnect_from_cli.py +++ b/smoketests/tests/connect_disconnect_from_cli.py @@ -3,23 +3,23 @@ class ConnDisconnFromCli(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext}; +use spacetimedb::{log, ReducerContext}; #[spacetimedb::reducer(client_connected)] pub fn connected(_ctx: &ReducerContext) { - println!("_connect called"); + log::info!("_connect called"); panic!("Panic on connect"); } #[spacetimedb::reducer(client_disconnected)] pub fn disconnected(_ctx: &ReducerContext) { - println!("disconnect called"); + log::info!("disconnect called"); panic!("Panic on disconnect"); } #[spacetimedb::reducer] pub fn say_hello(_ctx: &ReducerContext) { - println!("Hello, World!"); + log::info!("Hello, World!"); } """ diff --git a/smoketests/tests/describe.py b/smoketests/tests/describe.py index 30a5a07317c..16aef32e055 100644 --- a/smoketests/tests/describe.py +++ b/smoketests/tests/describe.py @@ -2,7 +2,7 @@ class ModuleDescription(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -17,9 +17,9 @@ class ModuleDescription(Smoketest): #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """ diff --git a/smoketests/tests/filtering.py b/smoketests/tests/filtering.py index ab5fbef5d12..0951007fd4a 100644 --- a/smoketests/tests/filtering.py +++ b/smoketests/tests/filtering.py @@ -2,7 +2,7 @@ class Filtering(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, Identity, ReducerContext, Table}; +use spacetimedb::{log, Identity, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -25,7 +25,7 @@ class Filtering(Smoketest): match ctx.db.person().try_insert(Person { id, name: name.clone(), nick: nick.clone()}) { Ok(_) => {}, Err(_) => { - println!("UNIQUE CONSTRAINT VIOLATION ERROR: id {}: {}", id, name) + log::info!("UNIQUE CONSTRAINT VIOLATION ERROR: id {}: {}", id, name) } } } @@ -38,23 +38,23 @@ class Filtering(Smoketest): #[spacetimedb::reducer] pub fn find_person(ctx: &ReducerContext, id: i32) { match ctx.db.person().id().find(&id) { - Some(person) => println!("UNIQUE FOUND: id {}: {}", id, person.name), - None => println!("UNIQUE NOT FOUND: id {}", id), + Some(person) => log::info!("UNIQUE FOUND: id {}: {}", id, person.name), + None => log::info!("UNIQUE NOT FOUND: id {}", id), } } #[spacetimedb::reducer] pub fn find_person_by_name(ctx: &ReducerContext, name: String) { for person in ctx.db.person().iter().filter(|p| p.name == name) { - println!("UNIQUE FOUND: id {}: {} aka {}", person.id, person.name, person.nick); + log::info!("UNIQUE FOUND: id {}: {} aka {}", person.id, person.name, person.nick); } } #[spacetimedb::reducer] pub fn find_person_by_nick(ctx: &ReducerContext, nick: String) { match ctx.db.person().nick().find(&nick) { - Some(person) => println!("UNIQUE FOUND: id {}: {}", person.id, person.nick), - None => println!("UNIQUE NOT FOUND: nick {}", nick), + Some(person) => log::info!("UNIQUE FOUND: id {}: {}", person.id, person.nick), + None => log::info!("UNIQUE NOT FOUND: nick {}", nick), } } @@ -74,21 +74,21 @@ class Filtering(Smoketest): #[spacetimedb::reducer] pub fn find_nonunique_person(ctx: &ReducerContext, id: i32) { for person in ctx.db.nonunique_person().id().filter(&id) { - println!("NONUNIQUE FOUND: id {}: {}", id, person.name) + log::info!("NONUNIQUE FOUND: id {}: {}", id, person.name) } } #[spacetimedb::reducer] pub fn find_nonunique_humans(ctx: &ReducerContext) { for person in ctx.db.nonunique_person().iter().filter(|p| p.is_human) { - println!("HUMAN FOUND: id {}: {}", person.id, person.name); + log::info!("HUMAN FOUND: id {}: {}", person.id, person.name); } } #[spacetimedb::reducer] pub fn find_nonunique_non_humans(ctx: &ReducerContext) { for person in ctx.db.nonunique_person().iter().filter(|p| !p.is_human) { - println!("NON-HUMAN FOUND: id {}: {}", person.id, person.name); + log::info!("NON-HUMAN FOUND: id {}: {}", person.id, person.name); } } @@ -116,8 +116,8 @@ class Filtering(Smoketest): fn find_identified_person(ctx: &ReducerContext, id_number: u64) { let identity = identify(id_number); match ctx.db.identified_person().identity().find(&identity) { - Some(person) => println!("IDENTIFIED FOUND: {}", person.name), - None => println!("IDENTIFIED NOT FOUND"), + Some(person) => log::info!("IDENTIFIED FOUND: {}", person.name), + None => log::info!("IDENTIFIED NOT FOUND"), } } @@ -144,7 +144,7 @@ class Filtering(Smoketest): #[spacetimedb::reducer] fn find_indexed_people(ctx: &ReducerContext, surname: String) { for person in ctx.db.indexed_person().surname().filter(&surname) { - println!("INDEXED FOUND: id {}: {}, {}", person.id, person.surname, person.given_name); + log::info!("INDEXED FOUND: id {}: {}, {}", person.id, person.surname, person.given_name); } } """ diff --git a/smoketests/tests/module_nested_op.py b/smoketests/tests/module_nested_op.py index bf2fa1ef88e..999026eb7ae 100644 --- a/smoketests/tests/module_nested_op.py +++ b/smoketests/tests/module_nested_op.py @@ -2,7 +2,7 @@ class ModuleNestedOp(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = account)] pub struct Account { @@ -38,7 +38,7 @@ class ModuleNestedOp(Smoketest): for friendship in ctx.db.friends().iter() { let friend1 = ctx.db.account().id().find(&friendship.friend_1).unwrap(); let friend2 = ctx.db.account().id().find(&friendship.friend_2).unwrap(); - println!("{} is friends with {}", friend1.name, friend2.name); + log::info!("{} is friends with {}", friend1.name, friend2.name); } } """ diff --git a/smoketests/tests/modules.py b/smoketests/tests/modules.py index 203a6e2a16c..37d42e9ee26 100644 --- a/smoketests/tests/modules.py +++ b/smoketests/tests/modules.py @@ -7,7 +7,7 @@ class UpdateModule(Smoketest): AUTOPUBLISH = False MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -25,9 +25,9 @@ class UpdateModule(Smoketest): #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """ MODULE_CODE_B = """ @@ -42,7 +42,7 @@ class UpdateModule(Smoketest): """ MODULE_CODE_C = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -59,7 +59,7 @@ class UpdateModule(Smoketest): #[spacetimedb::reducer] pub fn are_we_updated_yet(ctx: &ReducerContext) { - println!("MODULE UPDATED"); + log::info!("MODULE UPDATED"); } """ @@ -102,7 +102,7 @@ def test_module_update(self): class UploadModule1(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -117,9 +117,9 @@ class UploadModule1(Smoketest): #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """ @@ -139,7 +139,7 @@ def test_upload_module_1(self): class UploadModule2(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, duration, ReducerContext, Table, Timestamp}; +use spacetimedb::{log, duration, ReducerContext, Table, Timestamp}; #[spacetimedb::table(name = scheduled_message, public, scheduled(my_repeating_reducer))] @@ -159,7 +159,7 @@ class UploadModule2(Smoketest): #[spacetimedb::reducer] pub fn my_repeating_reducer(_ctx: &ReducerContext, arg: ScheduledMessage) { - println!("Invoked: ts={:?}, delta={:?}", Timestamp::now(), arg.prev.elapsed()); + log::info!("Invoked: ts={:?}, delta={:?}", Timestamp::now(), arg.prev.elapsed()); } """ def test_upload_module_2(self): diff --git a/smoketests/tests/new_user_flow.py b/smoketests/tests/new_user_flow.py index dcfd7f5bb8f..345dcb77bca 100644 --- a/smoketests/tests/new_user_flow.py +++ b/smoketests/tests/new_user_flow.py @@ -4,7 +4,7 @@ class NewUserFlow(Smoketest): AUTOPUBLISH = False MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person)] pub struct Person { @@ -19,9 +19,9 @@ class NewUserFlow(Smoketest): #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """ diff --git a/smoketests/tests/panic.py b/smoketests/tests/panic.py index a8f860ec2fc..87aa482d192 100644 --- a/smoketests/tests/panic.py +++ b/smoketests/tests/panic.py @@ -2,7 +2,7 @@ class Panic(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, ReducerContext}; +use spacetimedb::{log, ReducerContext}; use std::cell::RefCell; thread_local! { @@ -18,7 +18,7 @@ class Panic(Smoketest): #[spacetimedb::reducer] fn second(_ctx: &ReducerContext) { X.with(|x| *x.borrow_mut()); - println!("Test Passed"); + log::info!("Test Passed"); } """ diff --git a/smoketests/tests/schedule_reducer.py b/smoketests/tests/schedule_reducer.py index 01f6e57efdf..1e1016ac51d 100644 --- a/smoketests/tests/schedule_reducer.py +++ b/smoketests/tests/schedule_reducer.py @@ -4,7 +4,7 @@ class CancelReducer(Smoketest): MODULE_CODE = """ -use spacetimedb::{duration, println, ReducerContext, Table}; +use spacetimedb::{duration, log, ReducerContext, Table}; #[spacetimedb::reducer(init)] fn init(ctx: &ReducerContext) { @@ -40,7 +40,7 @@ class CancelReducer(Smoketest): #[spacetimedb::reducer] fn reducer(_ctx: &ReducerContext, args: ScheduledReducerArgs) { - println!("the reducer ran: {}", args.num); + log::info!("the reducer ran: {}", args.num); } """ @@ -54,7 +54,7 @@ def test_cancel_reducer(self): class SubscribeScheduledTable(Smoketest): MODULE_CODE = """ -use spacetimedb::{println, duration, ReducerContext, Table, Timestamp}; +use spacetimedb::{log, duration, ReducerContext, Table, Timestamp}; #[spacetimedb::table(name = scheduled_table, public, scheduled(my_reducer))] pub struct ScheduledTable { @@ -78,7 +78,7 @@ class SubscribeScheduledTable(Smoketest): #[spacetimedb::reducer] pub fn my_reducer(_ctx: &ReducerContext, arg: ScheduledTable) { - println!("Invoked: ts={:?}, delta={:?}", Timestamp::now(), arg.prev.elapsed()); + log::info!("Invoked: ts={:?}, delta={:?}", Timestamp::now(), arg.prev.elapsed()); } """ def test_scheduled_table_subscription(self): diff --git a/smoketests/tests/zz_docker.py b/smoketests/tests/zz_docker.py index a5d236cda67..58ded478d0c 100644 --- a/smoketests/tests/zz_docker.py +++ b/smoketests/tests/zz_docker.py @@ -45,7 +45,7 @@ class DockerRestartModule(Smoketest): # Note: creating indexes on `Person` # exercises more possible failure cases when replaying after restart MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person, index(name = name_idx, btree(columns = [name])))] pub struct Person { @@ -63,9 +63,9 @@ class DockerRestartModule(Smoketest): #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """ @@ -91,7 +91,7 @@ class DockerRestartSql(Smoketest): # Note: creating indexes on `Person` # exercises more possible failure cases when replaying after restart MODULE_CODE = """ -use spacetimedb::{println, ReducerContext, Table}; +use spacetimedb::{log, ReducerContext, Table}; #[spacetimedb::table(name = person, index(name = name_idx, btree(columns = [name])))] pub struct Person { @@ -109,9 +109,9 @@ class DockerRestartSql(Smoketest): #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { - println!("Hello, {}!", person.name); + log::info!("Hello, {}!", person.name); } - println!("Hello, World!"); + log::info!("Hello, World!"); } """