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>
26 #define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec)
31 #define LOG_TAG "SENSOR"
33 #define LOG_DUMP(fp, fmt, arg...) do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while (0)
38 #define DBG(...) do {} while (0)
49 #define _ERRNO(errno, tag, fmt, arg...) do { \
51 char *error = strerror_r(errno, buf, 1024); \
53 _E("Failed to strerror_r()"); \
56 tag(fmt" (%s[%d])", ##arg, error, errno); \
60 # define warn_if(expr, fmt, arg...) do { \
62 _D("(%s) -> " fmt, #expr, ##arg); \
65 # define ret_if(expr) do { \
67 _D("(%s) -> %s() return", #expr, __FUNCTION__); \
71 # define retv_if(expr, val) do { \
73 _D("(%s) -> %s() return", #expr, __FUNCTION__); \
77 # define retm_if(expr, fmt, arg...) do { \
80 _D("(%s) -> %s() return", #expr, __FUNCTION__); \
84 # define retvm_if(expr, val, fmt, arg...) do { \
87 _D("(%s) -> %s() return", #expr, __FUNCTION__); \
93 # define warn_if(expr, fmt, arg...) do { \
98 # define ret_if(expr) do { \
103 # define retv_if(expr, val) do { \
108 # define retm_if(expr, fmt, arg...) do { \
114 # define retvm_if(expr, val, fmt, arg...) do { \
128 const char* get_client_name(void);
129 bool get_proc_name(pid_t pid, char *process_name);
135 #endif /* _SENSOR_LOG_H_ */