Skip to content

Commit

Permalink
docs: Convert debugging page (#7407)
Browse files Browse the repository at this point in the history
* docs: Convert debugging page

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Delete file

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Fix links

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* docs: Delete Python debugging code example

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* docs: Remove partial

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Removed link

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Add back Python info

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Update output

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Fix sidebar

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

* Fix output

Signed-off-by: Vikram Vaswani <vikram@dagger.io>

---------

Signed-off-by: Vikram Vaswani <vikram@dagger.io>
  • Loading branch information
vikram-dagger committed May 25, 2024
1 parent 51e644d commit ed0c4d6
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
---
slug: /manuals/developer/python/924959/debugging
slug: /manuals/developer/debugging
displayed_sidebar: "current"
toc_max_heading_level: 2
title: "Debugging"
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Debugging


If you come across bugs, here are some simple debugging suggestions.

## Rerun commands with `--debug`
### Rerun commands with `--debug`

The Dagger CLI tries to keep its output concise by default. If you're running
into issues and want to debug with more detailed output, you can run any `dagger`
subcommand with the `--debug` flag to have it reveal all available information.

## Enable Python debug logs
### Access the Dagger Engine logs

The Dagger Engine runs in a dedicated Docker container and emits log messages as it works. Here's how to access these logs:

```shell
DAGGER_ENGINE_DOCKER_CONTAINER="$(docker container list --all --filter 'name=^dagger-engine-*' --format '{{.Names}}')"
docker logs $DAGGER_ENGINE_DOCKER_CONTAINER
```

### Enable SDK debug logs

:::important
The information in this section is only applicable to the Python SDK. Debug logs are not currently available for the Go and TypeScript SDKs.
:::

The Python SDK prints debugging information at various steps of the execution
flow of a module, which can be very useful in understanding what's being
Expand All @@ -28,31 +42,27 @@ external system like Sentry). But for a simple lowering of the default logging
level to [logging.DEBUG](https://docs.python.org/3/library/logging.html#logging.DEBUG),
there's a convenience function for that:

```python file=./snippets/debugging/main.py
```python file=./snippets/debugging/python/main.py
```

:::note
With the TUI, you need to use a progress output that doesn't collapse on success
like `--progress=plain` or `--debug`, otherwise it won't show in the terminal.
:::

Using the command `dagger call --debug echo --msg="hello"`, should print
something like:
Using the command `dagger call --debug echo --msg="hello"`, you should see a large number of debug messages, eventually ending with output similar to the below:

```
✔ MyModule.echo(msg: "hello"): String! 0.5s
✔ exec /runtime 0.5s
┃ [DEBUG] dagger.client._session: Configuring shared connection to GraphQL server
┃ [DEBUG] dagger.client._session: Establishing client session to GraphQL server
┃ [DEBUG] dagger.mod._module: invoke => {'parent_name': 'MyModule', 'parent_json': '{}', 'name': 'echo', 'input_args': "{'msg': 'hello'}"}
┃ [DEBUG] dagger.mod._module: resolver => MyModule.echo
┃ [DEBUG] dagger.mod._resolver: func => <Signature (msg: str) -> str>
┃ [DEBUG] dagger.mod._resolver: input args => {'msg': 'hello'}
┃ [DEBUG] dagger.mod._resolver: structured args => {'msg': 'hello'}
┃ [DEBUG] dagger.mod._module: result => 'hello'
┃ [DEBUG] dagger.mod._module: output => '"hello"'
┃ [DEBUG] dagger.client._session: Closing client session to GraphQL server
DEBUG: executing query="query{myModule{echo(msg:\"hello\")}}"
✔ connect 0.1s
✔ Debug.echo(msg: "hello"): String! 0.9s
┃ [DEBUG] dagger.mod._resolver: func => <Signature (msg: str) -> str>
┃ [DEBUG] dagger.mod._resolver: input args => {'msg': 'hello'}
┃ [DEBUG] dagger.mod._resolver: structured args => {'msg': 'hello'}
┃ [DEBUG] dagger.mod._module: result => 'hello'
┃ [DEBUG] dagger.mod._module: output => '"hello"'
┃ [DEBUG] dagger.client._session: Closing client session to GraphQL server
hello
```

The above gives a lot of useful information:
Expand All @@ -62,14 +72,3 @@ The above gives a lot of useful information:
- The user inputs before and after deserialization
- The user inputs after being converted to more complex types (structuring)
- The function's result before and after serialization

Additionally, with `--debug` the GraphQL query that the CLI produced is also shown.

## Access the Dagger Engine logs

The Dagger Engine runs in a dedicated Docker container and emits log messages as it works. Here's how to access these logs:

```shell
DAGGER_ENGINE_DOCKER_CONTAINER="$(docker container list --all --filter 'name=^dagger-engine-*' --format '{{.Names}}')"
docker logs $DAGGER_ENGINE_DOCKER_CONTAINER
```
15 changes: 0 additions & 15 deletions docs/current_docs/manuals/developer/go/924957-debugging.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion docs/current_docs/manuals/developer/go/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you're just getting started, the learning path below will give you the essent
- Streamline your module with a [constructor](./520657-constructor.mdx)
- Work with [secrets](../secrets.mdx)
- Call code from [other modules](../module-dependencies.mdx)
- [Handle errors](../error-handling.mdx) and [debug](./924957-debugging.mdx) your module
- [Handle errors](../error-handling.mdx) and [debug](../debugging.mdx) your module
- Get [IDE support](../ide-integration.mdx) for your module development

Detailed [reference documentation for the Go SDK](https://pkg.go.dev/dagger.io/dagger) is also available.
2 changes: 1 addition & 1 deletion docs/current_docs/manuals/developer/python/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you're just getting started, the learning path below will give you the essent
- Streamline your module with a [constructor](./428321-constructor.mdx)
- Work with [secrets](../secrets.mdx)
- Call code from [other modules](../module-dependencies.mdx)
- [Handle errors](../error-handling.mdx) and [debug](./924959-debugging.mdx) your module
- [Handle errors](../error-handling.mdx) and [debug](../debugging.mdx) your module
- Get [IDE support](../ide-integration.mdx) for your module development

Detailed [reference documentation for the Python SDK](https://dagger-io.readthedocs.org/) is also available.

This file was deleted.

2 changes: 1 addition & 1 deletion docs/current_docs/manuals/developer/typescript/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you're just getting started, the learning path below will give you the essent
- Streamline your module with a [constructor](./520201-constructor.mdx)
- Work with [secrets](../secrets.mdx)
- Call code from [other modules](../module-dependencies.mdx)
- [Handle errors](../error-handling.mdx) and [debug](./372032-debugging.mdx) your module
- [Handle errors](../error-handling.mdx) and [debug](../debugging.mdx) your module
- Get [IDE support](../ide-integration.mdx) for your module development

Detailed [reference documentation for the TypeScript SDK](../../../reference/typescript/modules.md) is also available.
14 changes: 0 additions & 14 deletions docs/current_docs/partials/_debugging.mdx

This file was deleted.

6 changes: 3 additions & 3 deletions docs/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@
status = 301

[[redirects]]
# redirect developer manual TypeScript visibility page to multi-language page
from = "/manuals/developer/typescript/:docid/visibility"
to = "/manuals/developer/state-functions"
# redirect developer manual language-specific debugging page to multi-language page
from = "/manuals/developer/:language/:docid/debugging"
to = "/manuals/developer/debugging"
status = 301

[[redirects]]
Expand Down
16 changes: 4 additions & 12 deletions docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ module.exports = {
"type": "doc",
"id": "manuals/developer/error-handling"
},
{
"type": "doc",
"id": "manuals/developer/debugging"
},
{
"type": "category",
"label": "Develop with Go",
Expand All @@ -388,10 +392,6 @@ module.exports = {
"type": "doc",
"id": "manuals/developer/go/constructor"
},
{
"type": "doc",
"id": "manuals/developer/go/debugging"
},
{
"type": "link",
"label": "Go SDK Reference",
Expand Down Expand Up @@ -423,10 +423,6 @@ module.exports = {
"type": "doc",
"id": "manuals/developer/python/name-overrides"
},
{
"type": "doc",
"id": "manuals/developer/python/debugging"
},
{
"type": "link",
"label": "Python SDK Reference",
Expand Down Expand Up @@ -462,10 +458,6 @@ module.exports = {
"type": "doc",
"id": "manuals/developer/typescript/aliases"
},
{
"type": "doc",
"id": "manuals/developer/typescript/debugging"
},
{
"type": "doc",
"label": "Reference",
Expand Down

0 comments on commit ed0c4d6

Please sign in to comment.