2020-10-05 15:45:00 +00:00
|
|
|
#ifndef MALACHSCRIPT_DIAGNOSTICS_HPP
|
|
|
|
#define MALACHSCRIPT_DIAGNOSTICS_HPP
|
2020-10-04 17:38:13 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "Diagnostic.hpp"
|
|
|
|
|
2020-10-05 15:45:00 +00:00
|
|
|
namespace MalachScript::Diagnostics {
|
2020-10-04 17:38:13 +00:00
|
|
|
class Diagnostics {
|
|
|
|
std::vector<Diagnostic> _messages;
|
|
|
|
|
|
|
|
public:
|
2020-10-05 10:18:05 +00:00
|
|
|
inline void Log(DiagnosticLevel level, DiagnosticType type, std::u8string_view scriptName, TextSpan span) {
|
|
|
|
_messages.emplace_back(level, type, scriptName, span);
|
|
|
|
}
|
|
|
|
inline void LogTrace(DiagnosticType type, std::u8string_view scriptName, TextSpan span) {
|
|
|
|
Log(DiagnosticLevel::Trace, type, scriptName, span);
|
|
|
|
}
|
|
|
|
inline void LogInfo(DiagnosticType type, std::u8string_view scriptName, TextSpan span) {
|
|
|
|
Log(DiagnosticLevel::Information, type, scriptName, span);
|
|
|
|
}
|
|
|
|
inline void LogWarning(DiagnosticType type, std::u8string_view scriptName, TextSpan span) {
|
|
|
|
Log(DiagnosticLevel::Warning, type, scriptName, span);
|
|
|
|
}
|
|
|
|
inline void LogError(DiagnosticType type, std::u8string_view scriptName, TextSpan span) {
|
|
|
|
Log(DiagnosticLevel::Error, type, scriptName, span);
|
|
|
|
}
|
|
|
|
inline void LogCritical(DiagnosticType type, std::u8string_view scriptName, TextSpan span) {
|
|
|
|
Log(DiagnosticLevel::Critical, type, scriptName, span);
|
2020-10-04 17:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] const std::vector<Diagnostic>& GetMessages() const noexcept { return _messages; }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-05 15:45:00 +00:00
|
|
|
#endif // MALACHSCRIPT_DIAGNOSTICS_HPP
|