Published on 25th of October 2017
System Logs

During the development of the application and/or its debugging, it becomes necessary to obtain information about the state of variables or get messages with information about errors. For these purposes, in Tizen uses dlog library. To check the logs messages, both your own and other applications on the device/emulator, you can use the dlogutil utility.

Message Output

To use the dlog API, you must include dlog.h header file in the project:

#include <dlog.h>

The message registration includes: message text, priority (indicates the importance level of the message), and tag. In the development environment, these messages are highlighted in different colors. The library includes the following priorities:

DLOG_VERBOSE Messages containing detailed information.
DLOG_DEBUG Messages for verifying program execution.
DLOG_INFO Information messages.
DLOG_WARN Warning messages about possible errors.
DLOG_ERROR Error messages. Errors can be handled and the application can run further, but with functional or performance limitations.
DLOG_FATAL Error messages that can not be processed. The occurrence of such errors leads to the impossibility of application execution.

To specify the source of log messages, use the tag. Tag is a string that identifies the application or module. The messages output is provided by the function:

int dlog_print(log_priority prio, const char *tag, const char *fmt, ...);

Arguments: priority, tag and format (a string that can include different specifiers, replaced by values that follows after the format). In case of success, the function returns the number of written bytes. In case of unsuccessful execution - negative value. Now let's look at how to display several messages with different priorities and see them through the message log window in Tizen Studio.

dlog_print(DLOG_VERBOSE, "lessonwear013", "Priority message DLOG_VERBOSE.");
dlog_print(DLOG_DEBUG, "lessonwear013", "Priority message DLOG_DEBUG.");
dlog_print(DLOG_INFO, "lessonwear013", "Priority message DLOG_INFO.");
dlog_print(DLOG_WARN, "lessonwear013", "Priority message DLOG_WARN.");
dlog_print(DLOG_ERROR, "lessonwear013", "Priority message DLOG_ERROR.");
dlog_print(DLOG_FATAL, "lessonwear013", "Priority message DLOG_FATAL.");
nw_013_01_en

In the IDE, the log is available in the Log tab. Open the tab Window → Show view → Log. Messages are highlighted in priority color. They can also be filtered by tag or by the content of the message. You can enable/disable messages of a certain type.

Viewing Message Log from the Console

On the device, you can see the log messages using the dlogutil utility. Connect to the device via SDB. First, to use SDB, set the device to SDB mode by going to Settings → More system settings → Developer options → USB debugging. Via console, run the SDB connect device.ip command.

To view the log, call dlogutil. In general, the command has the following form:

dlogutil [<option>] ... [<filter-spec>] ...

The filter expression includes tag:priority. To view information messages of your application, call:

dlogutil lessonwear013:I

To view messages of all priorities, call:

dlogutil lessonwear013:*

Now you can display your error messages or additional information from your application in the logging window.

Leave a Reply

Your email address will not be published. Required fields are marked *