summaryrefslogtreecommitdiff
path: root/src/log.hpp
blob: 996b6bc2e933396a2e360b5e6ea5645fabfcfe62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include "format.hpp"
#include <format>
#include <print>
#include <string>
#include <unistd.h>

inline void log(FILE *_stream, eFormatType type, std::string str) {
#ifndef DEBUG
	if (type == TRACE)
		return;
#endif
	std::println(_stream, "{}", NFormatter::fmt(type, str));
}

template <typename... Args>
void log(FILE *_stream, eFormatType type, std::format_string<Args...> fmt, Args &&...args) {
#ifndef DEBUG
	if (type == TRACE)
		return;
#endif
	std::println(_stream, "{}", NFormatter::fmt(type, fmt, std::forward<Args>(args)...));
}

inline void log(eFormatType type, std::string str) {
	log(type == ERR ? stderr : stdout, type, str);
}

template <typename... Args>
void log(eFormatType type, std::format_string<Args...> fmt, Args &&...args) {
	log(type == ERR ? stderr : stdout, type, fmt, std::forward<Args>(args)...);
}