Add log_debug
This commit is contained in:
parent
1112be661e
commit
601d73c9ec
@ -25,6 +25,11 @@ int main(int argc, char *argv[])
|
|||||||
camera_t camera;
|
camera_t camera;
|
||||||
int http_fd = -1;
|
int http_fd = -1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
const char *env;
|
||||||
|
|
||||||
|
if (env = getenv("DEBUG")) {
|
||||||
|
log_debug = strstr(env, "1") ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
camera_init(&camera);
|
camera_init(&camera);
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "hw/v4l2.h"
|
#include "hw/v4l2.h"
|
||||||
|
|
||||||
|
int log_debug = 0;
|
||||||
|
|
||||||
int xioctl(const char *name, int fd, int request, void *arg)
|
int xioctl(const char *name, int fd, int request, void *arg)
|
||||||
{
|
{
|
||||||
int retries = XIOCTL_RETRIES;
|
int retries = XIOCTL_RETRIES;
|
||||||
|
@ -25,13 +25,15 @@
|
|||||||
|
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||||
|
|
||||||
|
extern int log_debug;
|
||||||
|
|
||||||
// assumes that name is first item
|
// assumes that name is first item
|
||||||
#define dev_name(dev) (dev ? *(const char**)dev : "?")
|
#define dev_name(dev) (dev ? *(const char**)dev : "?")
|
||||||
#define E_LOG_ERROR(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); goto error; } while(0)
|
#define E_LOG_ERROR(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); goto error; } while(0)
|
||||||
#define E_LOG_PERROR(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); exit(-1); } while(0)
|
#define E_LOG_PERROR(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); exit(-1); } while(0)
|
||||||
#define E_LOG_INFO(dev, _msg, ...) fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__)
|
#define E_LOG_INFO(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); } while(0)
|
||||||
#define E_LOG_VERBOSE(dev, _msg, ...) fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__)
|
#define E_LOG_VERBOSE(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); } while(0)
|
||||||
#define E_LOG_DEBUG(dev, _msg, ...) fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__)
|
#define E_LOG_DEBUG(dev, _msg, ...) do { if (log_debug) { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); } } while(0)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char buf[10];
|
char buf[10];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user