diff --git a/include/cppast/diagnostic.hpp b/include/cppast/diagnostic.hpp index 9ddedfb..e4cac19 100644 --- a/include/cppast/diagnostic.hpp +++ b/include/cppast/diagnostic.hpp @@ -86,6 +86,7 @@ namespace cppast enum class severity { debug, //< A debug diagnostic that is just for debugging purposes. + info, //< An informational message. warning, //< A warning that doesn't impact AST generation. error, //< A non-critical error that does impact AST generation but not critically. critical, //< A critical error where AST generation isn't possible. @@ -99,6 +100,8 @@ namespace cppast { case severity::debug: return "debug"; + case severity::info: + return "info"; case severity::warning: return "warning"; case severity::error: diff --git a/include/cppast/parser.hpp b/include/cppast/parser.hpp index 241930d..2021864 100644 --- a/include/cppast/parser.hpp +++ b/include/cppast/parser.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace cppast { @@ -54,6 +55,12 @@ namespace cppast error_ = false; } + /// \returns A reference to the logger used. + const diagnostic_logger& logger() const noexcept + { + return *logger_; + } + protected: /// \effects Creates it giving it a reference to the logger it uses. explicit parser(type_safe::object_ref logger) @@ -61,12 +68,6 @@ namespace cppast { } - /// \returns A reference to the logger used. - const diagnostic_logger& logger() const noexcept - { - return *logger_; - } - /// \effects Sets the error state. /// This must be called when an error or critical diagnostic is logged and the AST is incomplete. void set_error() const noexcept @@ -111,6 +112,9 @@ namespace cppast /// \returns The parsed file or an empty optional, if a fatal error occurred. type_safe::optional_ref parse(std::string path, const config& c) { + parser_.logger().log("simple file parser", + diagnostic{"parsing file '" + path + "'", source_location(), + severity::info}); auto file = parser_.parse(*idx_, std::move(path), c); auto ptr = file.get(); if (file)