Clingo
Loading...
Searching...
No Matches

Functions and classes for logging. More...

Classes

class  CppClingo::parse_error
 Exception to indicate that parsing failed. More...
 
class  CppClingo::rewrite_error
 Exception to indicate that parsing failed. More...
 
class  CppClingo::Logger
 Simple logger to report message to stderr or via a callback. More...
 
class  CppClingo::Report
 Helper class to ease logging. More...
 

Macros

#define CLINGO_REPORT(p, id)
 Report messages of the given type.
 
#define CLINGO_REPORT_LOC(p, id, loc)
 Report messages of the given type and location.
 
#define CLINGO_REPORT_STR(p, id, msg)
 Report message of the given type given as string.
 

Enumerations

enum class  CppClingo::MessageCode : uint8_t {
  trace = 0 , MessageCode::debug = 1 , MessageCode::info = 2 , MessageCode::info_operation_undefined = 3 ,
  MessageCode::info_atom_undefined = 4 , MessageCode::info_file_included = 5 , MessageCode::info_global_variable = 6 , MessageCode::warn = 7 ,
  MessageCode::error = 8
}
 Codes of messages. More...
 
enum class  CppClingo::LogLevel : uint8_t {
  LogLevel::trace = static_cast<uint8_t>(MessageCode::trace) , LogLevel::debug = static_cast<uint8_t>(MessageCode::debug) , LogLevel::info = static_cast<uint8_t>(MessageCode::info) , LogLevel::warn = static_cast<uint8_t>(MessageCode::warn) ,
  LogLevel::error = static_cast<uint8_t>(MessageCode::error)
}
 Log levels for coarse-grained configuration of logging. More...
 

Functions

auto CppClingo::Logger::check (MessageCode code) -> bool
 Check if a message with the given code should be reported.
 
auto CppClingo::Logger::enabled (MessageCode code) const -> bool
 Check if the given message code is enabled.
 
void CppClingo::Logger::enable (MessageCode code, bool enable)
 Enable or disable a message code.
 
void CppClingo::Logger::set_level (LogLevel level)
 Set the log level.
 
void CppClingo::Logger::set_limit (size_t limit)
 Set the message limit.
 
void CppClingo::Logger::print (MessageCode code, std::string_view msg)
 Unconditionally output a message with a given code.
 
void CppClingo::Logger::reset ()
 Reset the logger to the constructed state.
 
auto CppClingo::Logger::message_prefix (MessageCode code) const -> std::string_view
 Get a string representation of the message category.
 

Detailed Description

Functions and classes for logging.

Macro Definition Documentation

◆ CLINGO_REPORT

#define CLINGO_REPORT (   p,
  id 
)
Value:
if ((p).check(::CppClingo::MessageCode::id)) \
CppClingo::Report(p, ::CppClingo::MessageCode::id).out()

Report messages of the given type.

◆ CLINGO_REPORT_LOC

#define CLINGO_REPORT_LOC (   p,
  id,
  loc 
)
Value:
if ((p).check(::CppClingo::MessageCode::id)) \
CppClingo::Report(p, ::CppClingo::MessageCode::id, loc).out()

Report messages of the given type and location.

◆ CLINGO_REPORT_STR

#define CLINGO_REPORT_STR (   p,
  id,
  msg 
)
Value:
if ((p).check(::CppClingo::MessageCode::id)) { \
(p).print(::CppClingo::MessageCode::id, msg); \
}

Report message of the given type given as string.

Enumeration Type Documentation

◆ LogLevel

enum class CppClingo::LogLevel : uint8_t
strong

Log levels for coarse-grained configuration of logging.

Enumerator
trace 

Trace as much as possible.

debug 

Output debug messages.

info 

Output info messages.

warn 

Output warnings.

error 

Output errors.

◆ MessageCode

enum class CppClingo::MessageCode : uint8_t
strong

Codes of messages.

Codes larger or equal to error indicate non-recoverable runtime errors.

Enumerator
debug 

Trace messages.

info 

Debug messages.

info_operation_undefined 

Generic info messages.

info_atom_undefined 

Info message for undefined operations.

info_file_included 

Info message for undefined atoms.

info_global_variable 

Info message for duplicate includes.

warn 

Info message for global variables.

error 

A warning.

Function Documentation

◆ enable()

void CppClingo::Logger::enable ( MessageCode  code,
bool  enable 
)
inline

Enable or disable a message code.

Note that errors cannot be disabled and are always reported.

◆ reset()

void CppClingo::Logger::reset ( )
inline

Reset the logger to the constructed state.

This keeps all settings but resets the error flag and message limit.