Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ic.print as print and improve for objects #360

Open
dansteren opened this issue Apr 19, 2023 · 0 comments
Open

Expose ic.print as print and improve for objects #360

dansteren opened this issue Apr 19, 2023 · 0 comments
Assignees
Labels
developer experience speed, usability, shiny, wow-factor, customization enhancement Improves behavior of existing functionality

Comments

@dansteren
Copy link
Contributor

User Stories
As a canister developer,
I want to be able to log to std.out by calling print() in addition to ic.print,
So that I don't have to learn some new non-standard method of logging in Python.

As a canister developer,
I want to be able to log any complex objects with print(some_complex_object)
So that I don't have to wrap them in json.dump (which may not even be possible) or other stuff.

Acceptance Criteria

Given:

from kybra import Principal, Record, query, void

class User(Record):
    id: Principal
    username: str

@query
def print() -> void:
    user = {
        "id": Principal.from_str('aaaaa-aa'),
        "username": "user1"
    }
    print(message)

When calling dfx canister call my_canister some_method
Then the following is output in the terminal where the replica is running

{'id': Principal(aaaaa-aa), 'username': 'user1'}

This should look just like it does in a normal python repl.

Note
We should ideally be able to print any candid type: principals, vecs, funcs, services, results... We should determine if all that will be supported in this PR before we start.

@dansteren dansteren added enhancement Improves behavior of existing functionality developer experience speed, usability, shiny, wow-factor, customization labels Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer experience speed, usability, shiny, wow-factor, customization enhancement Improves behavior of existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants