Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions crates/bindings/src/io.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/bindings/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
18 changes: 9 additions & 9 deletions crates/sdk/examples/quickstart-chat/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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));
}
}

Expand All @@ -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));
}
}

Expand All @@ -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
Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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)
}
}
Expand Down
16 changes: 8 additions & 8 deletions modules/benchmarks/src/synthetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------
Expand Down Expand Up @@ -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 ----------

Expand Down Expand Up @@ -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!");
}
}
8 changes: 4 additions & 4 deletions modules/spacetimedb-quickstart/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use spacetimedb::{println, ReducerContext, Table};
use spacetimedb::{log, ReducerContext, Table};

#[spacetimedb::table(name = person, public)]
pub struct Person {
Expand All @@ -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);
}
}
14 changes: 7 additions & 7 deletions smoketests/tests/auto_inc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
""")

Expand All @@ -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)}
"""

Expand Down Expand Up @@ -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<dyn Error>> {
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(())
}

Expand All @@ -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!");
}
""")

Expand All @@ -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)}
"""

Expand Down
14 changes: 7 additions & 7 deletions smoketests/tests/auto_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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);
}
}
"""
Expand Down
8 changes: 4 additions & 4 deletions smoketests/tests/connect_disconnect_from_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
"""

Expand Down
6 changes: 3 additions & 3 deletions smoketests/tests/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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!");
}
"""

Expand Down
Loading
Loading