Add uc_log_destination_set_log_location, fix signed/unsigned use
This commit is contained in:
@@ -182,6 +182,13 @@ void uc_log_remove_destination(struct uc_log_destination *dest);
|
|||||||
*/
|
*/
|
||||||
void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LOG_LEVEL level);
|
void uc_log_destination_set_loglevel(struct uc_log_destination *dest, enum UC_LOG_LEVEL level);
|
||||||
|
|
||||||
|
/** Change whether to log the location (file/line no.) of logging
|
||||||
|
* output on a destination,
|
||||||
|
*
|
||||||
|
* @param dest log destination to change
|
||||||
|
* @param log_location 1=log the locaton, 0=don't log the location
|
||||||
|
*/
|
||||||
|
void uc_log_destination_set_log_location(struct uc_log_destination *dest, int log_location);
|
||||||
/** Remove and free a destination.
|
/** Remove and free a destination.
|
||||||
* This frees the memory allocated to the destination. For
|
* This frees the memory allocated to the destination. For
|
||||||
* UC_LDEST_FILE the log file is closed.
|
* UC_LDEST_FILE the log file is closed.
|
||||||
|
|||||||
+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)
|
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];
|
return g_debug_levels[l];
|
||||||
} else {
|
} else {
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns -1 if the string is not a known log level
|
//returns if the string is not a known log level
|
||||||
static enum UC_LOG_LEVEL uc_str_2_ll(const char *str)
|
static int uc_str_2_ll(const char *str)
|
||||||
{
|
{
|
||||||
size_t i;
|
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)
|
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);
|
pthread_mutex_lock(&g_log_lock);
|
||||||
|
|
||||||
dest->log_level = level;
|
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);
|
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)
|
static int uc_log_reopen_file(struct uc_log_destination *dest)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
if (dest == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (dest->type.file.file != NULL) {
|
if (dest->type.file.file != NULL) {
|
||||||
fclose(dest->type.file.file);
|
fclose(dest->type.file.file);
|
||||||
dest->type.file.file = NULL;
|
dest->type.file.file = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user