Initial import of libucore

This commit is contained in:
Nils O. Selåsdal
2012-10-29 23:07:32 +01:00
commit ed3866e49a
79 changed files with 6181 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
#ifndef UCORE_LOGGING_H_
#define UCORE_LOGGING_H_
enum UC_LOG_LEVEL {
UC_LL_NONE = 0,
UC_LL_DEBUG = 1,
UC_LL_INFO = 3,
UC_LL_WARNING = 5,
UC_LL_ERROR = 7,
};
enum UC_LOG_DESTINATION {
UC_LDEST_SYSLOG,
UC_LDEST_STDERR,
UC_LDEST_FILE,
};
struct uc_log_module {
int id;
const char *short_name;
const char *long_name;
int log_level;
};
struct uc_log_modules {
struct uc_log_module *mods;
int cnt;
};
struct uc_log_destination;
const char *uc_ll_2_str(enum UC_LOG_LEVEL l);
struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location);
struct uc_log_destination *uc_log_new_syslog(const char *ident, int facility, int log_level, int log_location);
struct uc_log_destination *uc_log_new_file(const char *filename, int log_level, int log_location);
void uc_log_add_destination(struct uc_log_destination *dest);
void uc_log_remove_destination(struct uc_log_destination *dest);
int uc_log_module_set_loglevel(int module, enum UC_LOG_LEVEL level);
int uc_log_reopen_files(void);
void uc_log_init(struct uc_log_modules *user_modules);
void uc_logf(int log_level, int module, const char *file, int line, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
#ifdef DEBUG
# define UC_DEBUGF(mod, fmt, ...) uc_logf(UC_LL_DEBUG, mod, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
#else
# define UC_DEBUGF(mod, fmt, ...)
#endif
#define UC_LOGF(lvl, mod, fmt, ...) uc_logf(lvl, mod, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
#endif