← Winnitude! Search  ·  Reader Mode (857 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 44 LINKS

GitHub - vixcpp/log: Structured logging system.

Repository navigation

log
Public

About

Structured logging system.

Resources

Readme MIT license Activity Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks Report repository
Branches

Tags
Go to Branches page Go to Tags page

Latest commit

 

History


27 Commits
View commit history for this file.

Folders and files

Name Name Last commit message Last commit date
.github/ workflows .github/ workflows    
cmake cmake    
examples examples    
include/ vix/ log include/ vix/ log    
src src    
test test    
.gitignore .gitignore    
CMakeLists.txt CMakeLists.txt    
LICENSE LICENSE    
README.md README.md    
vix.json vix.json    

Repository files navigation

Vix Log

The log module provides a clean, stable, and high-level logging API for Vix applications.

It owns the canonical Vix logging implementation, exposing a consistent and developer-friendly interface while reusing a powerful logging backend.

Philosophy

Logging in Vix follows strict principles:

  • No duplication of logging engines
  • Simple public API (vix::log)
  • Structured logging by default
  • Explicit configuration
  • Thread-local context support
  • High performance (delegated to utils)

The module is designed to be:

  • easy to use
  • easy to integrate
  • stable across versions
  • consistent across all Vix modules

Architecture

vix::log::Logger   → logging engine
vix::log           → public logging capability

The log module does not implement logging itself. Historical vix::utils::Logger remains a temporary compatibility alias to the canonical implementation.

Quick Start

#include <vix/log/Log.hpp>

int main()
{
  vix::log::info("Hello world");
  vix::log::warn("Low disk space");
  vix::log::error("Failed to open file");
}

Log Levels

vix::log::set_level(vix::log::LogLevel::Debug);

Available levels:

  • Trace
  • Debug
  • Info
  • Warn
  • Error
  • Critical
  • Off

Structured Logging

vix::log::logf(
  vix::log::LogLevel::Info,
  "request completed",
  "status", 200,
  "method", "GET",
  "path", "/api/users"
);

Output Formats

vix::log::set_format(vix::log::LogFormat::KV);
vix::log::set_format(vix::log::LogFormat::JSON);
vix::log::set_format(vix::log::LogFormat::JSON_PRETTY);

Context (Thread-Local)

Attach metadata to all logs in a scope:

vix::log::LogContext ctx;
ctx.request_id = "req-123";
ctx.module = "auth";
ctx.fields["user_id"] = "42";

vix::log::set_context(ctx);

vix::log::info("user logged in");

vix::log::clear_context();

Configuration

vix::log::LogConfig config;
config.level = vix::log::LogLevel::Info;
config.format = vix::log::LogFormat::JSON;
config.async = true;

vix::log::configure(config);

Environment Configuration

vix::log::set_level_from_env();   // VIX_LOG_LEVEL
vix::log::set_format_from_env();  // VIX_LOG_FORMAT

Examples

Located in examples/:

  • basic.cpp → basic logging
  • context.cpp → context usage
  • format.cpp → format switching

Tests

Located in test/:

  • log_test.cpp

Run:

ctest

Dependencies

This module depends on:

  • vix::utils (logging backend)

No direct dependency on spdlog is exposed publicly.

Design Goals Recap

  • Simple API
  • No duplication
  • Structured logging first
  • Context-aware
  • High performance
  • Stable interface

License

MIT Part of the Vix.cpp project.

About

Structured logging system.

Resources

Readme MIT license Activity Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks Report repository

Releases

Packages

Contributors

Languages