aboutsummaryrefslogtreecommitdiffstats
path: root/src/logging.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-02-18 20:37:04 +0100
committerHarald Welte <laforge@gnumonks.org>2011-02-18 20:37:04 +0100
commit2822296ddb22389c5b4e9b8fb6ef7c906ff99314 (patch)
tree5a05ad56e7ac5730bb98d12eef4aa527e4c7d0d9 /src/logging.c
parent46cfd77f7521ad53934e1e42057723b4cd52d241 (diff)
LOGGING: configure logging from the vty
We can now configure logging to (multiple) files, stderr and syslog from the vty command line in a persistent way (config file)
Diffstat (limited to 'src/logging.c')
-rw-r--r--src/logging.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/logging.c b/src/logging.c
index 44528620..876a3526 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -41,7 +41,7 @@ const struct log_info *osmo_log_info;
static struct log_context log_context;
static void *tall_log_ctx = NULL;
-static LLIST_HEAD(target_list);
+LLIST_HEAD(osmo_log_target_list);
static const struct value_string loglevel_strs[] = {
{ 0, "EVERYTHING" },
@@ -176,7 +176,7 @@ static void _logp(unsigned int subsys, int level, char *file, int line,
{
struct log_target *tar;
- llist_for_each_entry(tar, &target_list, entry) {
+ llist_for_each_entry(tar, &osmo_log_target_list, entry) {
struct log_category *category;
int output = 0;
@@ -239,7 +239,7 @@ void logp2(unsigned int subsys, unsigned int level, char *file, int line, int co
void log_add_target(struct log_target *target)
{
- llist_add_tail(&target->entry, &target_list);
+ llist_add_tail(&target->entry, &osmo_log_target_list);
}
void log_del_target(struct log_target *target)
@@ -338,6 +338,7 @@ struct log_target *log_target_create_stderr(void)
if (!target)
return NULL;
+ target->type = LOG_TGT_TYPE_STDERR;
target->tgt_file.out = stderr;
target->output = _file_output;
return target;
@@ -354,6 +355,7 @@ struct log_target *log_target_create_file(const char *fname)
if (!target)
return NULL;
+ target->type = LOG_TGT_TYPE_FILE;
target->tgt_file.out = fopen(fname, "a");
if (!target->tgt_file.out)
return NULL;
@@ -365,6 +367,22 @@ struct log_target *log_target_create_file(const char *fname)
return target;
}
+struct log_target *log_target_find(int type, const char *fname)
+{
+ struct log_target *tgt;
+
+ llist_for_each_entry(tgt, &osmo_log_target_list, entry) {
+ if (tgt->type != type)
+ continue;
+ if (tgt->type == LOG_TGT_TYPE_FILE) {
+ if (!strcmp(fname, tgt->tgt_file.fname))
+ return tgt;
+ } else
+ return tgt;
+ }
+ return NULL;
+}
+
void log_target_destroy(struct log_target *target)
{