Add uc_log_destination_set_log_location, fix signed/unsigned use
This commit is contained in:
+21
-3
@@ -80,15 +80,15 @@ static const char *const g_debug_levels[] = {
|
||||
|
||||
inline const char *uc_ll_2_str(enum UC_LOG_LEVEL l)
|
||||
{
|
||||
if (l >= 0 && l < (int)ARRAY_SIZE(g_debug_levels)) {
|
||||
if (l < ARRAY_SIZE(g_debug_levels)) {
|
||||
return g_debug_levels[l];
|
||||
} else {
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
||||
//returns -1 if the string is not a known log level
|
||||
static enum UC_LOG_LEVEL uc_str_2_ll(const char *str)
|
||||
//returns if the string is not a known log level
|
||||
static int uc_str_2_ll(const char *str)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -313,6 +313,9 @@ void uc_log_delete_destination(struct uc_log_destination *dest)
|
||||
|
||||
void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LOG_LEVEL level)
|
||||
{
|
||||
if (dest == NULL)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&g_log_lock);
|
||||
|
||||
dest->log_level = level;
|
||||
@@ -320,10 +323,25 @@ 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)
|
||||
{
|
||||
if (dest == NULL)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&g_log_lock);
|
||||
|
||||
dest->log_location = log_location;
|
||||
|
||||
pthread_mutex_unlock(&g_log_lock);
|
||||
}
|
||||
|
||||
static int uc_log_reopen_file(struct uc_log_destination *dest)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (dest == NULL)
|
||||
return -1;
|
||||
|
||||
if (dest->type.file.file != NULL) {
|
||||
fclose(dest->type.file.file);
|
||||
dest->type.file.file = NULL;
|
||||
|
||||
Reference in New Issue
Block a user