Add informational log output to simple_file_parser
This commit is contained in:
parent
ca5623b43d
commit
03495fbf11
2 changed files with 13 additions and 6 deletions
|
|
@ -86,6 +86,7 @@ namespace cppast
|
||||||
enum class severity
|
enum class severity
|
||||||
{
|
{
|
||||||
debug, //< A debug diagnostic that is just for debugging purposes.
|
debug, //< A debug diagnostic that is just for debugging purposes.
|
||||||
|
info, //< An informational message.
|
||||||
warning, //< A warning that doesn't impact AST generation.
|
warning, //< A warning that doesn't impact AST generation.
|
||||||
error, //< A non-critical error that does impact AST generation but not critically.
|
error, //< A non-critical error that does impact AST generation but not critically.
|
||||||
critical, //< A critical error where AST generation isn't possible.
|
critical, //< A critical error where AST generation isn't possible.
|
||||||
|
|
@ -99,6 +100,8 @@ namespace cppast
|
||||||
{
|
{
|
||||||
case severity::debug:
|
case severity::debug:
|
||||||
return "debug";
|
return "debug";
|
||||||
|
case severity::info:
|
||||||
|
return "info";
|
||||||
case severity::warning:
|
case severity::warning:
|
||||||
return "warning";
|
return "warning";
|
||||||
case severity::error:
|
case severity::error:
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <cppast/cpp_file.hpp>
|
#include <cppast/cpp_file.hpp>
|
||||||
#include <cppast/cpp_preprocessor.hpp>
|
#include <cppast/cpp_preprocessor.hpp>
|
||||||
#include <cppast/diagnostic_logger.hpp>
|
#include <cppast/diagnostic_logger.hpp>
|
||||||
|
#include <cppast/diagnostic.hpp>
|
||||||
|
|
||||||
namespace cppast
|
namespace cppast
|
||||||
{
|
{
|
||||||
|
|
@ -54,6 +55,12 @@ namespace cppast
|
||||||
error_ = false;
|
error_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \returns A reference to the logger used.
|
||||||
|
const diagnostic_logger& logger() const noexcept
|
||||||
|
{
|
||||||
|
return *logger_;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// \effects Creates it giving it a reference to the logger it uses.
|
/// \effects Creates it giving it a reference to the logger it uses.
|
||||||
explicit parser(type_safe::object_ref<const diagnostic_logger> logger)
|
explicit parser(type_safe::object_ref<const diagnostic_logger> 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.
|
/// \effects Sets the error state.
|
||||||
/// This must be called when an error or critical diagnostic is logged and the AST is incomplete.
|
/// This must be called when an error or critical diagnostic is logged and the AST is incomplete.
|
||||||
void set_error() const noexcept
|
void set_error() const noexcept
|
||||||
|
|
@ -111,6 +112,9 @@ namespace cppast
|
||||||
/// \returns The parsed file or an empty optional, if a fatal error occurred.
|
/// \returns The parsed file or an empty optional, if a fatal error occurred.
|
||||||
type_safe::optional_ref<const cpp_file> parse(std::string path, const config& c)
|
type_safe::optional_ref<const cpp_file> 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 file = parser_.parse(*idx_, std::move(path), c);
|
||||||
auto ptr = file.get();
|
auto ptr = file.get();
|
||||||
if (file)
|
if (file)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue