Skip to content

Commit

Permalink
Adding more anchors (and headings) to debug logs section (#2199)
Browse files Browse the repository at this point in the history
Allowing for more specific sharing of instructions
  • Loading branch information
peteruithoven authored and btkostner committed May 23, 2019
1 parent 80dd3d8 commit 949e8fe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/code/os-dev.md
Expand Up @@ -102,6 +102,8 @@ If Gala doesn't start, you can reinstall the latest stable version by running `s

## Debug logs {#debug-logs}

### Adding logs {#adding-logs}

One way to debug applications is logging information in the code. This enables seeing what code was run and what the value of variables where.

Example:
Expand All @@ -120,6 +122,8 @@ debug("Person: %s %i", name, age);

The first argument is the message which is formatted like `printf`. This means that it can include "format specifiers" which can be replaced by the remaining arguments you pass to the function. The `%s` for example can be replaced by a string, the `%i` by an integer. [More info](http://www.cplusplus.com/reference/cstdio/printf/).

### Retrieving logs {#retrieving-logs}

By default these messages are not shown. To see them you need to set the `G_MESSAGES_DEBUG` environment variable to the log domain you're interested in. Usually you'll set it to `all` to log everything. [More info](https://developer.gnome.org/glib/stable/glib-running.html).

Example:
Expand Down

0 comments on commit 949e8fe

Please sign in to comment.