> For the complete documentation index, see [llms.txt](https://kvision.gitbook.io/kvision-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kvision.gitbook.io/kvision-guide/1.-getting-started-1/debugging.md).

# Debugging

You can easily debug KVision applications in most modern browsers (e.g. Chrome or Firefox), which support source maps generated by Kotlin/JS compiler. Source maps allow you to see Kotlin source code in the browser "Sources" panel. You can see line numbers, step through your code, set breakpoints and watch variable values just like with plain JavaScript.

You can also debug KVision application directly in IntelliJ IDEA Ultimate by creating new "JavaScript Debug" configuration pointing to <http://localhost:3000> url.

{% hint style="info" %}
Note: Source maps are disabled by default in all KVision template projects, because the development cycle (hot reload) is a lot faster without them. To enable source maps you need to remove line `sourceMaps = false` from your `build.gradle.kts` file and remove line `config.devtool = 'eval-cheap-source-map'` from `webpack.config.d/webpack.js` file.
{% endhint %}

### Console.log

Some UI interactions may be tricky to handle with a debugger, and so being able to fall back to console logging is useful. We find it useful to create a debug function, which is turned on and off with a global boolean.

```kotlin
const val DEBUG = true  // in your App class

...

    fun debug(s: String, color: LogType? = null) {
        if (DEBUG) {
            console.log("%c $s", when (color) {
                null -> ""
                LogType.EVENT -> "background: #FF0; color: #000000"
                LogType.ROUTING -> "background: #09F; color: #000000"
                LogType. ... -> "background: #E1FDD2; color: #000000"
            })
        }
    }
        
    enum class LogType {
      EVENT,
      ROUTING,
      ...
    }
    
...

   debug("user hovered element $element", LogType.Event)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://kvision.gitbook.io/kvision-guide/1.-getting-started-1/debugging.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
