Set proper executable bits
[platform/core/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 <stdarg.h>
28 #include <string.h>
29 #include <tizen_error.h>
30 #include "dlog-internal.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 /*
37  * This is the local tag used for the following simplified
38  * logging macros.  You can change this preprocessor definition
39  * before using the other macros to change the tag.
40  */
41 #ifndef LOG_TAG
42 #define LOG_TAG NULL
43 #endif
44
45 /**
46  * @addtogroup CAPI_SYSTEM_DLOG
47  * @{
48  *
49  */
50 /**
51  * @brief Enumeration for Dlog Error.
52  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @elseif TV 3.0 @endif
53  */
54 typedef enum {
55         DLOG_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
56         DLOG_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
57         DLOG_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED /**< Operation not permitted */
58 } dlog_error_e;
59 /**
60  * @}
61  */
62
63 /**
64  * @addtogroup CAPI_SYSTEM_DLOG
65  * @{
66  *
67  */
68 /**
69  * @brief log priority values, in ascending priority order.
70  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @elseif TV 3.0 @endif
71  */
72 typedef enum {
73         DLOG_UNKNOWN = 0, /**< Keep this always at the start */
74         DLOG_DEFAULT, /**< Default */
75         DLOG_VERBOSE, /**< Verbose */
76         DLOG_DEBUG, /**< Debug */
77         DLOG_INFO, /**< Info */
78         DLOG_WARN, /**< Warning */
79         DLOG_ERROR, /**< Error */
80         DLOG_FATAL, /**< Fatal */
81         DLOG_SILENT, /**< Silent */
82         DLOG_PRIO_MAX   /**< Keep this always at the end. */
83 } log_priority;
84 /**
85  * @}
86  */
87
88 /**
89  * @addtogroup CAPI_SYSTEM_DLOG
90  * @{
91  */
92 /**
93  * @brief     Send log with priority and tag.
94  * @details   for application
95  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @elseif TV 3.0 @endif
96  * @param[in] prio log_priority
97  * @param[in] tag tag
98  * @param[in] fmt format string
99  * @return On success, the function returns the number of bytes written.
100  *         On error, a negative errno-style error code
101  * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
102  * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
103  * @pre       none
104  * @post      none
105  * @see       dlog_vprint
106  * @code
107 #include<dlog.h>
108 int main(void)
109 {
110     int integer = 21;
111     char string[] = "test dlog";
112
113         dlog_print(DLOG_INFO, "USR_TAG", "test dlog");
114         dlog_print(DLOG_INFO, "USR_TAG", "%s, %d", string, integer);
115     return 0;
116 }
117  * @endcode
118  */
119 int dlog_print(log_priority prio, const char *tag, const char *fmt, ...);
120
121 /**
122  * @brief     Send log with priority, tag and va_list.
123  * @details   for application
124  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @elseif TV 3.0 @endif
125  * @param[in] prio log_priority
126  * @param[in] tag tag
127  * @param[in] fmt format string
128  * @param[in] ap va_list
129  * @return On success, the function returns the number of bytes written.
130  *         On error, a negative errno-style error code
131  * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
132  * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
133  * @pre       none
134  * @post      none
135  * @see       dlog_print
136  * @code
137 #include<dlog.h>
138 void my_debug_print(char *format, ...)
139 {
140     va_list ap;
141
142     va_start(ap, format);
143     dlog_vprint(DLOG_INFO, "USR_TAG", format, ap);
144     va_end(ap);
145 }
146
147 int main(void)
148 {
149     my_debug_print("%s", "test dlog");
150     my_debug_print("%s, %d", "test dlog", 21);
151     return 0;
152 }
153  * @endcode
154  */
155 int dlog_vprint(log_priority prio, const char *tag, const char *fmt, va_list ap);
156 /**
157  * @}
158  */
159
160 #ifdef __cplusplus
161 }
162 #endif /* __cplusplus */
163 #endif /* _DLOG_H_*/