Logger¶
-
struct
TmeLogger
¶ Provides logging facilities.
A logger instance can log either to stdout, to file or to a memory buffer.
- Note
The logger won’t deallocate the string provider instance that gets passed to it during its allocation: you must deallocate it yourself.
Lifecycle
-
TmeLogger *
tme_logger_alloc_console
(TmeStringProvider const *provider)¶ Allocates a new logger instance that logs to stdout.
- Return
Logger instance.
- Parameters
provider
: String provider.
-
TmeLogger *
tme_logger_alloc_file
(TmeStringProvider const *provider, char const *path)¶ Allocates a new logger instance that logs to file.
- Return
Logger instance.
- Note
The path is copied by the logger, so you are still responsible for deallocating the string passed to this allocator.
- Parameters
provider
: String provider.path
: Path of the log file.
-
TmeLogger *
tme_logger_alloc_memory
(TmeStringProvider const *provider)¶ Allocates a new logger instance that logs to an internal memory buffer.
- Return
Logger instance.
- Parameters
provider
: String provider.
State
-
void
tme_logger_clear
(TmeLogger *logger)¶ Clears the logger, removing anything it has logged in the past.
The effect depends on the logger type:
Console/Null: no effect.
File: empties the file.
Memory: empties the memory buffer.
- Parameters
logger
: Logger instance.
Logging
-
void
tme_logger_logf
(TmeLogger *logger, char const *format, ...)¶ Logs the specified formatted string.
- Parameters
logger
: Logger instance.format
: Format string....
: Format arguments.
-
void
tme_logger_log
(TmeLogger *logger, TmeString string)¶ Logs the specified counted string.
- Parameters
logger
: Logger instance.string
: String to log.
-
void
tme_logger_logln
(TmeLogger *logger, TmeString string)¶ Logs the specified counted string followed by a newline character.
- Parameters
logger
: Logger instance.string
: String to log.
-
void
tme_logger_log_free
(TmeLogger *logger, TmeString string)¶ Logs the specified counted string, freeing it once done.
- Parameters
logger
: Logger instance.string
: String to log.
-
void
tme_logger_logln_free
(TmeLogger *logger, TmeString string)¶ Logs the specified counted string followed by a newline character, freeing it when done.
- Parameters
logger
: Logger instance.string
: String to log.
-
void
tme_logger_log_entity_iri
(TmeLogger *logger, TmeEntityPtr entity_ptr)¶ Logs the IRI associated with the specified entity.
- Parameters
logger
: Logger instance.entity_ptr
: Entity identifier.
-
void
tme_logger_log_entity
(TmeLogger *logger, TmeEntityPtr entity_ptr)¶ Logs the readable representation of the specified entity.
- Parameters
logger
: Logger instance.entity_ptr
: Entity identifier.
-
void
tme_logger_log_negated_entity
(TmeLogger *logger, TmeEntityPtr entity_ptr)¶ Logs the readable representation of the specified negated entity.
- Parameters
logger
: Logger instance.entity_ptr
: Entity identifier.
-
void
tme_logger_log_card_role
(TmeLogger *logger, TmeCardinalityRole role)¶ Logs the readable representation of the specified cardinality restriction.
- Parameters
logger
: Logger instance.role
: Cardinality restriction.
-
void
tme_logger_log_gt_role
(TmeLogger *logger, TmeCardinalityRole role)¶ Logs the readable representation of the specified minimum cardinality restriction.
- Parameters
logger
: Logger instance.role
: Cardinality restriction.
-
void
tme_logger_log_lt_role
(TmeLogger *logger, TmeCardinalityRole role)¶ Logs the readable representation of the specified maximum cardinality restriction.
- Parameters
logger
: Logger instance.role
: Cardinality restriction.
-
void
tme_logger_log_uv_role
(TmeLogger *logger, TmeUniversalRole role)¶ Logs the readable representation of the specified value restriction.
- Parameters
logger
: Logger instance.role
: Value restriction.
-
void
tme_logger_log_sem_desc
(TmeLogger *logger, TmeSemDesc const *desc)¶ Logs the readable representation of the specified semantic description.
- Parameters
logger
: Logger instance.desc
: Semantic description.
-
void
tme_logger_log_abduction
(TmeLogger *logger, TmeAbduction abduction)¶ Logs the readable representation of the specified abduction result.
- Parameters
logger
: Logger instance.abduction
: Abduction result.
-
void
tme_logger_log_bonus
(TmeLogger *logger, TmeBonus bonus)¶ Logs the readable representation of the specified bonus result.
- Parameters
logger
: Logger instance.bonus
: Bonus result.
-
void
tme_logger_log_contraction
(TmeLogger *logger, TmeContraction contraction)¶ Logs the readable representation of the specified contraction result.
- Parameters
logger
: Logger instance.contraction
: Contraction result.
-
void
tme_logger_log_composition
(TmeLogger *logger, TmeComposition composition)¶ Logs the readable representation of the specified covering result.
- Parameters
logger
: Logger instance.composition
: Covering result.
-
void
tme_logger_log_tbox
(TmeLogger *logger, TmeKB *kb)¶ Logs the TBox of the specified KB.
- Parameters
logger
: Logger instance.kb
: KB whose TBox should be logged.
-
void
tme_logger_log_abox
(TmeLogger *logger, TmeKB *kb)¶ Logs the ABox of the specified KB.
- Parameters
logger
: Logger instance.kb
: KB whose ABox should be logged.
-
void
tme_logger_log_taxonomy
(TmeLogger *logger, TmeReasoner const *reasoner)¶ Logs the taxonomy inferred by the reasoner instance.
- Note
The reasoner must have already computed the taxonomy (via e.g. tme_reasoner_classify()).
- Parameters
logger
: Logger instance.reasoner
: Reasoner whose taxonomy should be logged.
-
void
tme_logger_log_nanos
(TmeLogger *logger, char const *prompt, uint64_t nanos, TmeTimeUnit unit)¶ Logs a prompt string followed by a formatted time interval.
Useful for logging benchmark results.
- Parameters
logger
: Logger instance.prompt
: Prompt string.nanos
: Time interval in nanoseconds.unit
: Desired time unit.