Polyphase Game Engine
Loading...
Searching...
No Matches
ValidationLog.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <cstdint>
6#include <string>
7#include <vector>
8
9namespace Validation
10{
11 enum class Severity : uint8_t
12 {
13 Info,
14 Warning,
15 Error,
16 };
17
18 struct Message
19 {
20 Severity severity = Severity::Info;
21 std::string code;
22 std::string message;
23 std::string details;
24 };
25
26 struct Report
27 {
28 bool valid = false;
29 std::vector<Message> messages;
30 std::string summary;
31 std::string contextHeader;
32 };
33
34 bool HasError(const Report& report);
35 bool HasWarning(const Report& report);
36 void AddInfo(Report& report, const char* code, std::string message, std::string details = {});
37 void AddWarning(Report& report, const char* code, std::string message, std::string details = {});
38 void AddError(Report& report, const char* code, std::string message, std::string details = {});
39
40 const char* SeverityLabel(Severity s);
41
42 std::string FormatReportPlainText(const Report& report);
43 std::string FormatReportMarkdown(const Report& report);
44
45 // Writes the plain-text report to <projectDir>/Logs/<subfolder>/<timestamp>.log.
46 // Creates the directory tree if it does not yet exist.
47 // outPath receives the absolute path of the written file.
48 bool SaveReportToLogsFolder(const Report& report,
49 const std::string& projectDir,
50 const char* subfolder,
51 std::string& outPath);
52
53 void CopyReportToClipboard(const Report& report);
54}
55
56#endif // EDITOR