aboutsummaryrefslogtreecommitdiff
path: root/client/src/util/io.h
blob: 99339c52da9028b8c52e3adeaef1d56027e173b2 (plain) (blame)
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
33
34
35
36
37
38
39
40
41
#pragma once

#include <fmt/format.h>
#include <fmt/color.h>

#include "../client/enc.h"

namespace io {

	template<typename... Args>
	void log(const std::string_view str, Args... params) {
#ifndef _REL
		static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleTextAttribute(handle, FOREGROUND_GREEN);
		fmt::print("$> ");
		SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);

		std::string msg{ str };
		msg.append("\n");

		fmt::print(msg, std::forward<Args>(params)...);
#endif
	}

	template<typename... Args>
	void log_error(const std::string_view str, Args... params) {
#ifndef _REL
		static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleTextAttribute(handle, FOREGROUND_RED);
		fmt::print("$> ");
		SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);

		std::string msg{ str };
		msg.append("\n");

		fmt::print(msg, std::forward<Args>(params)...);
#endif
}

	bool read_file(const std::string_view path, std::vector<char>& out);
};  // namespace io