Tizen 2.4 SDK Rev6 Release
[framework/system/dlog.git] / include / dlog.h
1 /*
2  * DLOG
3  * Copyright (c) 2005-2008, The Android Open Source Project
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 /**
20  * @file        dlog.h
21  * @version     0.4
22  * @brief       This file is the header file of interface of dlog.
23  */
24 #ifndef _DLOG_H_
25 #define _DLOG_H_
26
27 #include <tizen_error.h>
28 #include <stdarg.h>
29 #include <string.h>
30
31 #include "dlog-internal.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36
37 /*
38  * This is the local tag used for the following simplified
39  * logging macros.  You can change this preprocessor definition
40  * before using the other macros to change the tag.
41  */
42 #ifndef LOG_TAG
43 #define LOG_TAG NULL
44 #endif
45
46 /**
47  * @addtogroup CAPI_SYSTEM_DLOG
48  * @{
49  *
50  */
51 /**
52  * @brief Enumeration for Dlog Error.
53  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
54  */
55 typedef enum {
56         DLOG_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
57         DLOG_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
58         DLOG_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED /**< Operation not permitted */
59 } dlog_error_e;
60 /**
61  * @}
62  */
63
64 /**
65  * @addtogroup CAPI_SYSTEM_DLOG
66  * @{
67  *
68  */
69 /**
70  * @brief log priority values, in ascending priority order.
71  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
72  */
73 typedef enum {
74         DLOG_UNKNOWN = 0, /**< Keep this always at the start */
75         DLOG_DEFAULT, /**< Default */
76         DLOG_VERBOSE, /**< Verbose */
77         DLOG_DEBUG, /**< Debug */
78         DLOG_INFO, /**< Info */
79         DLOG_WARN, /**< Warning */
80         DLOG_ERROR, /**< Error */
81         DLOG_FATAL, /**< Fatal */
82         DLOG_SILENT, /**< Silent */
83         DLOG_PRIO_MAX   /**< Keep this always at the end. */
84 } log_priority;
85 /**
86  * @}
87  */
88
89 /**
90  * @addtogroup CAPI_SYSTEM_DLOG
91  * @{
92  */
93 /**
94  * @brief     Send log with priority and tag.
95  * @details   for application
96  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
97  * @param[in] prio log_priority
98  * @param[in] tag tag
99  * @param[in] fmt format string
100  * @return On success, the function returns the number of bytes written.
101  *         On error, a negative errno-style error code
102  * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
103  * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
104  * @pre       none
105  * @post      none
106  * @see       dlog_vprint
107  * @code
108 #include<dlog.h>
109 int main(void)
110 {
111     int integer = 21;
112     char string[] = "test dlog";
113
114         dlog_print(DLOG_INFO, "USR_TAG", "test dlog");
115         dlog_print(DLOG_INFO, "USR_TAG", "%s, %d", string, integer);
116     return 0;
117 }
118  * @endcode
119  */
120 int dlog_print(log_priority prio, const char *tag, const char *fmt, ...);
121
122 /**
123  * @brief     Send log with priority, tag and va_list.
124  * @details   for application
125  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
126  * @param[in] prio log_priority
127  * @param[in] tag tag
128  * @param[in] fmt format string
129  * @param[in] ap va_list
130  * @return On success, the function returns the number of bytes written.
131  *         On error, a negative errno-style error code
132  * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
133  * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
134  * @pre       none
135  * @post      none
136  * @see       dlog_print
137  * @code
138 #include<dlog.h>
139 void my_debug_print(char *format, ...)
140 {
141     va_list ap;
142
143     va_start(ap, format);
144     dlog_vprint(DLOG_INFO, "USR_TAG", format, ap);
145     va_end(ap);
146 }
147
148 int main(void)
149 {
150     my_debug_print("%s", "test dlog");
151     my_debug_print("%s, %d", "test dlog", 21);
152     return 0;
153 }
154  * @endcode
155  */
156 int dlog_vprint(log_priority prio, const char *tag, const char *fmt, va_list ap);
157 /**
158  * @}
159  */
160
161 #ifdef __cplusplus
162 }
163 #endif /* __cplusplus */
164 #endif /* _DLOG_H_*/