Log to console / error window? I'm trying to get this code working

{% if article_id is defined %}
    {% set entry = craft.entries.id(article_id).first() %}
{% endif %}


The code itself is unimportant, what's relevant is that I'm currently working outside of the context where I would rendering an article. This particular code happens to be broken, and I would like to fix it via inspecting {{ article_id }}. Except I can't, because:

Template Error

A template that extends another one cannot have a body.

---

{% extends "_base" %}

{% if article_id is defined %}
    {% set entry = craft.entries.id(article_id).first() %}
    {{ article_id }}
{% endif %}


Now there's a variety of ways that I could solve this issue, but I'm wondering what's the best option. Ideally it would be something like {{ craft.log(article_id) }} - ie. a function would still produce the Template Error, but at also let me see the value / other information about article_id (either in the error window, or on the javascript console log).

How should I implement the logging behavior that I'm looking for?
If you have devMode enabled, then you have access to Twig's dump method that lets you inspect variables.

{{ dump(article_id) }}


Or, if you're feeling more adventurous, there is a debugging library called Kint that there is a Craft plugin for to help debug templates.