GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - vixcpp/utils: Core utility library for Vix (logging, validation, env, time, UUID).

BranchesTags
Open more actions menu

Latest commit

 

History

136 Commits
136 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
cmake
cmake
 
 
examples
examples
 
 
include/vix/utils
include/vix/utils
 
 
scripts
scripts
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CMakeLists.txt
CMakeLists.txt
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
vix.json
vix.json
 
 

Repository files navigation

🧩 Vix.cpp β€” Utils Module

C++ License Status spdlog

vix.cpp/utils β€” Foundational utility layer for the Vix.cpp framework. Includes environment management, logging, validation, UUIDs, timestamps, and build metadata.


πŸš€ Overview

The Utils module provides lightweight, reusable helpers used throughout Vix.cpp and standalone C++ apps. It is designed to simplify configuration, logging, and validation with zero runtime dependencies beyond spdlog.


βš™οΈ Features

  • 🧩 Env β€” Retrieve typed environment variables with defaults (env_or, env_bool, env_int).
  • ⏰ Time β€” Get current timestamps in ISO-8601, RFC-1123, or epoch milliseconds.
  • πŸͺͺ UUID β€” Generate RFC 4122–compliant UUIDv4 strings.
  • 🧱 Version β€” Access framework version & build metadata.
  • 🧾 Logger β€” Thread-safe, async, and colorized logging system.
  • πŸ§ͺ Validation β€” Schema-based map validation for user input.

🧰 Quick Example

#include <vix/utils/Env.hpp>
#include <vix/utils/Time.hpp>
#include <vix/utils/UUID.hpp>
#include <vix/utils/Version.hpp>
#include <iostream>
using namespace vix::utils;

int main() {
    std::cout << "version=" << version() << "\n";
    std::cout << "build_info=" << build_info() << "\n";
    std::cout << "APP_ENV=" << env_or("APP_ENV", "dev") << "\n";
    std::cout << "uuid4=" << uuid4() << "\n";
}

Output

version=0.2.0
build_info=v0.2.0 (abcdef1, Oct 10 2025)
APP_ENV=dev
uuid4=550e8400-e29b-41d4-a716-446655440000

🧠 Logging Example

#include <vix/utils/Logger.hpp>
#include <vix/utils/Env.hpp>
#include <vix/utils/UUID.hpp>
using namespace vix::utils;
using vix::Logger;

int main() {
    auto &log = Logger::getInstance();
    log.setAsync(env_bool("VIX_LOG_ASYNC", true));
    log.setPattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v");
    log.setLevel(Logger::Level::INFO);

    Logger::Context cx;
    cx.request_id = uuid4();
    cx.module = "utils_demo";
    cx.fields["env"] = env_or("APP_ENV", "dev");
    log.setContext(cx);

    log.log(Logger::Level::INFO, "Hello from utils!");
}

Sample Output

[2025-10-10 19:45:12.891] [info] Hello from utils/log_demo
[2025-10-10 19:45:12.891] [debug] Debug enabled = true
[2025-10-10 19:45:12.892] [info] Boot args | port=8080 async=true
[2025-10-10 19:45:12.892] [warn] This is a warning

πŸ§ͺ Validation Example

#include <vix/utils/Validation.hpp>
#include <vix/utils/Logger.hpp>
#include <unordered_map>
using namespace vix::utils;
using vix::Logger;

int main() {
    std::unordered_map<std::string, std::string> data{
        {"name", "Gaspard"}, {"age", "18"}, {"email", "[email protected]"}};

    Schema sch{
        {"name", required("Name")},
        {"age", num_range(1, 150, "Age")},
        {"email", match(R"(^[^@\s]+@[^@\s]+\.[^@\s]+$)", "Email")}};

    auto &log = Logger::getInstance();
    const auto r = validate_map(data, sch);

    if (r.is_ok())
        log.log(Logger::Level::INFO, "Validation OK");
    else {
        log.log(Logger::Level::ERROR, "Validation FAILED :");
        for (auto &kv : r.error())
            log.log(Logger::Level::ERROR, " - {} -> {}", kv.first, kv.second);
    }
}

Output

[2025-10-10 19:04:12.512] [info] Validation OK

🧱 Components

Header Description
Env.hpp Environment variable access helpers
Time.hpp Time and date utilities
UUID.hpp RFC 4122 UUIDv4 generator
Version.hpp Build metadata and version info
Logger.hpp Thread-safe async logger (spdlog-based)
Validation.hpp Declarative schema validation

πŸ—οΈ Build & Installation

Build standalone

git clone https://github.com/vixcpp/utils.git
cd utils
cmake -B build -DCMAKE_BUILD_TYPE=Release
# and examples
cmake -S . -B build -DVIX_UTILS_BUILD_EXAMPLES=ON

cmake --build build -j$(nproc)

Build as part of Vix.cpp umbrella

cd vixcpp/vix
cmake -B build -S .
cmake --build build -j$(nproc)

🧾 License

MIT License Β© Gaspard Kirira See LICENSE for details.

About

Core utility library for Vix (logging, validation, env, time, UUID).

vixcpp.com

Topics

chalkchalk-clienvloggerruntimevalidationvalidation-errorvixvix-clivix-fameworkvix-runtimevix-utilsvixcpp

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.