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
+39 -39
View File
@@ -11,18 +11,18 @@
//used to realise per destination settings
struct uc_log_module_setting {
struct UCLogModule_setting {
int log_level;
};
struct uc_log_destination {
SLIST_ENTRY(uc_log_destination) entry;
struct UCLogDestination {
SLIST_ENTRY(UCLogDestination) entry;
enum UC_LOG_DESTINATION dest_type;
//log level for this destination
int log_level;
//Whether to log the source file name and line number
int log_location;
struct uc_log_module_setting *module_settings;
struct UCLogModule_setting *module_settings;
union {
//for syslog openlog()
struct {
@@ -38,9 +38,9 @@ struct uc_log_destination {
};
/* Helper struct for arguments to our main logging function */
struct uc_log_args {
struct uc_log_destination *dest;
const struct uc_log_module *module;
struct UCLogArgs {
struct UCLogDestination *dest;
const struct UCLogModule *module;
int log_level;
const char *location;
int raw;
@@ -51,9 +51,9 @@ struct uc_log_args {
//this lock before accessing any the global data.
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,
.short_name = "UNKNOWN",
.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
//this list an anything contained within it.
static SLIST_HEAD(, uc_log_destination) g_destinations;
static int uc_log_reopen_file(struct uc_log_destination *dest);
static SLIST_HEAD(, UCLogDestination) g_destinations;
static int uc_log_reopen_file(struct UCLogDestination *dest);
//Uses enum UC_LOG_LEVEL as index
static const char *const g_log_levels[] = {
"UNKNOWN_0",
@@ -122,7 +122,7 @@ static inline int uc_ll_2_syslog(enum UC_LOG_LEVEL l)
}
//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 rc = -1;
@@ -143,9 +143,9 @@ static int uc_log_init_settings(struct uc_log_destination *dest)
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)
return NULL;
@@ -163,9 +163,9 @@ struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location)
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;
if (dest == NULL)
@@ -195,9 +195,9 @@ struct uc_log_destination *uc_log_new_syslog(const char *ident, int facility, in
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;
char *name;
@@ -235,9 +235,9 @@ struct uc_log_destination *uc_log_new_file(const char *filename, int log_level,
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)
return;
@@ -259,9 +259,9 @@ void uc_log_add_destination(struct uc_log_destination *dest)
}
//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
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) {
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)
return;
@@ -286,7 +286,7 @@ void uc_log_remove_destination(struct uc_log_destination *dest)
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)
return;
@@ -320,7 +320,7 @@ void uc_log_delete_destination(struct uc_log_destination *dest)
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)
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);
}
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)
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);
}
static int uc_log_reopen_file(struct uc_log_destination *dest)
static int uc_log_reopen_file(struct UCLogDestination *dest)
{
int rc = 0;
@@ -368,7 +368,7 @@ static int uc_log_reopen_file(struct uc_log_destination *dest)
int uc_log_reopen_files(void)
{
struct uc_log_destination *dest;
struct UCLogDestination *dest;
int rc = 0;
pthread_mutex_lock(&g_log_lock);
@@ -385,15 +385,15 @@ int uc_log_reopen_files(void)
return rc;
}
void uc_log_init(struct uc_log_modules *user_modules)
void uc_log_init(struct UCLogModules *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];
time_t now;
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
}
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);
@@ -470,7 +470,7 @@ log:
}
void uc_log_destination_set_module_loglevel(
struct uc_log_destination *dest,
struct UCLogDestination *dest,
int module,
enum UC_LOG_LEVEL log_level
)
@@ -488,7 +488,7 @@ void uc_log_destination_set_module_loglevel(
void uc_log_destination_set_mask(
struct uc_log_destination *dest,
struct UCLogDestination *dest,
const char *log_mask
)
{
@@ -546,7 +546,7 @@ void uc_logf(int log_level, int module, int raw,
const char *location, const char *fmt, ...)
{
va_list ap;
struct uc_log_destination *dest;
struct UCLogDestination *dest;
va_start(ap, fmt);
@@ -554,7 +554,7 @@ void uc_logf(int log_level, int module, int raw,
//do logging for each destination
SLIST_FOREACH(dest, &g_destinations, entry) {
const struct uc_log_module *log_module;
const struct UCLogModule *log_module;
va_list apc;
int module_log_level;
@@ -577,7 +577,7 @@ void uc_logf(int log_level, int module, int raw,
if (log_level < module_log_level)
continue;
const struct uc_log_args args = {
const struct UCLogArgs args = {
.dest = dest,
.module = log_module,
.log_level = log_level,