Adhere to coding style in logging module (struct uc_log_destination->

struct UCLogDestination, and similar for other structs)
This commit is contained in:
Nils O. Selåsdal
2014-01-07 23:39:01 +01:00
parent 74b6a65bd2
commit 0e2d4f07c3
5 changed files with 108 additions and 108 deletions
+21 -21
View File
@@ -18,7 +18,7 @@
* IO * IO
*}; *};
* *
* struct uc_log_module modules[] = { * struct UCLogModule modules[] = {
* { * {
* .id = POLLER, * .id = POLLER,
* .short_name = "POLLER", * .short_name = "POLLER",
@@ -38,7 +38,7 @@
* .log_level == UC_LL_DEBUG * .log_level == UC_LL_DEBUG
* } * }
* }; * };
* struct uc_log_modules m = { * struct UCLogModules m = {
* .mods = modules, * .mods = modules,
* .cnt = ARRAY_SIZE(modules) * .cnt = ARRAY_SIZE(modules)
* }; * };
@@ -100,13 +100,13 @@ enum UC_LOG_DESTINATION {
* and allow the log message to identigy which module the * and allow the log message to identigy which module the
* log message originates from * log message originates from
*/ */
struct uc_log_module { struct UCLogModule {
/** The id of the log module. /** The id of the log module.
* This is the id one specifies in the various log * This is the id one specifies in the various log
* functions/macros. * functions/macros.
* Within the struct uc_log_modules, this id must start * Within the struct UCLogModules, this id must start
* at 0 and be incremented consecutively, being equal * at 0 and be incremented consecutively, being equal
* to the index within struct uc_log_modules.mods * to the index within struct UCLogModules.mods
*/ */
int id; int id;
@@ -122,15 +122,15 @@ struct uc_log_module {
int log_level; int log_level;
}; };
/* A collection of struct uc_log_module */ /* A collection of struct UCLogModule */
struct uc_log_modules { struct UCLogModules {
/* Pointer to the first element of the array */ /* Pointer to the first element of the array */
struct uc_log_module *mods; struct UCLogModule *mods;
/** The number of elements in the mods array. */ /** The number of elements in the mods array. */
int cnt; int cnt;
}; };
struct uc_log_destination; struct UCLogDestination;
/* Returns a string representation of the log level. /* Returns a string representation of the log level.
@@ -150,7 +150,7 @@ const char *uc_ll_2_str(enum UC_LOG_LEVEL l);
* @return An opaque uc_log_destination that can be added as a destination to * @return An opaque uc_log_destination that can be added as a destination to
* the ucore logging system * the ucore logging system
*/ */
struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location); struct UCLogDestination *uc_log_new_stderr(int log_level, int log_location);
/* creates a new uc_log_destination for logging to syslog /* creates a new uc_log_destination for logging to syslog
* *
@@ -163,7 +163,7 @@ struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location);
* @return An opaque uc_log_destination that can be added as a destination to * @return An opaque uc_log_destination that can be added as a destination to
* the ucore logging system * the ucore logging system
*/ */
struct uc_log_destination *uc_log_new_syslog(const char *ident, int facility, int log_level, int log_location); struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, int log_level, int log_location);
/* creates a new uc_log_destination for printing on stderr. /* creates a new uc_log_destination for printing on stderr.
* *
@@ -174,13 +174,13 @@ struct uc_log_destination *uc_log_new_syslog(const char *ident, int facility, in
* @param return An opaque uc_log_destination that can be added as a destination to * @param return An opaque uc_log_destination that can be added as a destination to
* the ucore logging system * the ucore logging system
*/ */
struct uc_log_destination *uc_log_new_file(const char *filename, int log_level, int log_location); struct UCLogDestination *uc_log_new_file(const char *filename, int log_level, int log_location);
/** Add a uc_log_destination to the logging system. /** Add a uc_log_destination to the logging system.
* *
* @param dest The uc_log_destination to add. * @param dest The uc_log_destination to add.
*/ */
void uc_log_add_destination(struct uc_log_destination *dest); void uc_log_add_destination(struct UCLogDestination *dest);
/** Remove a log destination. /** Remove a log destination.
* Note that this does not free the destination, it can be readded later. * Note that this does not free the destination, it can be readded later.
@@ -188,14 +188,14 @@ void uc_log_add_destination(struct uc_log_destination *dest);
* *
* @param dest The uc_log_destination to remove. * @param dest The uc_log_destination to remove.
*/ */
void uc_log_remove_destination(struct uc_log_destination *dest); void uc_log_remove_destination(struct UCLogDestination *dest);
/** Change the log level of a destination.. /** Change the log level of a destination..
* *
* @param dest destination for which to set the log level * @param dest destination for which to set the log level
* @param level The new log level * @param level The new log level
*/ */
void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LOG_LEVEL level); void uc_log_destination_set_loglevel(struct UCLogDestination *dest, enum UC_LOG_LEVEL level);
/** Change whether to log the location (file/line no.) of logging /** Change whether to log the location (file/line no.) of logging
* output on a destination, * output on a destination,
@@ -203,7 +203,7 @@ void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LO
* @param dest log destination to change * @param dest log destination to change
* @param log_location 1=log the locaton, 0=don't log the location * @param log_location 1=log the locaton, 0=don't log the location
*/ */
void uc_log_destination_set_log_location(struct uc_log_destination *dest, int log_location); void uc_log_destination_set_log_location(struct UCLogDestination *dest, int log_location);
/** Remove and free a destination. /** Remove and free a destination.
* This frees the memory allocated to the destination. For * This frees the memory allocated to the destination. For
* UC_LDEST_FILE the log file is closed. * UC_LDEST_FILE the log file is closed.
@@ -214,7 +214,7 @@ void uc_log_destination_set_log_location(struct uc_log_destination *dest, int lo
* *
* @param dest The destination to delete. * @param dest The destination to delete.
*/ */
void uc_log_delete_destination(struct uc_log_destination *dest); void uc_log_delete_destination(struct UCLogDestination *dest);
/** Set the log level for a particular module on this destination /** Set the log level for a particular module on this destination
@@ -224,7 +224,7 @@ void uc_log_delete_destination(struct uc_log_destination *dest);
* @param log_level new log level to set for the module * @param log_level new log level to set for the module
*/ */
void uc_log_destination_set_module_loglevel( void uc_log_destination_set_module_loglevel(
struct uc_log_destination *dest, struct UCLogDestination *dest,
int module, int module,
enum UC_LOG_LEVEL log_level enum UC_LOG_LEVEL log_level
); );
@@ -238,7 +238,7 @@ void uc_log_destination_set_module_loglevel(
* *
* SHORT_NAME_1=LEVEL:SHORT_NAME_2=LEVEL:SHORT_NAME_N=LEVEL * SHORT_NAME_1=LEVEL:SHORT_NAME_2=LEVEL:SHORT_NAME_N=LEVEL
* *
* The SHORT_NAME_N is the .short_name within a struct uc_log_module * The SHORT_NAME_N is the .short_name within a struct UCLogModule
* LEVEL is one of DEBUG, INFO, WARNING, ERROR or NONE * LEVEL is one of DEBUG, INFO, WARNING, ERROR or NONE
* Example: * Example:
* DB=DEBUG:IO=ERROR:POLLER=INFO * DB=DEBUG:IO=ERROR:POLLER=INFO
@@ -250,7 +250,7 @@ void uc_log_destination_set_module_loglevel(
* @parama log_mask the log mask as described above to set. * @parama log_mask the log mask as described above to set.
*/ */
void uc_log_destination_set_mask( void uc_log_destination_set_mask(
struct uc_log_destination *dest, struct UCLogDestination *dest,
const char *log_mask const char *log_mask
); );
@@ -266,7 +266,7 @@ int uc_log_reopen_files(void);
* *
* @param user_struct containing an array of all the modules defined by the application. * @param user_struct containing an array of all the modules defined by the application.
*/ */
void uc_log_init(struct uc_log_modules *user_modules); void uc_log_init(struct UCLogModules *user_modules);
void uc_logf(int log_level, int module, int raw, void uc_logf(int log_level, int module, int raw,
const char *location, const char *fmt, ...) const char *location, const char *fmt, ...)
+39 -39
View File
@@ -11,18 +11,18 @@
//used to realise per destination settings //used to realise per destination settings
struct uc_log_module_setting { struct UCLogModule_setting {
int log_level; int log_level;
}; };
struct uc_log_destination { struct UCLogDestination {
SLIST_ENTRY(uc_log_destination) entry; SLIST_ENTRY(UCLogDestination) entry;
enum UC_LOG_DESTINATION dest_type; enum UC_LOG_DESTINATION dest_type;
//log level for this destination //log level for this destination
int log_level; int log_level;
//Whether to log the source file name and line number //Whether to log the source file name and line number
int log_location; int log_location;
struct uc_log_module_setting *module_settings; struct UCLogModule_setting *module_settings;
union { union {
//for syslog openlog() //for syslog openlog()
struct { struct {
@@ -38,9 +38,9 @@ struct uc_log_destination {
}; };
/* Helper struct for arguments to our main logging function */ /* Helper struct for arguments to our main logging function */
struct uc_log_args { struct UCLogArgs {
struct uc_log_destination *dest; struct UCLogDestination *dest;
const struct uc_log_module *module; const struct UCLogModule *module;
int log_level; int log_level;
const char *location; const char *location;
int raw; int raw;
@@ -51,9 +51,9 @@ struct uc_log_args {
//this lock before accessing any the global data. //this lock before accessing any the global data.
static pthread_mutex_t g_log_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_log_lock = PTHREAD_MUTEX_INITIALIZER;
static struct uc_log_modules g_modules; static struct UCLogModules g_modules;
static const struct uc_log_module g_unknown_module = { static const struct UCLogModule g_unknown_module = {
.id = -1, .id = -1,
.short_name = "UNKNOWN", .short_name = "UNKNOWN",
.long_name = "Unknown log module", .long_name = "Unknown log module",
@@ -63,8 +63,8 @@ static const struct uc_log_module g_unknown_module = {
//All destinations. The g_log_lock must be held while accessing //All destinations. The g_log_lock must be held while accessing
//this list an anything contained within it. //this list an anything contained within it.
static SLIST_HEAD(, uc_log_destination) g_destinations; static SLIST_HEAD(, UCLogDestination) g_destinations;
static int uc_log_reopen_file(struct uc_log_destination *dest); static int uc_log_reopen_file(struct UCLogDestination *dest);
//Uses enum UC_LOG_LEVEL as index //Uses enum UC_LOG_LEVEL as index
static const char *const g_log_levels[] = { static const char *const g_log_levels[] = {
"UNKNOWN_0", "UNKNOWN_0",
@@ -122,7 +122,7 @@ static inline int uc_ll_2_syslog(enum UC_LOG_LEVEL l)
} }
//Note, this grabs the global lock //Note, this grabs the global lock
static int uc_log_init_settings(struct uc_log_destination *dest) static int uc_log_init_settings(struct UCLogDestination *dest)
{ {
int i; int i;
int rc = -1; int rc = -1;
@@ -143,9 +143,9 @@ static int uc_log_init_settings(struct uc_log_destination *dest)
return rc; return rc;
} }
struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location) struct UCLogDestination *uc_log_new_stderr(int log_level, int log_location)
{ {
struct uc_log_destination *dest = calloc(1, sizeof *dest); struct UCLogDestination *dest = calloc(1, sizeof *dest);
if(dest == NULL) if(dest == NULL)
return NULL; return NULL;
@@ -163,9 +163,9 @@ struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location)
return dest; return dest;
} }
struct uc_log_destination *uc_log_new_syslog(const char *ident, int facility, int log_level, int log_location) struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, int log_level, int log_location)
{ {
struct uc_log_destination *dest = calloc(1, sizeof *dest); struct UCLogDestination *dest = calloc(1, sizeof *dest);
char *id; char *id;
if (dest == NULL) if (dest == NULL)
@@ -195,9 +195,9 @@ struct uc_log_destination *uc_log_new_syslog(const char *ident, int facility, in
return dest; return dest;
} }
struct uc_log_destination *uc_log_new_file(const char *filename, int log_level, int log_location) struct UCLogDestination *uc_log_new_file(const char *filename, int log_level, int log_location)
{ {
struct uc_log_destination *dest = calloc(1, sizeof *dest); struct UCLogDestination *dest = calloc(1, sizeof *dest);
FILE *f; FILE *f;
char *name; char *name;
@@ -235,9 +235,9 @@ struct uc_log_destination *uc_log_new_file(const char *filename, int log_level,
return dest; return dest;
} }
void uc_log_add_destination(struct uc_log_destination *dest) void uc_log_add_destination(struct UCLogDestination *dest)
{ {
struct uc_log_destination *it; struct UCLogDestination *it;
if (dest == NULL) if (dest == NULL)
return; return;
@@ -259,9 +259,9 @@ void uc_log_add_destination(struct uc_log_destination *dest)
} }
//hold g_log_lock while calling this. //hold g_log_lock while calling this.
static inline void uc_log_remove_dest_unlocked(struct uc_log_destination *dest) static inline void uc_log_remove_dest_unlocked(struct UCLogDestination *dest)
{ {
struct uc_log_destination *it; struct UCLogDestination *it;
//check that it's not already removed //check that it's not already removed
SLIST_FOREACH(it, &g_destinations, entry) { SLIST_FOREACH(it, &g_destinations, entry) {
@@ -270,11 +270,11 @@ static inline void uc_log_remove_dest_unlocked(struct uc_log_destination *dest)
} }
if (it != NULL) { if (it != NULL) {
SLIST_REMOVE(&g_destinations, dest, uc_log_destination, entry); SLIST_REMOVE(&g_destinations, dest, UCLogDestination, entry);
} }
} }
void uc_log_remove_destination(struct uc_log_destination *dest) void uc_log_remove_destination(struct UCLogDestination *dest)
{ {
if (dest == NULL) if (dest == NULL)
return; return;
@@ -286,7 +286,7 @@ void uc_log_remove_destination(struct uc_log_destination *dest)
pthread_mutex_unlock(&g_log_lock); pthread_mutex_unlock(&g_log_lock);
} }
void uc_log_delete_destination(struct uc_log_destination *dest) void uc_log_delete_destination(struct UCLogDestination *dest)
{ {
if (dest == NULL) if (dest == NULL)
return; return;
@@ -320,7 +320,7 @@ void uc_log_delete_destination(struct uc_log_destination *dest)
pthread_mutex_unlock(&g_log_lock); pthread_mutex_unlock(&g_log_lock);
} }
void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LOG_LEVEL level) void uc_log_destination_set_loglevel(struct UCLogDestination *dest, enum UC_LOG_LEVEL level)
{ {
if (dest == NULL) if (dest == NULL)
return; return;
@@ -332,7 +332,7 @@ void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LO
pthread_mutex_unlock(&g_log_lock); pthread_mutex_unlock(&g_log_lock);
} }
void uc_log_destination_set_log_location(struct uc_log_destination *dest, int log_location) void uc_log_destination_set_log_location(struct UCLogDestination *dest, int log_location)
{ {
if (dest == NULL) if (dest == NULL)
return; return;
@@ -344,7 +344,7 @@ void uc_log_destination_set_log_location(struct uc_log_destination *dest, int lo
pthread_mutex_unlock(&g_log_lock); pthread_mutex_unlock(&g_log_lock);
} }
static int uc_log_reopen_file(struct uc_log_destination *dest) static int uc_log_reopen_file(struct UCLogDestination *dest)
{ {
int rc = 0; int rc = 0;
@@ -368,7 +368,7 @@ static int uc_log_reopen_file(struct uc_log_destination *dest)
int uc_log_reopen_files(void) int uc_log_reopen_files(void)
{ {
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc = 0; int rc = 0;
pthread_mutex_lock(&g_log_lock); pthread_mutex_lock(&g_log_lock);
@@ -385,15 +385,15 @@ int uc_log_reopen_files(void)
return rc; return rc;
} }
void uc_log_init(struct uc_log_modules *user_modules) void uc_log_init(struct UCLogModules *user_modules)
{ {
g_modules = *user_modules; g_modules = *user_modules;
} }
static inline void uc_vlog_file(const struct uc_log_args *args, const char *fmt, va_list ap) static inline void uc_vlog_file(const struct UCLogArgs *args, const char *fmt, va_list ap)
{ {
struct uc_log_destination *dest = args->dest; struct UCLogDestination *dest = args->dest;
char time_buf[48]; char time_buf[48];
time_t now; time_t now;
struct tm t; struct tm t;
@@ -431,9 +431,9 @@ static inline void uc_vlog_file(const struct uc_log_args *args, const char *fmt,
// though stderr could be redirected to a file // though stderr could be redirected to a file
} }
static inline void uc_vlog_syslog(const struct uc_log_args *args, const char *fmt, va_list ap) static inline void uc_vlog_syslog(const struct UCLogArgs *args, const char *fmt, va_list ap)
{ {
struct uc_log_destination *dest = args->dest; struct UCLogDestination *dest = args->dest;
int pri = uc_ll_2_syslog(args->log_level); int pri = uc_ll_2_syslog(args->log_level);
@@ -470,7 +470,7 @@ log:
} }
void uc_log_destination_set_module_loglevel( void uc_log_destination_set_module_loglevel(
struct uc_log_destination *dest, struct UCLogDestination *dest,
int module, int module,
enum UC_LOG_LEVEL log_level enum UC_LOG_LEVEL log_level
) )
@@ -488,7 +488,7 @@ void uc_log_destination_set_module_loglevel(
void uc_log_destination_set_mask( void uc_log_destination_set_mask(
struct uc_log_destination *dest, struct UCLogDestination *dest,
const char *log_mask const char *log_mask
) )
{ {
@@ -546,7 +546,7 @@ void uc_logf(int log_level, int module, int raw,
const char *location, const char *fmt, ...) const char *location, const char *fmt, ...)
{ {
va_list ap; va_list ap;
struct uc_log_destination *dest; struct UCLogDestination *dest;
va_start(ap, fmt); va_start(ap, fmt);
@@ -554,7 +554,7 @@ void uc_logf(int log_level, int module, int raw,
//do logging for each destination //do logging for each destination
SLIST_FOREACH(dest, &g_destinations, entry) { SLIST_FOREACH(dest, &g_destinations, entry) {
const struct uc_log_module *log_module; const struct UCLogModule *log_module;
va_list apc; va_list apc;
int module_log_level; int module_log_level;
@@ -577,7 +577,7 @@ void uc_logf(int log_level, int module, int raw,
if (log_level < module_log_level) if (log_level < module_log_level)
continue; continue;
const struct uc_log_args args = { const struct UCLogArgs args = {
.dest = dest, .dest = dest,
.module = log_module, .module = log_module,
.log_level = log_level, .log_level = log_level,
+3 -3
View File
@@ -6,7 +6,7 @@ enum {
CC, CC,
HO HO
}; };
struct uc_log_module module_arr[] = { struct UCLogModule module_arr[] = {
{ {
MAIN, MAIN,
"MAIN", "MAIN",
@@ -28,14 +28,14 @@ struct uc_log_module module_arr[] = {
} }
}; };
struct uc_log_modules modules = { struct UCLogModules modules = {
.mods = module_arr, .mods = module_arr,
.cnt = ARRAY_SIZE(module_arr), .cnt = ARRAY_SIZE(module_arr),
}; };
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct uc_log_destination *dest; struct UCLogDestination *dest;
uc_log_init(&modules); uc_log_init(&modules);
dest = uc_log_new_file("test.log", UC_LL_INFO, 1); dest = uc_log_new_file("test.log", UC_LL_INFO, 1);
uc_log_add_destination(dest); uc_log_add_destination(dest);
+42 -42
View File
@@ -32,18 +32,18 @@ static void logging_rm_subdir(void)
START_TEST (test_logfile_location) START_TEST (test_logfile_location)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -66,18 +66,18 @@ END_TEST
START_TEST (test_logfile_delete_destination) START_TEST (test_logfile_delete_destination)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -114,18 +114,18 @@ END_TEST
START_TEST (test_logfile_no_location) START_TEST (test_logfile_no_location)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -144,18 +144,18 @@ END_TEST
START_TEST (test_logfile_loglevel_surpressed_dest) START_TEST (test_logfile_loglevel_surpressed_dest)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -176,19 +176,19 @@ END_TEST
START_TEST (test_logfile_loglevel_surpressed_module) START_TEST (test_logfile_loglevel_surpressed_module)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
//file destination have UC_LL_WARNING, so nothing should be logged //file destination have UC_LL_WARNING, so nothing should be logged
.log_level = UC_LL_WARNING, .log_level = UC_LL_WARNING,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -208,18 +208,18 @@ END_TEST
START_TEST (test_logfile_reopen_files) START_TEST (test_logfile_reopen_files)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -251,18 +251,18 @@ END_TEST
START_TEST (test_logfile_remove_dest) START_TEST (test_logfile_remove_dest)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest1, *dest2; struct UCLogDestination *dest1, *dest2;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -296,17 +296,17 @@ END_TEST
START_TEST (test_logfile_full_filesystem) START_TEST (test_logfile_full_filesystem)
//logging to a full filesystem shouldn't crash //logging to a full filesystem shouldn't crash
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct uc_log_destination *dest; struct UCLogDestination *dest;
int i; int i;
@@ -326,17 +326,17 @@ END_TEST
START_TEST (test_logfile_invalid_file) START_TEST (test_logfile_invalid_file)
//check behavior when a log file cannot be opened //check behavior when a log file cannot be opened
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct uc_log_destination *dest; struct UCLogDestination *dest;
uc_log_init(&mods); uc_log_init(&mods);
@@ -347,17 +347,17 @@ END_TEST
START_TEST (test_logfile_invalid_file_after_reopen) START_TEST (test_logfile_invalid_file_after_reopen)
//check behavior when a log file cannot be re-opened //check behavior when a log file cannot be re-opened
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -386,18 +386,18 @@ END_TEST
START_TEST (test_logfile_raw) START_TEST (test_logfile_raw)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -416,7 +416,7 @@ END_TEST
START_TEST (test_logfile_dest_mask) START_TEST (test_logfile_dest_mask)
struct uc_log_module m[] = { struct UCLogModule m[] = {
{ {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
@@ -430,12 +430,12 @@ START_TEST (test_logfile_dest_mask)
.log_level = UC_LL_WARNING, .log_level = UC_LL_WARNING,
} }
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = m, .mods = m,
.cnt = 2, .cnt = 2,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -462,18 +462,18 @@ END_TEST
START_TEST (test_loglevel_module_none) START_TEST (test_loglevel_module_none)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_NONE, .log_level = UC_LL_NONE,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
@@ -491,18 +491,18 @@ END_TEST
START_TEST (test_loglevel_dest_none) START_TEST (test_loglevel_dest_none)
struct uc_log_module m = { struct UCLogModule m = {
.id = 0, .id = 0,
.short_name = "MOD1", .short_name = "MOD1",
.long_name = "Module 1", .long_name = "Module 1",
.log_level = UC_LL_DEBUG, .log_level = UC_LL_DEBUG,
}; };
struct uc_log_modules mods = { struct UCLogModules mods = {
.mods = &m, .mods = &m,
.cnt = 1, .cnt = 1,
}; };
struct stat st; struct stat st;
struct uc_log_destination *dest; struct UCLogDestination *dest;
int rc; int rc;
uc_log_init(&mods); uc_log_init(&mods);
+3 -3
View File
@@ -25,7 +25,7 @@
#define PEER_HB_SEC 5 #define PEER_HB_SEC 5
#define PEER_HB_MISS 3 #define PEER_HB_MISS 3
static struct uc_log_module modules[] = { static struct UCLogModule modules[] = {
{ {
.id = LMAIN, .id = LMAIN,
.short_name = "MAIN", .short_name = "MAIN",
@@ -34,7 +34,7 @@ static struct uc_log_module modules[] = {
} }
}; };
static struct uc_log_modules log_modules = { static struct UCLogModules log_modules = {
.mods = modules, .mods = modules,
.cnt = ARRAY_SIZE(modules) .cnt = ARRAY_SIZE(modules)
}; };
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
uint16_t local_port = 23456; uint16_t local_port = 23456;
uint16_t remote_port = 23456; uint16_t remote_port = 23456;
int c; int c;
struct uc_log_destination *dest; struct UCLogDestination *dest;
srand(getpid()); srand(getpid());