- fixed bug in logger_t not storing the name of it
This commit is contained in:
parent
ffd555f58e
commit
96d72d323d
5 changed files with 33 additions and 8 deletions
|
@ -232,6 +232,7 @@ static status_t disable_level(private_logger_t *this, logger_level_t log_level)
|
|||
*/
|
||||
static status_t destroy(private_logger_t *this)
|
||||
{
|
||||
allocator_free(this->name);
|
||||
allocator_free(this);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -248,6 +249,11 @@ logger_t *logger_create(char *logger_name, logger_level_t log_level,FILE * outpu
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (logger_name == NULL)
|
||||
{
|
||||
logger_name = "";
|
||||
}
|
||||
|
||||
this->public.log = (status_t(*)(logger_t*,logger_level_t,char*,...))logg;
|
||||
this->public.log_bytes = (status_t(*)(logger_t*, logger_level_t, char*,char*,size_t))log_bytes;
|
||||
this->public.log_chunk = log_chunk;
|
||||
|
@ -259,7 +265,13 @@ logger_t *logger_create(char *logger_name, logger_level_t log_level,FILE * outpu
|
|||
|
||||
/* private variables */
|
||||
this->level = log_level;
|
||||
this->name = logger_name;
|
||||
this->name = allocator_alloc(strlen(logger_name) + 1);
|
||||
if (this->name == NULL)
|
||||
{
|
||||
allocator_free(this);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(this->name,logger_name);
|
||||
this->output = output;
|
||||
|
||||
|
||||
|
|
|
@ -127,6 +127,9 @@ static status_t get_logger (private_logger_manager_t *this, logger_context_t con
|
|||
case RECEIVER_THREAD:
|
||||
context_name = "RECEIVER_THREAD";
|
||||
break;
|
||||
case THREAD_POOL:
|
||||
context_name = "THREAD_POOL";
|
||||
break;
|
||||
case TESTER:
|
||||
context_name = "TESTER";
|
||||
output = stdout;
|
||||
|
@ -137,10 +140,17 @@ static status_t get_logger (private_logger_manager_t *this, logger_context_t con
|
|||
}
|
||||
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
snprintf(buffer, MAX_LOGGER_NAME, "%s - %s",context_name,name);
|
||||
if (name != NULL)
|
||||
{
|
||||
snprintf(buffer, MAX_LOGGER_NAME, "%s - %s",context_name,name);
|
||||
/* create logger with default log_level */
|
||||
*logger = logger_create(buffer,logger_level,output);
|
||||
}
|
||||
else
|
||||
{
|
||||
*logger = logger_create(context_name,logger_level,output);
|
||||
}
|
||||
|
||||
/* create logger with default log_level */
|
||||
*logger = logger_create(buffer,logger_level,output);
|
||||
|
||||
if (*logger == NULL)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ enum logger_context_e{
|
|||
GENERATOR,
|
||||
IKE_SA,
|
||||
MESSAGE,
|
||||
THREAD_POOL,
|
||||
WORKER_THREAD,
|
||||
EVENT_THREAD,
|
||||
SENDER_THREAD,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <arpa/inet.h>
|
||||
|
||||
#include "allocator.h"
|
||||
#include "globals.h"
|
||||
#include "types.h"
|
||||
#include "parser.h"
|
||||
#include "logger.h"
|
||||
|
@ -379,7 +380,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
|
|||
*/
|
||||
static status_t destroy(private_parser_t *this)
|
||||
{
|
||||
this->logger->destroy(this->logger);
|
||||
global_logger_manager->destroy_logger(global_logger_manager,this->logger);
|
||||
allocator_free(this);
|
||||
|
||||
return SUCCESS;
|
||||
|
@ -397,7 +398,8 @@ parser_t *parser_create(payload_info_t **payload_infos)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
this->logger = logger_create("parser", ALL,NULL);
|
||||
global_logger_manager->get_logger(global_logger_manager,PARSER,&(this->logger),"");
|
||||
|
||||
if (this->logger == NULL)
|
||||
{
|
||||
allocator_free(this);
|
||||
|
|
|
@ -113,7 +113,7 @@ static status_t destroy(private_thread_pool_t *this)
|
|||
}
|
||||
|
||||
/* free mem */
|
||||
this->logger->destroy(this->logger);
|
||||
global_logger_manager->destroy_logger(global_logger_manager, this->logger);
|
||||
allocator_free(this->threads);
|
||||
allocator_free(this);
|
||||
return SUCCESS;
|
||||
|
@ -143,7 +143,7 @@ thread_pool_t *thread_pool_create(size_t pool_size)
|
|||
allocator_free(this);
|
||||
return NULL;
|
||||
}
|
||||
this->logger = logger_create("thread_pool", ALL,NULL);
|
||||
global_logger_manager->get_logger(global_logger_manager,THREAD_POOL,&(this->logger),NULL);
|
||||
if (this->threads == NULL)
|
||||
{
|
||||
allocator_free(this);
|
||||
|
|
Loading…
Reference in a new issue