Direct:Log

From DirectFBWiki

(Redirected from Direct:log)
Table of contents

Overview

Direct log provides a way of displaying debugging messages. It's more flexible than using just printf() for debugging since the destination of the log messages can be configured independently of the calls to display messages. The possible destinations of the messages are:

  • stderr
  • file
  • udp network

The default log is typically configured in /etc/directfbrc and NULL is then passed as the log parameter to write to the default destination.

UDP Logging

If the controlling shell of the application is obscured (e.g. by the framebuffer switching to graphic mode), you probably want to use UDP debugging to send the messages to another display. If you can get a remote shell to the machine where the application is running, just use localhost by adding a line like this to directfbrc:

 log-udp=localhost:8088

The messages can then be seen in the remote shell with the socat (http://www.dest-unreach.org/socat/) utility:

 socat - udp4-listen:8088,fork

It is left as an exercise for the reader to change the parameters for truly remote debug logging.

Debug

Direct:Debug is built on top of direct log, and provides even richer debug logging. Have a look at it before you start using direct log by itself.

API Reference

direct_log_create(type, param, ret_log)

Create a new log.

The new log is passed back through the ret_log parameter.

The type parameters may be:

  • DLT_STDERR - the log's output is displayed on stderr
  • DLT_FILE - the log's output is written to the file named in param
  • DLT_UDB - the log's output is sent over the network in UDP packets to a host:port named in param.
    (The socat (http://www.dest-unreach.org/socat/) or Netcat (http://netcat.sourceforge.net/) utility may be useful to read the UDP messages)

direct_log_destroy(log)

Destroy a log.

If the specified log is currently the default log as set with direct_log_set_default() then the default log will be unset.

direct_log_printf(log, fmt, ...)

Display a message to the specified log.

If log is NULL, the message is sent to the default log. If there is no default log, the message will be displayed on stderr.

The fmt and following paramaters are like for printf()

direct_log_set_default(log)

Set the log to be used by default in case NULL or an invalid log is passed to direct_log_printf().