Tizen Native API  3.0

The Dlog API provides functions for sending log output.

Required Header

#include <dlog.h>

Overview

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

priority level indicates the urgency of log message

Priority Description
DLOG_DEBUG Debug messasge. - 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.

Macro example for useful usage

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

Introduction

You can use dlogutil command to view and follow the contents of the log buffers. The general usage is :

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

Filtering log output

Every log message has a tag and a priority associated with it. Filter expression follows this format tag:priority where tag indicates the tag of interest and priority indicates the minimum level of priority to report for that tag. You can add any number of tag:priority specifications in a single filter expression. The tag of a log message is a short indicating the system component from which the message originates The priority is one of the following character values, orderd from lowest to highest priority:
D - debug
I - info
W - warning
E - Error

for example, if you want to see MY_APP tag and above of debug priority,

# dlogutil MY_APP:D

if you want to see all log message above of info priority.

# dlogutil *:I

List of logutil command options

Option Description
-b <buffer> Alternate log buffer. The main buffer is used by default buffer.
-c Clears the entire log and exits
-d Dumps the log and exits.
-f <filename> Writes log to filename. The default is stdout
-g Print the size of the specified log buffer and exits.
-n <count> Sets the maximum number of rotated logs to count. The default value is 4. Requires the -r option
-r <Kbytes> Rotates the log file every Kbytes of output. The default value is 16. Requires the -f option.
-s Sets the default filter spec to silent.
-v <format>

Sets the output format for log messages. The default is brief format.

>>>>>>> mobile

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.

Enumeration Type Documentation

Enumeration for Dlog Error.

Since :
2.3
Enumerator:
DLOG_ERROR_NONE 

Successful

DLOG_ERROR_INVALID_PARAMETER 

Invalid parameter

DLOG_ERROR_NOT_PERMITTED 

Operation not permitted

Enumeration for log priority values in ascending priority order.

Since :
2.3
Enumerator:
DLOG_UNKNOWN 

Keep this always at the start

DLOG_DEFAULT 

Default

DLOG_VERBOSE 

Verbose

DLOG_DEBUG 

Debug

DLOG_INFO 

Info

DLOG_WARN 

Warning

DLOG_ERROR 

Error

DLOG_FATAL 

Fatal

DLOG_SILENT 

Silent

DLOG_PRIO_MAX 

Keep this always at the end.


Function Documentation

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

Sends log with priority and tag.

for application.

Since :
2.3
Parameters:
[in]priolog_priority
[in]tagTag
[in]fmtFormat string
Returns:
On success, the function returns the number of bytes written. On error, a negative errno-style error code
Return values:
DLOG_ERROR_INVALID_PARAMETERInvalid parameter
DLOG_ERROR_NOT_PERMITTEDOperation not permitted
Precondition:
none
Postcondition:
none
See also:
dlog_vprint
#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.

Since :
2.3
Parameters:
[in]priolog_priority
[in]tagTag
[in]fmtFormat string
[in]apva_list
Returns:
On success, the function returns the number of bytes written. On error, a negative errno-style error code
Return values:
DLOG_ERROR_INVALID_PARAMETERInvalid parameter
DLOG_ERROR_NOT_PERMITTEDOperation not permitted
Precondition:
none
Postcondition:
none
See also:
dlog_print
#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;
}