sammine-lang
Loading...
Searching...
No Matches
Logging.h File Reference

LLVM-style debug logging infrastructure. More...

#include <string>
Include dependency graph for Logging.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOG(X)

Functions

void sammine_log::set_enabled_types (const std::string &types_str)
 Set the enabled debug types from command line (semicolon-separated).
const std::string & sammine_log::get_enabled_types ()
 Get the enabled debug types string.
bool sammine_log::is_type_in_list (const char *type, const std::string &list)
 Check if type is in semicolon-separated list.

Detailed Description

LLVM-style debug logging infrastructure.

This file provides LLVM-style debug logging capabilities where each source file can define DEBUG_TYPE to categorize its debug output, and users can enable specific debug types via the –diagnostics CLI flag.

Usage:

  1. Define DEBUG_TYPE at the top of your source file: #define DEBUG_TYPE "lexer" #include "util/Logging.h"
  2. Use LOG macro to emit debug output: LOG({ fmt::print(stderr, "[{}] message\n", DEBUG_TYPE); });
  3. Enable specific debug types from command line: –diagnostics="lexer;parser"

Macro Definition Documentation

◆ LOG

#define LOG ( X)
Value:
do { \
X; \
} \
} while (false)
bool is_type_in_list(const char *type, const std::string &list)
Check if type is in semicolon-separated list.
Definition Logging.cpp:20
const std::string & get_enabled_types()
Get the enabled debug types string.
Definition Logging.cpp:18

LOG - Conditionally execute debug logging code

Example: LOG({ fmt::print(stderr, "[lexer] Token count: {}\n", count); });

Note: DEBUG_TYPE must be defined before using this macro.