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

Add transaction ID to Cadence log entries #466

Open
bartolomej opened this issue Aug 19, 2023 · 2 comments
Open

Add transaction ID to Cadence log entries #466

bartolomej opened this issue Aug 19, 2023 · 2 comments
Assignees
Labels
Feature A new user feature or a new package API Feedback

Comments

@bartolomej
Copy link
Contributor

bartolomej commented Aug 19, 2023

Issue To Be Solved

Let's say we have a transaction that uses the log() function to print something.

transaction {
  execute {
    log("Hello!")
  }
}

When that transaction is executed on the local emulator blockchain, the produced log outputs are displayed as emulator (Flow CLI) logs like so:

9:24PM INF LOG: "Hello!"
9:25PM INF LOG: "Hello!"

Problem: There is no way to tie a log entry to the transaction that emitted it. I believe this would be useful for many reasons:

  • users of Flow CLI can clearly see which logs were emitted within the same transaction (even if they can't remember the transaction ID)
    • this is especially useful in cases where each transaction emits multiple logs, which makes it harder to visually categorize them
  • developer tools using flow-emulator (e.g. Flowser, Flow playground,...) can provide a better UX
    • this would allow such tools to extract the transaction ID from each log and show it within the UI of the corresponding transaction

Suggest A Solution

We could solve this by including the transaction ID in each Cadence log entry, like so:

9:24PM INF transactionId=33d14437d6e5cb23b4d6de3b70ea754a815e2d4fac79ae85a29558da2b942aef LOG: "Hello!"
9:25PM INF transactionId=70d05c026c8c400dbd7a8627daffdd89cd3ca3d64c1fdf621275b8fd0f245833 LOG: "Hello!"

... or we could include only a subset ID to make it easier to view in the terminal:

9:24PM INF transactionId=33d14...422aef LOG: "Hello!"
9:25PM INF transactionId=70d05...45833 LOG: "Hello!"

Context

In the Flowser app, we have a logs view that shows all historic logs that ever happened (in the current emulator session). But when you execute a transaction in isolation, you usually only care about that transaction's logs and not all the historic ones.

This change would allow us to show currently executed transaction logs within that transaction's info view (related to this feature we just built: onflowser/flowser#170).

@bartolomej bartolomej added Feature A new user feature or a new package API Feedback labels Aug 19, 2023
@bluesign
Copy link
Collaborator

bluesign commented Aug 20, 2023

I think this is a nice idea, can be implemented, but maybe we can put it behind a flag. txId is pretty long and takes a lot of space ( or maybe we can put it after the message ) what do you think @sideninja ?

9:24PM INF LOG: "Hello!" transactionId=33d14437d6e5cb23b4d6de3b70ea754a815e2d4fac79ae85a29558da2b942aef 
9:25PM INF LOG: "Hello!" transactionId=70d05c026c8c400dbd7a8627daffdd89cd3ca3d64c1fdf621275b8fd0f245833 
9:24PM INF log="Hello!" transactionId=33d14437d6e5cb23b4d6de3b70ea754a815e2d4fac79ae85a29558da2b942aef 
9:25PM INF log="Hello!" transactionId=70d05c026c8c400dbd7a8627daffdd89cd3ca3d64c1fdf621275b8fd0f245833 

@sideninja
Copy link
Contributor

I would put it after the message. @chasefleming will be taking this on as his onboarding task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new user feature or a new package API Feedback
Projects
None yet
Development

No branches or pull requests

4 participants