github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/stdlibs/std/emit_event.gno (about)

     1  package std
     2  
     3  // Emit is a function that constructs a gnoEvent with a specified type and attributes.
     4  // It then forwards this event to the event logger. Each emitted event carries metadata
     5  // such as the event type, the initializing realm, and the provided attributes.
     6  //
     7  // The function takes type and attribute strings. typ (or type) is an arbitrary string that represents
     8  // the type of the event. It plays a role of indexing what kind of event occurred. For example,
     9  // a name like "Foo" or "Bar" can be used to indicating the purpose (nature) of the event.
    10  //
    11  // And the attrs (attributes) accepts an even number of strings and sets them as key-value pairs
    12  // according to the order they are passed. For example, if the attr strings "key1", "value1" are
    13  // passed in, the key is set to "key1" and the value is set to "value1".
    14  //
    15  // The event is dispatched to the EventLogger, which resides in the tm2/pkg/sdk/events.go file.
    16  //
    17  // For more details about the GnoEvent data structure, refer to its definition in the emit_event.go file.
    18  func Emit(typ string, attrs ...string) { emit(typ, attrs) }
    19  func emit(typ string, attrs []string)