dojoengine / dojo

Dojo is a toolchain for building provable games and autonomous worlds with Cairo
https://dojoengine.org
Apache License 2.0
386 stars 147 forks source link

[SOZO] Improve Sozo logging #1409

Closed glihm closed 2 months ago

glihm commented 5 months ago

Is your feature request related to a problem? Please describe. Currently, Sozo is not printing development information when RUST_LOG= is used.

Describe the solution you'd like It would be great to have a trace level that can inform a developer what's exactly happening on Sozo, to debug and understand some behavior we may encounter in Sozo.

This should be done using structured logging supported by tracing.

Example:

let name = "my_name";

trace!(name, "name added to the list");

// Let's use debug printing:
let data = [1, 2, 3];
debug!(?data, "data before update");
glihm commented 5 months ago

Integrate in the logging the env variables mentioned by @kariy here: https://github.com/dojoengine/dojo/pull/1405/files#r1446910564.

DanielUH2019 commented 4 months ago

Hi, can I take this issue?

glihm commented 4 months ago

Hi, can I take this issue?

Fore sure, assigned! Please don't hesitate if you have any questions.

DanielUH2019 commented 4 months ago

I've been exploring the code and I'm not sure I understand the problem well. Could you provide more details on what the desired behavior should be?

glihm commented 4 months ago

Hey @DanielUH2019! Sozo is lacking of logging, and a developer should be able by setting the RUST_LOG=trace to have more context on what sozo is doing. The idea of this issue is adding logs in important places where we would appreciate more information while sozo is running.

For the structured loggin, take this example: https://github.com/dojoengine/dojo/blob/68e81f65df92837cffcdd4f0b498a3b71edb55a9/bin/sozo/src/commands/test.rs#L118

This should use something like:

trace!(?project_config, "project config"); 

Like so, sozo logs can easily be parsed by other tools when running on the cloud or monitored environment.

glihm commented 4 months ago

Hey @DanielUH2019 how do you feel about this issue? Any update?

DanielUH2019 commented 4 months ago

Hey, sorry for the delay. I've been very busy this week, but I'm still committed to solving this issue. I'm not sure if I'll be able to address it before the OnlyDust Hack ends, but I'll do my best.

btirth commented 2 months ago

Hi @DanielUH2019, if you haven't started on this one can I work on it? @glihm, @tarrencev

DanielUH2019 commented 2 months ago

Hi @tirth1, I couldn't continue working on that. I'll unassign myself from the issue.

btirth commented 2 months ago

@glihm can I work on this?

glihm commented 2 months ago

@glihm can I work on this?

Hey @tirth1! For sure go ahead! Sozo is being reworked on several points currently, you may have to rebase depending on where your PR is being opened. :)

btirth commented 2 months ago

@glihm: I'm trying to explore code and documents, but I couldn't find the steps to run the project from source code.

kariy commented 2 months ago

@glihm: I'm trying to explore code and documents, but I couldn't find the steps to run the project from source code.

you can run sozo using:

cargo run --bin sozo
glihm commented 2 months ago

@glihm: I'm trying to explore code and documents, but I couldn't find the steps to run the project from source code.

We've an issue pending for tracking this missing info (#1711), the detailed setup will be covered soon.

As @kariy mentioned you will need:

  1. Install rust and use cargo, install here.
  2. Clone the Dojo repo.
  3. cargo run --bin sozo to build sozo only.
  4. cargo test -p sozo to run tests on sozo.
  5. Start a katana with katana --disable-fee (Katana binary can be run from dojo up installation or with cargo run --bin katana).
  6. Do a migration to have some sozo code being executed: cargo run --bin sozo -- migrate apply --manifest-path ./examples/spawn-and-move/Scarb.toml.