Skip to content

caliper.log.v1

Service id caliper.log.v1 sends timestamped log lines from an applet to the host.

Types

The severity of a log line. The host treats a value outside 0 to 3 as CALIPER_LOG_INFO.

Constant Value Description
CALIPER_LOG_DEBUG 0 Detail that helps to debug an applet.
CALIPER_LOG_INFO 1 A normal event of interest.
CALIPER_LOG_WARN 2 A problem that the applet can continue after.
CALIPER_LOG_ERROR 3 A failure of an operation.

Calls

Call Signature Description
log void (CaliperLogLevel level, const char* message_utf8) Write one finished UTF-8 line at level. The host does not interpret a format string and adds the trailing newline. Any applet thread can call it.

Ids

Name Value Description
CALIPER_LOG_V1 "caliper.log.v1" The id of this service, which get_service takes.

Semantics

The service has these rules:

  • Pre-formatted lines. The host does not interpret a printf format string, so format the text in the applet and pass the result.
  • Where it goes. The caliper executable adds a local HH:MM:SS timestamp and the level tag to each line. It then writes the line to stderr. A program that embeds the core through Caliper Embed can set log_fn in its CaliperCoreDesc. That program receives the applet lines through the callback, tagged [applet], and nothing goes to stderr. See Embedding.
  • Threading. Unlike caliper.ui.v1, log() can run on any thread the applet owns, for example a background worker. The applet must get the CaliperLogV1* table pointer with get_service(CALIPER_LOG_V1) during initialize() on the UI thread. It then caches the pointer and uses it from any thread.