Add some comments

This commit is contained in:
Nils O. Selåsdal
2012-11-05 23:12:17 +01:00
parent 56eb4b84b4
commit 99598c7add
+8 -2
View File
@@ -12,10 +12,12 @@
struct uc_log_destination { struct uc_log_destination {
SLIST_ENTRY(uc_log_destination) entry; SLIST_ENTRY(uc_log_destination) entry;
enum UC_LOG_DESTINATION dest_type; enum UC_LOG_DESTINATION dest_type;
//log level for this destination
int log_level; int log_level;
//Whether to log the source file name and line number
int log_location; int log_location;
union { union {
//for syslog //for syslog openlog()
struct { struct {
char *ident; char *ident;
int facility; int facility;
@@ -28,6 +30,7 @@ struct uc_log_destination {
} type; } type;
}; };
/* Helper struct for arguments to our main logging function */
struct uc_log_args { struct uc_log_args {
struct uc_log_destination *dest; struct uc_log_destination *dest;
const struct uc_log_module *module; const struct uc_log_module *module;
@@ -51,6 +54,8 @@ static const struct uc_log_module unknown_module = {
}; };
//All destinations. The log_lock must be held while accessing
//this list an anything contained within it.
static SLIST_HEAD(, uc_log_destination) destinations; static SLIST_HEAD(, uc_log_destination) destinations;
inline const char *uc_ll_2_str(enum UC_LOG_LEVEL l) inline const char *uc_ll_2_str(enum UC_LOG_LEVEL l)
@@ -180,6 +185,7 @@ void uc_log_add_destination(struct uc_log_destination *dest)
pthread_mutex_unlock(&log_lock); pthread_mutex_unlock(&log_lock);
} }
//hold 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 uc_log_destination *dest)
{ {
struct uc_log_destination *it; struct uc_log_destination *it;
@@ -212,7 +218,7 @@ void uc_log_delete_destination(struct uc_log_destination *dest)
pthread_mutex_lock(&log_lock); pthread_mutex_lock(&log_lock);
//remove it //remove it, it's ok if the destination is already removed
uc_log_remove_dest_unlocked(dest); uc_log_remove_dest_unlocked(dest);
//clean up, according to the type //clean up, according to the type