►
From YouTube: How to Use Logging to Debug a Subgraph
Description
Read more about logging with subgraphs:
https://thegraph.com/docs/en/developing/assemblyscript-api/#logging-api
-
The Graph is an indexing protocol for querying networks like Ethereum and IPFS. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.
Follow The Graph on social media
Twitter: https://twitter.com/graphprotocol
Instagram: https://instagram.com/graphprotocol
LinkedIn: https://www.linkedin.com/company/thegraph/
GitHub: https://github.com/graphprotocol
Website: https://thegraph.com
A
Hey
there
welcome
to
a
video
on
logging,
so
when
we
are
building
a
subgraph,
a
subgraph
May
encounter
some
errors
in
the
mappings
and
we
might
see
an
error
pop
up
and
it's
helpful
for
us
to
be
able
to
debug
that
subgraph
and
it's
a
little
bit
different
than
using
like
a
JavaScript
or
typescript
logging
into
the
console.
So
let's
go
through
a
few
techniques
that
are
helpful
and
see
if
we
can
debug
a
subgraph
that
I
deployed
that
intentionally
failed.
I
intentionally
made
this
to
fail.
A
So
here
we
are
check
out
this
logging
demo,
video
subgraph.
It
has
failed
syncing
and
we
see
there's
a
failure
in
the
syncing.
Let's
go
see
how
this
occurred.
Let's
go
back
to
the
smart
contract
that
I
deployed
it's
a
very
simple,
smart
contract.
This
is
an
array
emitter.
If
a
person
were
to
submit
an
array
to
this
smart
contract,
it
will
emit
this
as
a
event
and
we
get
the
values
of
that
array
and
we
get
the
entire
okay.
A
Hey
there
welcome
to
a
video
on
logging
with
our
subgraphs.
So
if
we
are
building
a
subgraph
and
at
times
we
might
come
into
an
error
in
the
mappings
and
the
logic
really
of
the
subgraph,
then
we
want
to
figure
out
where
that's
occurring,
and
so
in
this
little
walkthrough
I've
created
a
subgraph
that
has
intentionally
failed.
A
I
knew
it
was
going
to
fail
and
then
I'm
going
to
show
you
a
few
techniques
that
I
see
many
different
subgraph
developers
using
in
terms
of
the
logging
and
just
introducing
those
to
this
little
mini
Workshop
I
think
will
be
helpful
in
the
development
journey
of
a
subgraph
developer.
So
let's
go
ahead
and
go
into
the
reason
why
the
subgraph
has
failed.
A
I
created
a
smart
contract
here,
it's
called
the
array,
emitter,
smart
contract
and
it's
going
to
take
in
a
whatever
it
takes
here.
It's
going
to
emit
this
array
in
the
event
right
here
you
can
see
emit
array
events
and
the
array
will
come
out
as
an
event,
and
here
we
have
right
here.
This
is
the
event
that
has
been
emitted
and
the
subgraph
that
I've
pointed
to
this.
Smart
contract
will
Index
this
information,
but,
as
you
can
see,
the
index
number
does
not
go
to
index
678910.
A
It
just
has
a
few
numbers
in
there,
so
let's
go
ahead
and
see
why
the
subgraph
I
created
failed.
If
you
look
at
the
mappings
here,
let's
specifically
look
at
this
right
here,
where
I'm
looking
at
index
number
10
of
this
array,
which,
as
you
can
see,
was
never
emitted,
and
so
the
subgraph
itself
says
what's
going
on
and
it's
going
to
fail
because
the
index
is
out
of
range,
as
you
can
see
right
there,
it
just
didn't
work
and
that's
fine.
That's
like
great!
We
got
a
great
little
error
message
right
there.
A
It
tells
us
also.
It
happened
in
the
handle
array
event.
The
Handler
is
right
there,
so
we
can
go
in
and
see
it
happened
in
here
and
some
how
we
can
figure
that
out,
and
so
that's
great
already,
just
to
begin,
debugging
and
think.
Okay,
where
did
this
occur,
but
let's
make
this
a
little
bit
better.
Let's
see,
okay!
Well,
if
we
were
to
potentially
put
in
a
little
bit
more
information
with
logging
there,
we
go
copy
paste
this
in
here.
A
Let's
see
how
this
might
change
so,
as
you
can
see
right
here,
I
imported
the
logging
from
the
graph
TS
Library,
that's
going
to
allow
us
to
log
into
the
subgraph
log
dashboard
and
you
can
see
I've
put
in
xxx1
prior
to
the
handle
array
event.
So
it
tells
us
right
before
and
then
xxx2.
It's
entered
the
handle
array
event
and
then
these
little
bit
of
handlers
can
tell
us
more
specifically
in
the
mappings
where
this
issue
occurred,
and
so
let's
go
ahead
and
go
back
to
our
sub
graph
and
see
what
this
looks
like.
A
So,
let's
just
go
ahead
and
open
up
all
of
the
different
types
of
error
of
the
logs
and
I'm
just
going
to
type
in
XXX,
and
we
can
see
an
info.
A
little
bit
of
a
log
has
X1
and
X2,
so
we
can
see.
X3
was
never
actually
achieved
and
where
is
X2
and
X3.
We
know
right
now
that
the
error
is
right
there
and
that
little
technique
really
can
help
out
a
lot
of
developers
in
their
journey
of
saying,
okay.
A
Well,
how
do
we
figure
this
out
because
many
times
handlers
are
not
this
simple
many
times
I
pulled
up.
This
is
a
publicly
accessible
subgraph.
This
is
the
quick
swap
sub
graph
and
they
have
lots
of
different
Handler
files
right
there
and
I
just
pulled
up
any
one
of
these
I
mean
you
could
see
how
big
one
of
these
handles
are.
Handlers
are,
let's
go
look
at
the
handle
transfer,
it's
quite
large,
and
so,
if
there's
an
error
in
that
handle
transfer
and
they
get
this
alert
and
their
sub
graph.
That
just
simply
says
hey.
A
A
It
says
it
doesn't
say
where
it
is
well,
it's
very
simple
to
put
in
logs
at
different
sections
one
two,
three
four
five
and
hone
in
on
exactly
where
that
is
and
from
there
let's
go
on
to
a
little
bit
more
Advanced
Techniques,
not
necessarily
super
Advanced,
but
I
deployed
a
few
other
versions
of
the
subgraph
I
wanted
to
actually
have
one
that
went
all
the
way
through
here.
Just
so,
we
can
see
a
few
more
techniques
in
this
sub
graph
and
let's
pull
up
that
as
such.
A
No,
this
is
not
my
side
graph
I
want
to
go
to
my
sub
graph
and
we'll
go
to
main
and
we'll
stash
this.
That's
fine.
Okay,
so
I
put
in
a
few
more
logging
techniques
that
would
be
potentially
useful
for
those
out
there
who
are
watching
this
video
and
and
so
let's
go
ahead
and
look
at
the
different
types
of
logs.
A
Sometimes
we
want
to
have
different
types
of
logs
make
the
screen
a
little
bigger
for
y'all,
and
we
want
to
debug
log
an
info,
a
warning,
an
error
and
when
sub
graphs
get
a
little
bit
bigger,
it
helps
to
categorize
these,
and
you
can
see
this
information
arranged
as
such
in
this
version,
where
we
have
an
error,
worn
info
debug,
and
we
can
see
that
the
error
little
bit
that
I
put
in
there
XXX
message.
Error
is
the
same
one
as
this
one
right
there.
A
A
If
I
type
in
debug,
for
example,
you
could
just
see
what
did
I
name
it
here.
I
named
it
debug
message,
so
you
get
the
idea
XXX!
Oh
I
didn't
Tech
off
the
debug,
so
you
get
the
idea,
and
it
also
has
the
very
nice
pretty
little
pills
right
there
for
just
really
good
categorization
I
also
wanted
to
highlight
that
if
we
were
to,
if
I
was
to
deploy
this
right
here,
log
critical,
this
will
basically
stop
the
subgraph.
If
this
error
message
was
ever
hit.
A
So
that's
good
for
just
saying
we
got
to
stop
that
subgraph
and
there's
a
few
other
things
I
want
to
put
in
here
for
this
video.
While
we
are
still
here.
If
you
want
to
put
a
logging
of
the
info
in
this
format,
you
could
see
in
every
single
one
of
these
little
brackets
right
here.
This
information
will
populate
so
entity
values
to
string
we'll
go
to
the
first
one
entity
block
number
to
string
we'll
go
to
the
second
one
and
that's
going
to
be
very
helpful,
so
xxx7.
We
should
see
that
here.
A
I
believe
that
was
was
that
a
debug
type
and
that's
log.info,
so
I'll
go
to
log.info
and
let's
see
if
we
have
XXX
7
somewhere
in
there
there
it
is
okay.
So
we
got
all
of
that
big
list
values
right
in
there,
so
you
can
see
how
that
all
goes
through
a
little
bit
of
formatting
issues.
My
apologies
for
that,
but
that's
going
to
be
for
another
video.
A
This
is
in
this
entire
technique
of
just
numbering
it
and
going
through,
is
quite
helpful
and
then
also
I
wanted
to
go
through
a
loop
where,
if
you
wanted
to
go
through
this
array,
it's
a
little
bit
unique
in
that
you
have
to
go
and
do
this
formatting
of
your
looping.
You
can't
do
other
formatting.
This
is
just
required
with
assembly
script
and
you
can
Loop
through
using
this
styling
of
your
logging.
So
this
is
xxx8.
A
So
let's
look
at
xxx8
and
take
a
look
here
and
there
we
go
so
we've
looped
through
array
item
two
four
five
one.
You
can
see
how
we've
gone
through
that
just
as
such,
and
we
have
all
of
that
looped
in
so
just
different
techniques
that
you
can
use
for
logging.
I
hope
this
was
helpful
for
the
subgraph
developers
out
there
and
just
learning
how
logs
can
be
really
a
powerful
tool
in
the
subgraph
development
experience.
So
thank
you
for
joining
the
any
other
questions.