tizen 2.3 release
[framework/system/deviced.git] / src / logd / src / liblogd / logd.h
1 /*
2  * logd
3  *
4  * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /**
19  * @file logd.h
20  *
21  * @desc Contains API to create logd events.
22  */
23
24 #ifndef _LOGD_ACTIVITY_LOGGING_H_
25 #define _LOGD_ACTIVITY_LOGGING_H_
26
27 #include <stdint.h>
28
29 #define LOGD_SHIFT_ACTION(action) ((action) << 16)
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 enum logd_object {
36         /* HW devices */
37         LOGD_ACCELEROMETER,
38         LOGD_BAROMETER,
39         LOGD_BT,
40         LOGD_DISPLAY,
41         LOGD_GEOMAGNETIC,
42         LOGD_GPS,
43         LOGD_GYROSCOPE,
44         LOGD_LIGHT,
45         LOGD_NFC,
46         LOGD_PROXIMITY,
47         LOGD_THERMOMETER,
48         LOGD_WIFI,
49         LOGD_MMC,
50         /* Battery */
51         LOGD_BATTERY_SOC,
52         LOGD_CHARGER,
53         /* Apps */
54         LOGD_FOREGRD_APP,
55         /* Function */
56         LOGD_AUTOROTATE,
57         LOGD_MOTION,
58         LOGD_POWER_MODE,
59         /* Users */
60
61         LOGD_OBJECT_MAX,
62 };
63
64 enum logd_action {
65         LOGD_NONE_ACTION,
66         LOGD_ON,
67         LOGD_START,
68         LOGD_CONTINUE,
69         LOGD_STOP,
70         LOGD_OFF,
71         LOGD_CHANGED,
72         LOGD_ACTION_MAX,
73 };
74
75 /**
76  * enum logd_power_mode must be 3rd parameter
77  * for LOGD_POWER_MODE | LOGD_CHANGED event
78  */
79 enum logd_power_mode {
80         LOGD_POWER_MODE_NORMAL,
81         LOGD_POWER_MODE_POWERFUL,
82         LOGD_POWER_MODE_EMERGENCY,
83         LOGD_POWER_MODE_MAX, /* it's fake power mode, don't use it */
84         LOGD_POWER_MODE_CHARGED, /* it's fake power mode, don't use it */
85 };
86
87 enum logd_error {
88         LOGD_ERROR_OK,
89         LOGD_ERROR_INVALID_PARAM,
90         LOGD_ERROR_SDJOURNAL
91 };
92
93 /**
94  * Create new logd event, that will be sent to logd_grabber and stored in DB.
95  *
96  * @param object Object that was changed.
97  * @param action Type of event that occured with object.
98  * @param ... Message that clarify event's parameter. Required not for all
99  * event type. It can be <CODE>int</CODE> or <CODE>char*</CODE> depends on
100  * <CODE>object</CODE> and <CODE>action</CODE>.
101  * object=LOGD_BATTERY_SOC and action=LOGD_CHANGED, data=[battary level] (int)
102  * object=LOGD_DISPLAY and action=LOGD_CHANGED, data=[brigthness level] (int)
103  * object=LOGD_FOREGRD_APP and action=LOGD_CHANGED, data=[new foregraund appl] (char*)
104  * @return On success, LOGD_ERROR_OK. On error, other value from
105  * <CODE>enum logd_error</CODE>
106  *
107  * Example usage:
108  * @code
109  * logd_event(LOGD_WIFI, LOGD_ON);
110  * logd_event(LOGD_FOREGRD_APP, LOGD_CHANGED, "browser");
111  * @endcode
112  */
113 int logd_event(enum logd_object object, enum logd_action action, ...);
114
115 #ifdef __cplusplus
116 }
117 #endif
118
119 #endif /* _LOGD_ACTIVITY_LOGGING_H_ */