sensord: resize message size
[platform/core/system/sensord.git] / src / shared / sensor_log.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 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 #ifndef __SENSOR_LOG_H__
21 #define __SENSOR_LOG_H__
22
23 #include <dlog/dlog.h>
24 #include <sys/types.h>
25
26 #ifdef LOG_TAG
27         #undef LOG_TAG
28 #endif
29 #define LOG_TAG "SENSOR"
30
31 /* Logging and Error Handling */
32 #define _I SLOGI
33 #define _D SLOGD
34 #define _W SLOGW
35 #define _E SLOGE
36 #define _SI SECURE_SLOGI
37 #define _SD SECURE_SLOGD
38 #define _SW SECURE_SLOGW
39 #define _SE SECURE_SLOGE
40
41 #define _ERRNO(errno, tag, fmt, arg...) \
42         do { \
43                 char buf[1024]; \
44                 char *error = strerror_r(errno, buf, 1024); \
45                 if (!error) { \
46                         _E("Failed to strerror_r()"); \
47                         break; \
48                 } \
49                 tag(fmt" (%s[%d])", ##arg, error, errno); \
50         } while (0)
51
52 #define warn_if(expr, fmt, arg...) \
53         do { if (expr) { _E(fmt, ##arg); } } while (0)
54
55 #define ret_if(expr) \
56         do { if (expr) { return; } } while (0)
57
58 #define retv_if(expr, val) \
59         do { if (expr) { return (val); } } while (0)
60
61 #define retm_if(expr, fmt, arg...) \
62         do { if (expr) { _E(fmt, ##arg); return; } } while (0)
63
64 #define retvm_if(expr, val, fmt, arg...) \
65         do { if (expr) { _E(fmt, ##arg); return (val); } } while (0)
66
67 #define LOG_DUMP(fp, fmt, arg...) \
68         do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while (0)
69
70 #endif /* __SENSOR_LOG_H__ */