Skip to content

Latest commit

 

History

History
142 lines (63 loc) · 3.08 KB

README.md

File metadata and controls

142 lines (63 loc) · 3.08 KB

Logging Functions

CMake's logging is restricted to using the built in message() function. It writes the messages to stdout and stderr depending on the given tag present (STATUS, ERROR, FATAL_ERROR,WARNING, <none>). This is sometimes not enough - especially when the output of your CMake script should be very controlled (ie. it is important that no debug or status messages are ouput when users expect the output to adher to a certain format)

This is why I started to write log functions which do not output anything. You can listen to log messages using the event system - the on_log_message is called for every log message that is output.

Function List

Function Descriptions

error

error(...)-><log entry>

Shorthand function for `log( <refs...> --error)

see log

fatal

reports an error and stops program exection

log

log(<message:<string>> <refs...> [--error]|[--warning]|[--info]|[--debug]) -> <void>

This is the base function on which all of the logging depends. It transforms every log message into a object which can be consumed by listeners or filtered later

Note: in its current state this function is not ready for use

  • returns
    • the reference to the <log entry>
  • parameters
    • <message> a <string> containing the message which is to be logged the data may be formatted (see format())
    • <refs...> you may pass variable references which will be captured so you can later check the state of the application when the message was logged
  • flags
    • --error flag indicates that errors occured
    • --warning flag indicates warnings
    • --info flag indicates a info output
    • --debug flag indicates a debug output
  • values
    • --error-code <code>
    • --level <n>
    • --push <section> depth+1
    • --pop <section> depth-1
  • events
    • on_log_message

Examples

log("this is a simple error" --error) => null

log_record_clear

log_record_clear()-><void>

removes all messages from the log record

log_default_handler

log_last_error_entry

log_last_error_entry()-><log entry>

returns the last log entry which is an error

log_last_error_message

log_last_error_message()-><string>

returns the last logged error message

log_last_error_print

log_last_error_print()-><void>

prints the last error message to the console

log_print

log_print

warning