4 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef __SENSOR_LOG_H__
21 #define __SENSOR_LOG_H__
23 #include <dlog/dlog.h>
24 #include <sys/types.h>
29 #define LOG_TAG "SENSOR"
31 /* Logging and Error Handling */
36 #define _SI SECURE_SLOGI
37 #define _SD SECURE_SLOGD
38 #define _SW SECURE_SLOGW
39 #define _SE SECURE_SLOGE
41 #define _ERRNO(errno, tag, fmt, arg...) \
44 char *error = strerror_r(errno, buf, 1024); \
46 _E("Failed to strerror_r()"); \
49 tag(fmt" (%s[%d])", ##arg, error, errno); \
52 #define warn_if(expr, fmt, arg...) \
53 do { if (expr) { _E(fmt, ##arg); } } while (0)
55 #define ret_if(expr) \
56 do { if (expr) { return; } } while (0)
58 #define retv_if(expr, val) \
59 do { if (expr) { return (val); } } while (0)
61 #define retm_if(expr, fmt, arg...) \
62 do { if (expr) { _E(fmt, ##arg); return; } } while (0)
64 #define retvm_if(expr, val, fmt, arg...) \
65 do { if (expr) { _E(fmt, ##arg); return (val); } } while (0)
67 #define LOG_DUMP(fp, fmt, arg...) \
68 do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while (0)
70 #endif /* __SENSOR_LOG_H__ */