Debug API Reference
This page summarizes the public API exposed by rix/debug.
The documentation examples use the unified Rix facade:
#include <rix.hpp>and access Debug through:
rix.debugThe lower-level debug helpers live under:
rixlib
rixlib::debugUse the facade for application code and documentation examples.
Facade entry point
The Debug module is mounted at:
rix.debugCommon usage:
rix.debug.print("Hello", "Rix");
const auto message =
rix.debug.format("Package: {}", "rix/debug");
rix.debug.print(message);
rix.debug.inspect(message);Headers
Recommended public header:
#include <rix.hpp>Independent package header:
#include <rix/debug.hpp>Use <rix.hpp> when you want the unified facade:
rix.csv
rix.debug
rix.auth
rix.pdfUse <rix/debug.hpp> when you only need the independent debug package.
Namespace
The object-style Debug API lives in:
rixlib::debugThe simple free helpers live in:
rixlibCommon public names:
rixlib::debug::Debug
rixlib::debug::Format
rixlib::debug::Log
rixlib::debug::Inspect
rixlib::format_errorrix.debug
rix.debug exposes the public debug facade.
It provides:
rix.debug.print(...)
rix.debug.eprint(...)
rix.debug.dprint(...)
rix.debug.sprint(...)
rix.debug.format(...)
rix.debug.format.append(...)
rix.debug.format.to(...)
rix.debug.log(...)
rix.debug.log.info(...)
rix.debug.log.warn(...)
rix.debug.log.error(...)
rix.debug.inspect(...)Use it for examples, development-time output, quick diagnostics, and small tools.
For production application logs, prefer the Vix logging system.
print
template <typename... Args>
void print(const Args &...args) const;Prints values to stdout, separated by spaces, followed by a newline.
Example:
rix.debug.print("Hello", "Rix");
rix.debug.print("rows:", 3);
rix.debug.print("ready:", true);Output shape:
Hello Rix
rows: 3
ready: trueUse print for simple development output and documentation examples.
eprint
template <typename... Args>
void eprint(const Args &...args) const;Prints values to stderr.
Example:
rix.debug.eprint("error:", "something failed");Use eprint for local error output in examples and small command-line tools.
dprint
template <typename... Args>
void dprint(const Args &...args) const;Writes debug-only output.
Example:
rix.debug.dprint("debug value:", 42);Use it for messages that are only useful while developing.
sprint
template <typename... Args>
std::string sprint(const Args &...args) const;Returns the same value rendering style as print, but as a string.
Example:
const auto line =
rix.debug.sprint("rows:", 3);
rix.debug.print(line);Output:
rows: 3Use sprint when you want to build a line before printing, storing, or passing it to another API.
format
template <typename... Args>
std::string operator()(
std::string_view fmt,
const Args &...args) const;Creates a formatted string using Rix placeholder syntax.
Example:
const auto message =
rix.debug.format("Package: {}", "rix/debug");
rix.debug.print(message);Output:
Package: rix/debugformat returns a std::string.
It does not print by itself.
Automatic placeholders
Use {} to consume arguments in order:
const auto message =
rix.debug.format("{} uses {}", "Rix", "C++");Output:
Rix uses C++Each {} uses the next argument.
Explicit placeholders
Use {0}, {1}, and other numeric indexes when the position should be explicit:
const auto message =
rix.debug.format("{0} + {0} = {1}", "C++", "Vix.cpp");Output:
C++ + C++ = Vix.cppDo not mix automatic placeholders and explicit placeholders in the same format string.
Escaped braces
Use double opening braces and double closing braces when you need literal braces:
const auto message =
rix.debug.format("{{ package }} = {}", "rix/debug");Output:
{ package } = rix/debugUnsupported format specifiers
rix.debug.format intentionally supports a small placeholder syntax.
It does not support format specifiers such as:
{:>10}
{:.2f}
{:04d}Wrong:
rix.debug.format("{:.2f}", 3.14159);Use:
rix.debug.format("value: {}", 3.14159);For advanced formatting, use another formatting library or normal C++ formatting tools where appropriate.
format.append
template <typename... Args>
void append(
std::string &out,
std::string_view fmt,
const Args &...args) const;Appends formatted output to an existing string.
Example:
std::string out = "Rix: ";
rix.debug.format.append(
out,
"{}",
"debug");
rix.debug.print(out);Output:
Rix: debugUse append when building a string in steps.
format.to
template <typename... Args>
void to(
std::string &out,
std::string_view fmt,
const Args &...args) const;Replaces the destination string with formatted output.
Example:
std::string out = "old value";
rix.debug.format.to(
out,
"Package: {}",
"rix/debug");
rix.debug.print(out);Output:
Package: rix/debugThe previous content of out is cleared.
format_error
rixlib::format_errorformat_error is thrown on invalid format strings or invalid argument access.
Invalid examples:
rix.debug.format("{", "Rix");
rix.debug.format("}", "Rix");
rix.debug.format("{2}", "Rix");
rix.debug.format("{} {0}", "Rix");
rix.debug.format("{:.2f}", 3.14);Handle errors when the format string may come from outside your code:
try
{
const auto message =
rix.debug.format("{} {}", "Rix", "Debug");
rix.debug.print(message);
}
catch (const rixlib::format_error &error)
{
rix.debug.eprint("format error:", error.what());
return 1;
}log
template <typename... Args>
void operator()(
std::string_view fmt,
const Args &...args) const;Writes a debug-level formatted message.
Example:
rix.debug.log("loaded {} rows", 3);Output:
[debug] loaded 3 rowsrix.debug.log is a development helper.
For real application logging, prefer vix::log.
log.info
template <typename... Args>
void info(
std::string_view fmt,
const Args &...args) const;Writes an info-level message to stdout.
Example:
rix.debug.log.info("package {} is ready", "rix/debug");Output:
[info] package rix/debug is readylog.warn
template <typename... Args>
void warn(
std::string_view fmt,
const Args &...args) const;Writes a warning-level message to stdout.
Example:
rix.debug.log.warn("slow path: {}", "csv import");Output:
[warn] slow path: csv importlog.error
template <typename... Args>
void error(
std::string_view fmt,
const Args &...args) const;Writes an error-level message to stderr.
Example:
rix.debug.log.error("failed to open {}", "missing.csv");Output shape:
[error] failed to open missing.csvLogging recommendation
Use rix.debug.log for:
examples
small command-line demos
local diagnostics
quick package tests
development-only outputUse Vix logging for:
HTTP request logs
service startup logs
deployment diagnostics
production logs
structured application logs
runtime observabilityRule:
rix.debug.log -> development helper
vix::log -> application logginginspect
rix.debug.inspect(value);Inspects a value during development.
Example:
std::string package = "rix/debug";
rix.debug.inspect(package);Inspection is useful when you want a clearer development-time view of a value.
For normal output, use print.
For formatted messages, use format.
Complete API example
#include <rix.hpp>
#include <string>
int main()
{
rix.debug.print("Hello", "Rix");
rix.debug.eprint("stderr:", "example");
const std::string package =
rix.debug.format("Package: {}", "rix/debug");
rix.debug.print(package);
std::string line = "Rix: ";
rix.debug.format.append(
line,
"{}",
"debug");
rix.debug.print(line);
rix.debug.format.to(
line,
"module: {}",
"debug");
rix.debug.print(line);
const auto printed =
rix.debug.sprint("rows:", 3);
rix.debug.inspect(printed);
rix.debug.log.info("loaded {} APIs", 4);
return 0;
}Run:
vix run debug.cppUse with CSV
#include <rix.hpp>
int main()
{
const auto table = rix.csv.parse(
"name,language\n"
"Ada,C++\n"
"Gaspard,Vix\n");
rix.debug.print("rows:", table.size());
rix.debug.log.info("loaded {} rows", table.size());
for (const auto &row : table)
{
rix.debug.print("fields:", row.size());
}
return 0;
}Use with Auth errors
#include <rix.hpp>
int main()
{
auto auth = rix.auth.memory();
auto login = auth.login({
"ada@example.com",
"wrong-password"});
if (login.failed())
{
const auto &error = login.error();
rix.debug.eprint(
"auth error:",
rix.auth.error.to_string(error),
error.message());
return 1;
}
return 0;
}Do not print or log authentication secrets.
Avoid:
plain-text passwords
password hashes
session ids
raw token values
private keys
API tokensUse with PDF errors
#include <rix.hpp>
int main()
{
auto doc = rix.pdf.document();
auto &page = doc.add_page();
page.text(
page.x_left(),
page.y_top(),
"Hello from rix.pdf");
auto saved = rix.pdf.save(doc, "");
if (saved.failed())
{
rix.debug.eprint(
"pdf error:",
rix.pdf.error.to_string(saved.error()),
saved.error().message());
return 1;
}
rix.debug.print("created:", "example.pdf");
return 0;
}Single-file usage
For quick examples:
vix run debug.cppIf Rix is not available yet for single-file usage:
vix install -g rix/rix
vix run debug.cppProject usage
For a Vix project, add Rix:
vix add rix/rix
vix installIn vix.app:
deps = [
"rix/rix",
]A small manifest can look like this:
name = "debug-app"
type = "executable"
standard = "c++20"
output_dir = "bin"
sources = [
"src/main.cpp",
]
include_dirs = [
"include",
"src",
]
deps = [
"rix/rix",
]
packages = [
"vix",
]
links = [
"vix::vix",
]Build and run:
vix build
vix runIndependent package usage
If the project only needs Debug, install:
vix add rix/debug
vix installIn vix.app:
deps = [
"rix/debug",
]Then include:
#include <rix/debug.hpp>Use this style when you do not need the unified rix.* facade.
Lightweight facade usage
If you want the unified facade but only want Debug mounted:
#define RIX_ENABLE_DEBUG
#include <rix.hpp>
int main()
{
rix.debug.print("Hello", "Rix");
return 0;
}When at least one RIX_ENABLE_* macro is defined, only selected modules are mounted.
Common mistakes
Expecting print to replace placeholders
Wrong:
rix.debug.print("Package: {}", "rix/debug");Use format:
rix.debug.print(
rix.debug.format("Package: {}", "rix/debug"));or use the debug logger:
rix.debug.log.info("Package: {}", "rix/debug");Mixing placeholder styles
Wrong:
rix.debug.format("{} {0}", "Rix");Use automatic placeholders:
rix.debug.format("{} {}", "Rix", "Debug");or explicit placeholders:
rix.debug.format("{0} {1}", "Rix", "Debug");Using unsupported format specifiers
Wrong:
rix.debug.format("{:.2f}", 3.14159);Use simple placeholders:
rix.debug.format("value: {}", 3.14159);Using debug log as production logging
rix.debug.log is a small development helper.
For deployed Vix.cpp applications, prefer Vix logging.
Printing secrets
Do not print, inspect, or log:
plain-text passwords
password hashes
session ids
raw token values
private keys
API tokensForgetting deps
For a Vix project, do not put Rix packages in packages.
Wrong:
packages = [
"rix/rix",
]Correct:
deps = [
"rix/rix",
]deps is for Vix Registry packages.
packages is for CMake package discovery.
API summary
Main facade:
rix.debug.print(...)
rix.debug.eprint(...)
rix.debug.dprint(...)
rix.debug.sprint(...)
rix.debug.format(...)
rix.debug.format.append(...)
rix.debug.format.to(...)
rix.debug.log(...)
rix.debug.log.info(...)
rix.debug.log.warn(...)
rix.debug.log.error(...)
rix.debug.inspect(...)Main types:
rixlib::debug::Debug
rixlib::debug::Format
rixlib::debug::Log
rixlib::debug::Inspect
rixlib::format_errorRecommended include:
#include <rix.hpp>Independent include:
#include <rix/debug.hpp>What you should remember
Use print for simple output:
rix.debug.print("Hello", "Rix");Use eprint for stderr:
rix.debug.eprint("error:", "message");Use format for placeholders:
auto message = rix.debug.format("Package: {}", "rix/debug");Use sprint for print-style strings:
auto line = rix.debug.sprint("rows:", 3);Use inspect to examine values:
rix.debug.inspect(value);Use rix.debug.log only as a development helper.
Prefer Vix logging for real application logs.
For a Vix project, install Rix:
vix add rix/rix
vix installand use:
deps = [
"rix/rix",
]Next step
Continue with the PDF package.
Next: PDF