4. Logging

This section introduces the Haka logging API. The logs are used for various type of information about a running Haka. The API defines various log sections that allows to have a fine grained control over information reported.

haka.log.fatal(fmt[, ...])
haka.log.error(fmt[, ...])
haka.log.warning(fmt[, ...])
haka.log.info(fmt[, ...])
haka.log.debug(fmt[, ...])
Parameters:
  • fmt (string) – Format string.
  • ... – Format arguments.

Log a message in corresponding level. This function log to the section named 'external'.

haka.log(fmt[, ...])

Alias to haka.log.info().

4.1. Using different log section

haka.log_section(name) → logging

If you want more control, you can define a new section with this function. It will return a tabe without have the same API as the table haka.log().

4.2. Example

haka.log("error in packet %s", pkt)

local log = haka.log_section("mysection")
log.debug("this is a log")