SiddiqSoft.ScopeTrace 0.51.2

dotnet add package SiddiqSoft.ScopeTrace --version 0.51.2
                    
NuGet\Install-Package SiddiqSoft.ScopeTrace -Version 0.51.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.ScopeTrace" Version="0.51.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SiddiqSoft.ScopeTrace" Version="0.51.2" />
                    
Directory.Packages.props
<PackageReference Include="SiddiqSoft.ScopeTrace" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SiddiqSoft.ScopeTrace --version 0.51.2
                    
#r "nuget: SiddiqSoft.ScopeTrace, 0.51.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SiddiqSoft.ScopeTrace@0.51.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SiddiqSoft.ScopeTrace&version=0.51.2
                    
Install as a Cake Addin
#tool nuget:?package=SiddiqSoft.ScopeTrace&version=0.51.2
                    
Install as a Cake Tool

ScopeTrace

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image NuGet

siddiqsoft::ScopeTrace is a modern, lightweight, header-only C++23 RAII scope logger designed for performance profiling and scope execution tracing.

  • RAII Scope Timing: Automatic duration measurement upon scope exit.
  • std::source_location Integration: Capture file, line, and function automatically.
  • Process Singleton Entry: Instantiated exclusively via static ScopeTrace::GetInstance() process singleton.
  • Nesting Level Tracking: Indents nested scope execution trees dynamically using parentage depth inheritance (sub_scope()).
  • Dynamic Log Level Filtering: Fine-grained threshold control (LogLevel / trace_level). Critical, exception, and error logs are always output, while warning, info, debug, and trace are filtered according to threshold (m_log_level).
  • Structured Console Logging: Specialized info(), debug(), trace(), warn(), err(), err_throw(), and exp() methods for formatted console logging with ANSI colors and ISO 8601 UTC timestamps.

For full detailed documentation, integration guides, and API specifications, visit our MkDocs documentation site:


Quick Start

#include <iostream>
#include <siddiqsoft/ScopeTrace.hpp>

// Obtain process singleton configured with trace threshold
auto& Log = siddiqsoft::ScopeTrace::GetInstance("MYPROJECT", siddiqsoft::LogLevel::trace);

void sub_task()
{
    // Create nested context ("MYPROJECT/sub_task") with info threshold
    auto inner = Log.sub_scope(__func__, siddiqsoft::LogLevel::info);
    auto last_line = __LINE__;

    try {
        last_line = __LINE__;
        inner.info("Processing items...");

        // Perform work...
        last_line = __LINE__;
        call_something(); // throws std::runtime_error("Device non-responsive")
    } catch (const std::exception& ex) {
        // Logs exception type, e.what(), and contextual line information
        inner.exp(ex, "Got exception last_line: {}", last_line);
    }

    // Upon scope exit, destructors log completed message and elapsed time
}

int main()
{
    Log.info("Starting application execution");
    sub_task();
    return 0;
}

Sample Output & Console Coloring

When running the quick start application, siddiqsoft::ScopeTrace outputs depth-indented log lines to std::cerr prefixed by ISO 8601 UTC timestamps and styled with ANSI level color codes:

<div class="terminal-window" style="background-color: #1b1d24; border-radius: 8px; border: 1px solid #2e3240; margin: 1.5rem 0; overflow: hidden; font-family: 'JetBrains Mono', Consolas, monospace;"> <div class="terminal-header" style="background-color: #242836; padding: 8px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #2e3240;"> <span class="terminal-dot red" style="width: 12px; height: 12px; border-radius: 50%; background-color: #ff5f56; display: inline-block;"></span> <span class="terminal-dot yellow" style="width: 12px; height: 12px; border-radius: 50%; background-color: #ffbd2e; display: inline-block;"></span> <span class="terminal-dot green" style="width: 12px; height: 12px; border-radius: 50%; background-color: #27c93f; display: inline-block;"></span> <span class="terminal-title" style="color: #8b949e; font-size: 12px; margin-left: 6px; font-family: sans-serif;">Console Output (std::cerr)</span> </div> <pre class="terminal-body" style="padding: 14px 18px; color: #e6edf3; font-size: 13px; line-height: 1.65; overflow-x: auto; margin: 0; background: transparent;"><span style="color: #8b949e;">2026-08-15T20:49:27.060564Z</span>|[<span style="color: #e6edf3;">info </span>]|<span style="color: #8b949e;">MYPROJECT</span>|Starting application execution <span style="color: #8b949e;">2026-08-15T20:49:27.060600Z</span>|[<span style="color: #e6edf3;">info </span>]|<span style="color: #8b949e;">MYPROJECT/sub_task</span>|Processing items... <span style="color: #8b949e;">2026-08-15T20:49:27.061200Z</span>|[<span style="background-color: #da3633; color: #ffffff; font-weight: 600; padding: 0 3px;">except</span>]|<span style="color: #8b949e;">MYPROJECT/sub_task</span>|<span style="color: #ff7b72;"><b>std::runtime_error</b> - <i>Device non-responsive</i> - Got exception last_line: 54</span> <span style="color: #8b949e;">2026-08-15T20:49:27.061250Z</span>|[<span style="color: #8b949e;">debug </span>]|<span style="color: #8b949e;">MYPROJECT/sub_task</span>|<span style="color: #8b949e;">COMPLETED: time:</span><span style="color: #3fb950; font-weight: 600;">650us</span> <span style="color: #8b949e;">2026-08-15T20:49:27.061300Z</span>|[<span style="color: #8b949e;">debug </span>]|<span style="color: #8b949e;">MYPROJECT</span>|<span style="color: #8b949e;">COMPLETED: time:</span><span style="color: #3fb950; font-weight: 600;">7360us</span></pre> </div>

Log Level Color Palette

Log Level / Method Tag Label Tag Color Output ANSI Code Visual Output Preview
trace_level::critical crit Reverse Red \033[7;31m [<span style="background-color: #da3633; color: #ffffff; font-weight: 600; padding: 0 3px;">crit </span>] System memory exhaustion
trace_level::exception except Reverse Red \033[7;31m [<span style="background-color: #da3633; color: #ffffff; font-weight: 600; padding: 0 3px;">except</span>] std::runtime_error - Connection refused
trace_level::error error Reverse Orange \033[7;38;5;208m [<span style="background-color: #d96c00; color: #ffffff; font-weight: 600; padding: 0 3px;">error </span>] Failed to open configuration file
trace_level::warning warn Reverse Light Yellow \033[7;38;5;220m [<span style="background-color: #ffd700; color: #000000; font-weight: 600; padding: 0 3px;">warn </span>] Cache capacity reached 92%
trace_level::info info Default / Neutral \033[0m <span style="color: #e6edf3;">[info ] Server listening on port 8080</span>
trace_level::debug debug Light Gray \033[38;5;250m <span style="color: #8b949e;">[debug ] Worker thread depth: 2</span>
trace_level::trace trace Dark Blue \033[38;5;19m <span style="color: #58a6ff;">[trace ] RX payload: 0x41 0x42 0x43</span>
Scope Exit COMPLETED Green Time \033[0;32m <span style="color: #8b949e;">COMPLETED: time:</span><span style="color: #3fb950; font-weight: 600;">450us</span>

Installation & Integration

Integrate via CPM.cmake:

include(CPM.cmake)

CPMAddPackage("gh:SiddiqSoft/ScopeTrace#v1.0.0")

target_link_libraries(your_target PRIVATE siddiqsoft::ScopeTrace)

For more details, see the CMake & Integration Documentation.


Requirements & Building

  • C++ Compiler: C++23 compliant compiler (MSVC 2022 v17.10+, GCC 13+, Clang 17+).
  • CMake: Version >= 3.29.

Preset Build & Test

# Configure using Apple-Debug / Linux-GCC-Debug / Windows-x64-Debug preset
cmake --preset Darwin

# Build test binaries
cmake --build build/Darwin

# Execute unit tests
ctest --test-dir build/Darwin

License

Distributed under the BSD 3-Clause License. Copyright (c) 2026 Siddiq Software LLC.

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.51.2 9 8/17/2026
0.51.1 24 8/17/2026
0.51.0 28 8/17/2026
0.50.1 49 8/17/2026
0.50.0 37 8/16/2026
0.40.0 42 8/15/2026
0.32.0 39 8/15/2026
0.31.0 38 8/15/2026
0.30.1 43 8/15/2026
0.30.0 49 8/15/2026
0.20.0 44 8/14/2026
0.10.1 45 8/14/2026
0.10.0 36 8/14/2026
0.9.1 45 8/13/2026

Refer to the project repository for release notes.