Skip to content

Commit 7cfc94a

Browse files
committed
feat: add debug module to rix facade
1 parent 1b1df0f commit 7cfc94a

11 files changed

Lines changed: 330 additions & 34 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.20)
22

33
project(rix
4-
VERSION 0.1.0
4+
VERSION 0.5.0
55
DESCRIPTION "Unified Rix facade for Vix C++ projects"
66
LANGUAGES CXX
77
)
@@ -25,6 +25,7 @@ target_include_directories(rix
2525
target_link_libraries(rix
2626
INTERFACE
2727
rix::csv
28+
rix::debug
2829
)
2930

3031
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)

examples/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,21 @@ target_link_libraries(rix_basic
66
PRIVATE
77
rix::rix
88
)
9+
10+
add_executable(rix_csv_example
11+
csv.cpp
12+
)
13+
14+
target_link_libraries(rix_csv_example
15+
PRIVATE
16+
rix::rix
17+
)
18+
19+
add_executable(rix_debug_example
20+
debug.cpp
21+
)
22+
23+
target_link_libraries(rix_debug_example
24+
PRIVATE
25+
rix::rix
26+
)

examples/basic.cpp

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,14 @@
11
/**
22
* @file basic.cpp
3-
* @brief Basic example for the Rix facade.
3+
* @brief Basic example for the unified Rix facade.
44
*/
55

66
#include <rix.hpp>
77

8-
#include <iostream>
9-
#include <string>
10-
11-
namespace
12-
{
13-
void run_basic_example()
14-
{
15-
const std::string input =
16-
"name,language\n"
17-
"Ada,C++\n"
18-
"Gaspard,Vix\n";
19-
20-
const auto table = rix.csv.parse(input);
21-
22-
for (const auto &row : table)
23-
{
24-
for (const auto &field : row)
25-
{
26-
std::cout << field << ' ';
27-
}
28-
29-
std::cout << '\n';
30-
}
31-
}
32-
}
33-
348
int main()
359
{
36-
run_basic_example();
10+
rix.debug.print("Hello {}", "Rix");
11+
rix.debug.log("facade is ready");
12+
3713
return 0;
3814
}

examples/csv.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @file csv.cpp
3+
* @brief CSV example for the unified Rix facade.
4+
*/
5+
6+
#include <rix.hpp>
7+
8+
#include <string>
9+
10+
namespace
11+
{
12+
void print_table(const rixlib::csv::Table &table)
13+
{
14+
for (const auto &row : table)
15+
{
16+
for (const auto &field : row)
17+
{
18+
rix.debug.print.inline_text("{} ", field);
19+
}
20+
21+
rix.debug.print();
22+
}
23+
}
24+
}
25+
26+
int main()
27+
{
28+
const std::string input =
29+
"name,language\n"
30+
"Ada,C++\n"
31+
"Gaspard,Vix\n";
32+
33+
const auto table = rix.csv.parse(input);
34+
35+
rix.debug.log("loaded {} rows", table.size());
36+
print_table(table);
37+
38+
return 0;
39+
}

examples/debug.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @file debug.cpp
3+
* @brief Debug example for the unified Rix facade.
4+
*/
5+
6+
#include <rix.hpp>
7+
8+
#include <string>
9+
10+
int main()
11+
{
12+
rix.debug.print("Hello {}", "Rix");
13+
14+
const std::string package = rix.debug.format("Package: {}", "rix/rix");
15+
16+
rix.debug.print(package);
17+
rix.debug.log("loaded {} debug APIs", 4);
18+
rix.debug.log.warn("this is a warning: {}", "slow path");
19+
rix.debug.inspect(package);
20+
21+
return 0;
22+
}

include/rix.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* This header exposes the global `rix` object.
66
*
77
* The package `@rix/rix` is the optional unified facade for Rix packages.
8-
* Individual packages such as `@rix/csv` stay independent, but this facade
9-
* mounts them into one object-style API.
8+
* Individual packages such as `@rix/csv` and `@rix/debug` stay independent,
9+
* but this facade mounts them into one object-style API.
1010
*
1111
* Example:
1212
*
1313
* @code
1414
* auto table = rix.csv.parse("name,lang\nAda,C++\n");
15+
* rix.debug.print("loaded {} rows", table.size());
1516
* @endcode
1617
*
1718
* @author Gaspard Kirira
@@ -21,6 +22,7 @@
2122
#define RIXCPP_RIX_INCLUDE_RIX_HPP_INCLUDED
2223

2324
#include <rix/csv.hpp>
25+
#include <rix/debug.hpp>
2426

2527
namespace rixlib
2628
{
@@ -36,6 +38,11 @@ namespace rixlib
3638
* @brief CSV reader and writer component.
3739
*/
3840
rixlib::csv::Csv csv{};
41+
42+
/**
43+
* @brief Debug printing, formatting, logging, and inspection component.
44+
*/
45+
rixlib::debug::Debug debug{};
3946
};
4047
}
4148

@@ -46,6 +53,10 @@ namespace rixlib
4653
*
4754
* @code
4855
* rix.csv.parse(...)
56+
* rix.debug.print(...)
57+
* rix.debug.format(...)
58+
* rix.debug.log(...)
59+
* rix.debug.inspect(...)
4960
* @endcode
5061
*/
5162
inline constexpr rixlib::Rix rix{};

packages/debug/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# rix/debug
2+
3+
Debug printing, formatting, logging, and inspection utilities for Rix.
4+
5+
`rix/debug` is part of Rix, the userland package layer for the Vix.cpp ecosystem.
6+
7+
The source code lives in its own repository. This folder only keeps the official package entry used by the Rix umbrella repository.
8+
9+
## Install
10+
11+
```bash
12+
vix add @rix/debug
13+
vix install
14+
```
15+
16+
## Use
17+
18+
```cpp
19+
#include <rix/debug.hpp>
20+
21+
int main()
22+
{
23+
rixlib::debug::Debug debug;
24+
25+
debug.print("Hello {}", "Rix");
26+
27+
auto text = debug.format("Package: {}", "rix/debug");
28+
29+
debug.log("loaded {} rows", 3);
30+
debug.log.warn("slow request: {}ms", 120);
31+
32+
debug.inspect(text);
33+
}
34+
```
35+
36+
## Repository
37+
38+
```txt
39+
https://github.com/rixcpp/debug
40+
```
41+
42+
## Package
43+
44+
```txt
45+
rix/debug
46+
```
47+
48+
## Namespace
49+
50+
```cpp
51+
rixlib::debug
52+
```
53+
54+
## CMake target
55+
56+
```cmake
57+
rix::debug
58+
```
59+
60+
## Manifest
61+
62+
```txt
63+
packages/debug/vix.json
64+
```
65+
66+
## Role in Rix
67+
68+
Rix does not embed package source code.
69+
70+
The real library lives in:
71+
72+
```txt
73+
github.com/rixcpp/debug
74+
```
75+
76+
The Rix facade mounts this package as:
77+
78+
```cpp
79+
rix.debug.print(...)
80+
rix.debug.format(...)
81+
rix.debug.log(...)
82+
rix.debug.inspect(...)
83+
```

packages/debug/vix.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "debug",
3+
"namespace": "rix",
4+
"version": "0.1.0",
5+
"type": "header-only",
6+
"include": "include",
7+
"license": "MIT",
8+
"description": "Debug printing, formatting, logging, and inspection utilities for Rix.",
9+
"keywords": [
10+
"cpp",
11+
"debug",
12+
"print",
13+
"format",
14+
"log",
15+
"inspect",
16+
"rix",
17+
"vix"
18+
],
19+
"repository": "https://github.com/rixcpp/debug",
20+
"maintainers": [
21+
{
22+
"name": "Rix maintainers",
23+
"github": "rixcpp"
24+
}
25+
],
26+
"cmake": {
27+
"target": "rix::debug"
28+
},
29+
"deps": []
30+
}

0 commit comments

Comments
 (0)