aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJan Hutter <jhutter@hsr.ch>2005-11-11 11:20:22 +0000
committerJan Hutter <jhutter@hsr.ch>2005-11-11 11:20:22 +0000
commit96d72d323d6ab3d3f505a1fd8c5175ebe4ce7363 (patch)
treeb2814a3eb504c9472bdbd1144ddd28e72f152df5 /Source
parentffd555f58e8f75622162efb2e9c6e5482d829f06 (diff)
downloadstrongswan-96d72d323d6ab3d3f505a1fd8c5175ebe4ce7363.tar.bz2
strongswan-96d72d323d6ab3d3f505a1fd8c5175ebe4ce7363.tar.xz
- fixed bug in logger_t not storing the name of it
Diffstat (limited to 'Source')
-rw-r--r--Source/charon/logger.c14
-rw-r--r--Source/charon/logger_manager.c16
-rw-r--r--Source/charon/logger_manager.h1
-rw-r--r--Source/charon/parser.c6
-rw-r--r--Source/charon/thread_pool.c4
5 files changed, 33 insertions, 8 deletions
diff --git a/Source/charon/logger.c b/Source/charon/logger.c
index 98f69ab1f..eee03b7fc 100644
--- a/Source/charon/logger.c
+++ b/Source/charon/logger.c
@@ -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;
diff --git a/Source/charon/logger_manager.c b/Source/charon/logger_manager.c
index 5e331e745..80721bb84 100644
--- a/Source/charon/logger_manager.c
+++ b/Source/charon/logger_manager.c
@@ -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)
{
diff --git a/Source/charon/logger_manager.h b/Source/charon/logger_manager.h
index 920a51d54..59c88d109 100644
--- a/Source/charon/logger_manager.h
+++ b/Source/charon/logger_manager.h
@@ -37,6 +37,7 @@ enum logger_context_e{
GENERATOR,
IKE_SA,
MESSAGE,
+ THREAD_POOL,
WORKER_THREAD,
EVENT_THREAD,
SENDER_THREAD,
diff --git a/Source/charon/parser.c b/Source/charon/parser.c
index ecc0b235a..b072bc258 100644
--- a/Source/charon/parser.c
+++ b/Source/charon/parser.c
@@ -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);
diff --git a/Source/charon/thread_pool.c b/Source/charon/thread_pool.c
index 76783efe0..532587ee7 100644
--- a/Source/charon/thread_pool.c
+++ b/Source/charon/thread_pool.c
@@ -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);