Tizen Native API
4.0
|
The Dlog API provides functions for sending log output.
#include <dlog.h>
Sending log message to circular buffer. Dlog APIs include Priority and Tag. By using priority and Tag, we can easily filtered messages what we want to see.
priority level indicates the urgency of log message
Priority | Description |
---|---|
DLOG_DEBUG | Debug message. - Log message which developer want to check. |
DLOG_INFO | Information message - Normal operational messages. above of this priority will always be logged. |
DLOG_WARN | Warning messages - Not an error, but indication that an error will occur if action is not taken. |
DLOG_ERROR | Error message - Indicate error. |
The Dlog APIs can be used by defining own macros. The macros can be defined like below examples. Thus, developers can use appropriate method as a matter of convenience.
#undef LOG_TAG #define LOG_TAG "APP_TAG" #define LOGI(fmt, arg...) \ ({ do { \ dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \ } while (0); }) #define LOGW(fmt, arg...) \ ({ do { \ dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \ } while (0); }) #define LOGE(fmt, arg...) \ ({ do { \ dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \ } while (0); })
dlogutil is a utility that can be utilized to read stored logs.
The most rudimentary way to use it is to run it with no parameters; it then prints all stored logs to the standard output and awaits more.
Parameters exist to change behaviour:
PARAM | DESCRIPTION |
-s | Set default filter to *:s (see later for details) |
-f filename | Output to given file instead of stdout |
-r kbytes | Rotate log file every this many kilobytes. |
-n files | Keep this many old rotations |
-v | Set log output format. |
-b buffer | Select another buffer |
-c | Clear the selected buffers |
-d | Exit when no more logs are currently available |
-t count | Similar to -d, except only print this many logs from the end |
-g | Get the size of selected buffers instead of printing logs |
-h, --help | Show help info |
--dumpfile file | Parse a binary file generated by the logger daemon |
Additionally, you can specify filters. Filters go behind the parameters and are used to decide which logs are shown.
Each log line has priority and a tag. Filters are specified in the format TAG[:PRIO]. Only logs with given tags and priorities are shown.
You can specify * as the tag to match anything. Beware: only a single asterisk works that way, asterisk is not otherwise expanded. For example, "T*G" filter will NOT match "TAG", only literal "T*G".
If you don't specify any filter, it defaults to *:I
If you specify just * as the tag, without priority, its priority defaults to D
If you specify any other tag without priority, the priority defaults to V
dlogutil allows you to specify buffers. These are:
NAME | REMARKS |
main | the default, for general platform logging |
system | for system logs |
radio | for radio logs |
apps | for applications |
kmsg | a copy of kernel messages (dmesg) |
There are also priorities to be specified. These are one letter abbreviations of the following levels:
LEVEL | DESCRIPTION |
V | verbose |
D | debug |
I | info |
W | warning |
E | error |
F | fatal |
S | silent |
Formats, and what they look like:
NAME | SPECIFICATION | EXAMPLE |
brief | PRI/TAG(PID): MSG | E/TEST_APP(123): FOO |
process | PRI(PID) MSG (TAG) | E(123) FOO (TEST_APP) |
tag | PRI/TAG: MSG | E/TEST_APP: FOO |
thread | PRI('P'PID, 'T'TID) MSG | E(P123, T456) FOO |
raw | MSG | FOO |
time | REALTIME PRI/TAG(PID): MSG | 12-31 23:59:59.999 +0200 E/TEST_APP(123): FOO |
threadtime | REALTIME PRI/TAG('P'PID, 'T'TID): MSG | 12-31 23:59:59.999 +0200 E/TEST_APP(P123, T456): FOO |
kerneltime | BOOTTIME PRI/TAG('P'PID, 'T'TID): MSG | 0.123 E/TEST_APP(P123, T456): FOO |
long | [REALTIME PRI/TAG 'P'PID, 'T'TID] MSG | [12-31 23:59:59.999 +0200 E/TEST_APP P123, T456] FOO |
Functions | |
int | dlog_print (log_priority prio, const char *tag, const char *fmt,...) |
Sends log with priority and tag. | |
int | dlog_vprint (log_priority prio, const char *tag, const char *fmt, va_list ap) |
Sends log with priority, tag, and va_list. |
enum dlog_error_e |
enum log_priority |
Enumeration for log priority values in ascending priority order.
int dlog_print | ( | log_priority | prio, |
const char * | tag, | ||
const char * | fmt, | ||
... | |||
) |
Sends log with priority and tag.
for application.
[in] | prio | priority level of type log_priority |
[in] | tag | tag - a null-terminated string |
[in] | fmt | format string - same as printf |
DLOG_ERROR_INVALID_PARAMETER | Invalid parameter |
DLOG_ERROR_NOT_PERMITTED | Operation not permitted |
#include<dlog.h> int main(void) { int integer = 21; char string[] = "test dlog"; dlog_print(DLOG_INFO, "USR_TAG", "test dlog"); dlog_print(DLOG_INFO, "USR_TAG", "%s, %d", string, integer); return 0; }
int dlog_vprint | ( | log_priority | prio, |
const char * | tag, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
Sends log with priority, tag, and va_list.
for application.
[in] | prio | priority level of type log_priority |
[in] | tag | tag - a null-terminated string |
[in] | fmt | format string - same as printf |
[in] | ap | va_list |
DLOG_ERROR_INVALID_PARAMETER | Invalid parameter |
DLOG_ERROR_NOT_PERMITTED | Operation not permitted |
#include<dlog.h> void my_debug_print(char *format, ...) { va_list ap; va_start(ap, format); dlog_vprint(DLOG_INFO, "USR_TAG", format, ap); va_end(ap); } int main(void) { my_debug_print("%s", "test dlog"); my_debug_print("%s, %d", "test dlog", 21); return 0; }