Logging

Sometimes, the information available statically, just by reading the HTML, may not be enough, and you may need to peek at the runtime value of an important variable.

With a well-designed API, such situations should be rare. But the real world is messy, and they cannot be avoided entirely.

This is where the dedicated log attribute comes in.

Most of the time, it does nothing and is generally harmless to add, even to every single element. However, it is still a debugging flag and, from a purely aesthetic point of view, should not be left enabled in production.

All it ever does is log information to the JavaScript console that the element deems important at a particular moment in time.

Info

Currently, this attribute only logs event objects in the presence of an event: modifier, right before performing the matching for it. However, the log attribute itself is meant to be general-purpose, and its functionality may be extended in the future.


1
2
3
4
5
6
7
8
9
<h4 class="mt0">Type in the field and watch events appear in the console.</h4>

<input
  type="text"
  class="input"
  on:keyup="logTest"
  event:keyup
  log
>
https://www.log-example.com/