Remove setting log level for a module, implement
setting log level for a destination
This commit is contained in:
@@ -175,6 +175,13 @@ void uc_log_add_destination(struct uc_log_destination *dest);
|
||||
*/
|
||||
void uc_log_remove_destination(struct uc_log_destination *dest);
|
||||
|
||||
/** Change the log level of a destination..
|
||||
*
|
||||
* @param dest destination for which to set the log level
|
||||
* @param level The new log level
|
||||
*/
|
||||
void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LOG_LEVEL level);
|
||||
|
||||
/** Remove and free a destination.
|
||||
* This frees the memory allocated to the destination. For
|
||||
* UC_LDEST_FILE the log file is closed.
|
||||
@@ -187,14 +194,6 @@ void uc_log_remove_destination(struct uc_log_destination *dest);
|
||||
*/
|
||||
void uc_log_delete_destination(struct uc_log_destination *dest);
|
||||
|
||||
/** Change the log level of a module.
|
||||
*
|
||||
* @param module The module to change, matched against the id member of a struct uc_log_module
|
||||
* @param level The log level for this module
|
||||
*
|
||||
* @return 0 on success, non-zero if the module was not found.
|
||||
*/
|
||||
int uc_log_module_set_loglevel(int module, enum UC_LOG_LEVEL level);
|
||||
|
||||
/** Closes and re-opens all the UC_LDEST_FILE log destinations.
|
||||
* Intended for use when a log file is rotated externally.
|
||||
|
||||
+9
-19
@@ -294,6 +294,15 @@ 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)
|
||||
{
|
||||
pthread_mutex_lock(&g_log_lock);
|
||||
|
||||
dest->log_level = level;
|
||||
|
||||
pthread_mutex_unlock(&g_log_lock);
|
||||
}
|
||||
|
||||
static int uc_log_reopen_file(struct uc_log_destination *dest)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -337,25 +346,6 @@ void uc_log_init(struct uc_log_modules *user_modules)
|
||||
g_modules = *user_modules;
|
||||
}
|
||||
|
||||
int uc_log_module_set_loglevel(int module, enum UC_LOG_LEVEL level)
|
||||
{
|
||||
int rc = -1;
|
||||
int i;
|
||||
|
||||
pthread_mutex_lock(&g_log_lock);
|
||||
|
||||
for (i = 0; i < g_modules.cnt; i++) {
|
||||
if (g_modules.mods[i].id == module) {
|
||||
g_modules.mods[i].log_level = level;
|
||||
rc = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&g_log_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline void uc_vlog_file(const struct uc_log_args *args, const char *fmt, va_list ap)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user