This page was generated from the source of RoboHub. Edit the source, not this page.
Logging
One logging policy for every application: the level, the format and the file
are chosen on the application's settings page and applied to everything the
program logs, its included modules among them.
How an application uses it
Add logging to deps (it brings settings and forms, and the toolchain's
rho-log component) and include it. The module needs no host hooks.
- Call
log_config_apply(app)once at startup. It reads the stored settings and
hands them to the host'slogemitport, which writes the records. Modules
that log throughrho.loginherit the same level, format and file. - Show
log_settings_form(app, action, locale)where the application keeps its
settings, and save the posted form withlog_settings_save(app, body), which
checks the CSRF field, validates and stores the values, and applies them at
once. Applications that includeappshellget both as its Logging tab.
Settings
Kept in the application's settings store (see settings/index):
| Key | Default | What it is |
|---|---|---|
log.level | info | trace, debug, info, warn, error or fatal |
log.format | text | text for a terminal, json for a collector |
log.file | see below | The application's own log file |
log.max_bytes | 5242880 | The file is rotated before it grows past this size |
log.keep | 5 | How many rotated files are kept |
log.stderr | 1 | 1 also writes records to standard error, so journald sees them; 0 does not |
The default file is under the user's state directory, which is created when
needed:
$XDG_STATE_HOME/robohub/<app>/app.log
~/.local/state/robohub/<app>/app.log # when XDG_STATE_HOME is unset
log_file_in_settings_file(path, app) reads another application's log file from
its settings file; the keeper uses it to show each application's log.
Environment
The host reads RHO_LOG_LEVEL, RHO_LOG_FORMAT, RHO_LOG_FILE,
RHO_LOG_MAX_BYTES, RHO_LOG_KEEP and RHO_LOG_STDERR when the program
starts. They are for tests and operators; log_config_apply sets the stored
settings on top of them.
Reference
Generated from the module's manifest and sources when this site was built.
Exports — what an application may call (provides.exports, imported as robohub.logging):
log_config_applylog_settings_formlog_settings_savelog_file_in_settings_filelog_settings_field_defs
Release history
All notable changes to the logging module are recorded here, one section per release.
[0.2.0] - 2026-11-12
The module publishes its interface: it is imported as robohub.logging, and exports log_config_apply, log_settings_form, log_settings_save, log_file_in_settings_file. Everything else in it is its own, so an application that imports it cannot reach its helpers, and they never collide with the application's own names. Including it by name still works and is reported with the import to use instead.
It imports robohub.settings and robohub.forms, which it uses and declares, instead of relying on whoever includes it to have included them first.
[0.2.1] - 2026-11-12
The module builds on its own: it declares the runtime functions it calls rather than relying on the application that includes it.
[0.2.2] - 2026-11-14
Trimming, URL escapes, form fields and decimals come from the toolchain (rho 0.7.0: str_trim, str_url_encode/str_url_decode, form_field, milli_*) rather than this module's own copy, the same on both backends. Needs rho 0.7.0.
[0.2.3] - 2026-11-14
log_settings_field_defs is exported: an application that draws the logging fields inside its own settings form uses it, and a build said it was not promised.