clibdocker  0.1.0-alpha.0
A Docker API for C
docker_log.h
Go to the documentation of this file.
1 
15 #ifndef LOG_H
16 #define LOG_H
17 
18 #include <stdio.h>
19 #include <stdarg.h>
20 #include "docker_common.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
27 #define LOG_VERSION "0.1.0"
28 
30 typedef void (*log_LockFn)(void *udata, int lock);
31 
32 enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
33 
39 #define docker_log_trace(...) docker_log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
40 
46 #define docker_log_debug(...) docker_log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
47 
53 #define docker_log_info(...) docker_log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
54 
60 #define docker_log_warn(...) docker_log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
61 
67 #define docker_log_error(...) docker_log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
68 
74 #define docker_log_fatal(...) docker_log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
75 
81 MODULE_API void docker_log_set_udata(void *udata);
82 
88 MODULE_API void docker_log_set_lock(log_LockFn fn);
89 
95 MODULE_API void docker_log_set_fp(FILE *fp);
96 
102 MODULE_API void docker_log_set_level(int level);
103 
109 MODULE_API void docker_log_set_quiet(int enable);
110 
120 MODULE_API void docker_log_log(int level, const char *file, int line, const char *fmt, ...);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif
Some common declarations.
void docker_log_set_udata(void *udata)
Set the user data for the logger.
Definition: docker_log.c:66
void docker_log_set_level(int level)
Enable the given log level.
Definition: docker_log.c:81
void docker_log_set_lock(log_LockFn fn)
Set the lock function for the logger.
Definition: docker_log.c:71
void docker_log_set_quiet(int enable)
Turn off the given log level.
Definition: docker_log.c:86
void docker_log_log(int level, const char *file, int line, const char *fmt,...)
Internal method for logging, called by all specific log level loggers.
Definition: docker_log.c:91
void(* log_LockFn)(void *udata, int lock)
Definition: docker_log.h:30
void docker_log_set_fp(FILE *fp)
Set the file pointer for the logger.
Definition: docker_log.c:76