Initial commit: Klammertext source distribution
Curated source subset assembled by klammertext-dev's doc/make_dist.sh: the Klammermachine (mac), the Standard Klammer Set (sks), the commands (com), editor plugins and install guides (doc), a test subset (tst), and lib/bin placeholders. Builds with 'make -C com'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
63
mac/log.h
Normal file
63
mac/log.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <source_location>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "error.h"
|
||||
#include "locator.h"
|
||||
// #include "source.h"
|
||||
#include "katom_list.h"
|
||||
|
||||
extern int verbose_level;
|
||||
extern bool show_verbose_location;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const std::variant<bool,int,float,std::string,const char*,Locator>& arg);
|
||||
|
||||
void display_location(int log_level, std::source_location location);
|
||||
|
||||
namespace K {
|
||||
template <typename... Ts>
|
||||
struct log
|
||||
{
|
||||
log(int log_level, Ts&&... ts, const std::source_location& location = std::source_location::current()) {
|
||||
if (verbose_level >= log_level) {
|
||||
display_location(log_level, location);
|
||||
if (verbose_level > 1 && sizeof...(ts) > 0) {
|
||||
std::cout << ": ";
|
||||
} else if (verbose_level == 1) {
|
||||
std::cout << command_name << ": ";
|
||||
}
|
||||
if (log_level > 0) {
|
||||
((std::cout << std::forward<Ts>(ts) << " "), ...);
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
log(int log_level, Ts&&...) -> log<Ts...>;
|
||||
}
|
||||
|
||||
/*
|
||||
void log(int level = 3, const std::source_location location = std::source_location::current());
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void log(Args... args, int level = 3, const std::source_location location = std::source_location::current());
|
||||
*/
|
||||
|
||||
/*
|
||||
void log(std::vector<std::variant<bool,int,float,std::string,const char*,Locator,Source>> args={}, int level=3,
|
||||
const std::source_location location
|
||||
= std::source_location::current());
|
||||
|
||||
void xlog(std::vector<std::variant<bool,int,float,std::string,const char*,Locator,Source>> args={}, int verbose_override=1,
|
||||
const std::source_location location
|
||||
= std::source_location::current());
|
||||
*/
|
||||
|
||||
void warning(const std::string& message, const Locator& loc);
|
||||
Reference in New Issue
Block a user