Coder Social home page Coder Social logo

Comments (11)

DavidKnott avatar DavidKnott commented on May 14, 2024

@fubuloubu Here's the format I'm currently implementing for event logging.

 MyLog: __log__({arg1: num, arg2: indexed(address)})

def example():
    MyLog(1, 0x1d805bC00b8fa3c96aE6C8FA97B2FD24B19a9801)

from vyper.

fubuloubu avatar fubuloubu commented on May 14, 2024

Does the inside of the log need to be a structure?

from vyper.

DavidKnott avatar DavidKnott commented on May 14, 2024

I'd prefer it not being a structure but this :

  MyLog: __log__(arg1: num, arg2: indexed(address))

Isn't valid python3.6 syntax.

from vyper.

fubuloubu avatar fubuloubu commented on May 14, 2024

Hmm, I guess that makes sense. It's norither a function call not a structure, so it wouldn't parse

Two questions:

  1. Is __log__ a Python object/function?
  2. Does MyLog name get represented in the output Bytecode (for searching purposes), or is it more of a type declaration e.g. this log call matches these types?

from vyper.

DavidKnott avatar DavidKnott commented on May 14, 2024
  1. No, __log__ is just a clear way to differentiate events from globals in contracts.
  2. MyLog is for type declaration (to be called later) though it will be used for searching in that it will be included in the keccak which will be used to create the event_id in the topics (topics are the part of an event that can be searched for).

from vyper.

fubuloubu avatar fubuloubu commented on May 14, 2024

Can it be a type then? e.g. MyLog: log({arg1: num, arg2: indexed(address)})

Actually, I'm using it more like public here... Could it work like public? (And create the right logger function behind the scenes?)

Further, if set as a type like that, you could set individual entries e.g. self.MyLog.arg1 = foo and self.MyLog.arg2 = bar and have it commit after all entries are set in a given contract method? (e.g. write at the end of the method)

Random thoughts...

from vyper.

DavidKnott avatar DavidKnott commented on May 14, 2024

MyLog: log({arg1: num, arg2: indexed(address)}) works, though I think using log instead of __log__ could make it harder to read as __log__ is more obvious.

We could make it so that individual entries can be set, though I don't think we should because then someone reading the code will have to do more work to figure out what's being logged.

I think both your ideas would improve writability at the detriment to readabi

from vyper.

JackieXu avatar JackieXu commented on May 14, 2024

I also prefer __log__ over log. It looks a bit out of place, but that further accentuates the difference, giving the reader feedback that it's something to look at.

I spent a bit trying to see if the syntax used by Python's typing module would work (e.g. MyLog: Log[num, indexed[address]]), but that looks a bit strange.

from vyper.

DavidKnott avatar DavidKnott commented on May 14, 2024

@JackieXu MyLog: Log[num, indexed[address]] I like this syntax, the issue is that it doesn't allow for the event inputs to be named which is important for readability.

from vyper.

DavidKnott avatar DavidKnott commented on May 14, 2024

Closing this issue now that the functionality has been added.

from vyper.

fubuloubu avatar fubuloubu commented on May 14, 2024

Nice! That's a major one!

from vyper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.