diff --git a/src/ucore_logging.c b/src/ucore_logging.c index bbf3231..d038bff 100644 --- a/src/ucore_logging.c +++ b/src/ucore_logging.c @@ -12,10 +12,12 @@ struct uc_log_destination { SLIST_ENTRY(uc_log_destination) 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; union { - //for syslog + //for syslog openlog() struct { char *ident; int facility; @@ -28,6 +30,7 @@ struct uc_log_destination { } type; }; +/* Helper struct for arguments to our main logging function */ struct uc_log_args { struct uc_log_destination *dest; 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; 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); } +//hold log_lock while calling this. static inline void uc_log_remove_dest_unlocked(struct uc_log_destination *dest) { struct uc_log_destination *it; @@ -212,7 +218,7 @@ void uc_log_delete_destination(struct uc_log_destination *dest) pthread_mutex_lock(&log_lock); - //remove it + //remove it, it's ok if the destination is already removed uc_log_remove_dest_unlocked(dest); //clean up, according to the type