diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-01 16:11:39 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-04 17:54:37 +0200 |
commit | 113e30cb0639cefbafdad2862c5e69b0e17d9bf3 (patch) | |
tree | 753dbe0cc7a4e7fd09cb44e9da2db7be401916f7 | |
parent | 091fcf147ae83d8daec92b2506d14e5e5ad35f80 (diff) |
use osmo_init_logging2() with proper talloc ctx
Completely drop bts_log_init(), call osmo_init_logging2() directly instead: all
callers of bts_log_init() passed NULL as category string, so all it ever did
was call osmo_init_logging(). The bts_log_info is already declared in the .h.
Here and there also define a proper talloc root context instead of using NULL.
Change-Id: Ic049f77bef74123b95350bcae182a468e0086b9c
-rw-r--r-- | doc/startup.txt | 2 | ||||
-rw-r--r-- | include/osmo-bts/logging.h | 2 | ||||
-rw-r--r-- | src/common/logging.c | 10 | ||||
-rw-r--r-- | src/common/main.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-litecell15/misc/lc15bts_mgr.c | 8 | ||||
-rw-r--r-- | src/osmo-bts-omldummy/main.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_fwd_main.c | 8 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/misc/sysmobts_mgr.c | 8 | ||||
-rw-r--r-- | tests/agch/agch_test.c | 2 | ||||
-rw-r--r-- | tests/cipher/cipher_test.c | 2 | ||||
-rw-r--r-- | tests/handover/handover_test.c | 2 | ||||
-rw-r--r-- | tests/meas/meas_test.c | 2 | ||||
-rw-r--r-- | tests/misc/misc_test.c | 9 | ||||
-rw-r--r-- | tests/paging/paging_test.c | 2 | ||||
-rw-r--r-- | tests/tx_power/tx_power_test.c | 2 |
15 files changed, 23 insertions, 40 deletions
diff --git a/doc/startup.txt b/doc/startup.txt index cc643758..50766e48 100644 --- a/doc/startup.txt +++ b/doc/startup.txt @@ -6,7 +6,7 @@ The start-up procedure of OsmoBTS can be described as follows: |=== | bts-specific | main() | | common | bts_main() | initialization of talloc contexts -| common | bts_log_init() | initialization of logging +| common | osmo_init_logging2() | initialization of logging | common | handle_options() | common option parsing | bts-specific | bts_model_handle_options() | model-specific option parsing | common | gsm_bts_alloc() | allocation of BTS/TRX/TS data structures diff --git a/include/osmo-bts/logging.h b/include/osmo-bts/logging.h index 68f379c7..852c3836 100644 --- a/include/osmo-bts/logging.h +++ b/include/osmo-bts/logging.h @@ -25,8 +25,6 @@ enum { extern const struct log_info bts_log_info; -int bts_log_init(const char *category_mask); - /* LOGP with gsm_time prefix */ #define LOGPGT(ss, lvl, gt, fmt, args...) \ LOGP(ss, lvl, "%s " fmt, osmo_dump_gsmtime(gt), ## args) diff --git a/src/common/logging.c b/src/common/logging.c index a4d30e6b..3315a019 100644 --- a/src/common/logging.c +++ b/src/common/logging.c @@ -148,13 +148,3 @@ const struct log_info bts_log_info = { .cat = bts_log_info_cat, .num_cat = ARRAY_SIZE(bts_log_info_cat), }; - -int bts_log_init(const char *category_mask) -{ - osmo_init_logging(&bts_log_info); - - if (category_mask) - log_parse_category_mask(osmo_stderr_target, category_mask); - - return 0; -} diff --git a/src/common/main.c b/src/common/main.c index 0f6f5295..9121a2ab 100644 --- a/src/common/main.c +++ b/src/common/main.c @@ -239,7 +239,7 @@ int bts_main(int argc, char **argv) msgb_talloc_ctx_init(tall_bts_ctx, 100*1024); bts_vty_info.tall_ctx = tall_bts_ctx; - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); vty_init(&bts_vty_info); ctrl_vty_init(tall_bts_ctx); rate_ctr_init(tall_bts_ctx); diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr.c b/src/osmo-bts-litecell15/misc/lc15bts_mgr.c index 7886a5e2..dbdcc9f0 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_mgr.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr.c @@ -281,12 +281,6 @@ static const struct log_info mgr_log_info = { .num_cat = ARRAY_SIZE(mgr_log_info_cat), }; -static int mgr_log_init(void) -{ - osmo_init_logging(&mgr_log_info); - return 0; -} - int main(int argc, char **argv) { int rc; @@ -294,7 +288,7 @@ int main(int argc, char **argv) tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager"); msgb_talloc_ctx_init(tall_mgr_ctx, 0); - mgr_log_init(); + osmo_init_logging2(tall_mgr_ctx, &mgr_log_info); osmo_init_ignore_signals(); signal(SIGINT, &signal_handler); diff --git a/src/osmo-bts-omldummy/main.c b/src/osmo-bts-omldummy/main.c index 39f2ac2b..ef945537 100644 --- a/src/osmo-bts-omldummy/main.c +++ b/src/osmo-bts-omldummy/main.c @@ -19,7 +19,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 10*1024); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); bts = gsm_bts_alloc(tall_bts_ctx, 0); if (!bts) diff --git a/src/osmo-bts-sysmo/l1_fwd_main.c b/src/osmo-bts-sysmo/l1_fwd_main.c index 92d2ea47..bc9fc21c 100644 --- a/src/osmo-bts-sysmo/l1_fwd_main.c +++ b/src/osmo-bts-sysmo/l1_fwd_main.c @@ -37,6 +37,7 @@ #include <osmocom/core/write_queue.h> #include <osmocom/core/logging.h> #include <osmocom/core/socket.h> +#include <osmocom/core/application.h> #include <osmocom/gsm/gsm_utils.h> #include <osmo-bts/logging.h> @@ -169,11 +170,12 @@ int main(int argc, char **argv) struct l1fwd_hdl *l1fh; struct femtol1_hdl *fl1h; int rc, i; + void *ctx = talloc_named_const(NULL, 0, "l1_fwd"); printf("sizeof(GsmL1_Prim_t) = %zu\n", sizeof(GsmL1_Prim_t)); printf("sizeof(SuperFemto_Prim_t) = %zu\n", sizeof(SuperFemto_Prim_t)); - bts_log_init(NULL); + osmo_init_logging2(ctx, &bts_log_info); /* * hack and prevent that two l1fwd-proxy/sysmobts run at the same @@ -187,7 +189,7 @@ int main(int argc, char **argv) } /* allocate new femtol1_handle */ - fl1h = talloc_zero(NULL, struct femtol1_hdl); + fl1h = talloc_zero(ctx, struct femtol1_hdl); INIT_LLIST_HEAD(&fl1h->wlc_list); /* open the actual hardware transport */ @@ -198,7 +200,7 @@ int main(int argc, char **argv) } /* create our fwd handle */ - l1fh = talloc_zero(NULL, struct l1fwd_hdl); + l1fh = talloc_zero(ctx, struct l1fwd_hdl); l1fh->fl1h = fl1h; fl1h->priv = l1fh; diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index 17a6d89b..a0080738 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -245,12 +245,6 @@ static const struct log_info mgr_log_info = { .num_cat = ARRAY_SIZE(mgr_log_info_cat), }; -static int mgr_log_init(void) -{ - osmo_init_logging(&mgr_log_info); - return 0; -} - int main(int argc, char **argv) { int rc; @@ -261,7 +255,7 @@ int main(int argc, char **argv) srand(time(NULL)); - mgr_log_init(); + osmo_init_logging2(tall_mgr_ctx, &mgr_log_info); if (classify_bts() != 0) exit(2); diff --git a/tests/agch/agch_test.c b/tests/agch/agch_test.c index 6efbc248..ab59ebfe 100644 --- a/tests/agch/agch_test.c +++ b/tests/agch/agch_test.c @@ -222,7 +222,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); bts = gsm_bts_alloc(tall_bts_ctx, 0); if (bts_init(bts) < 0) { diff --git a/tests/cipher/cipher_test.c b/tests/cipher/cipher_test.c index 5e2bdc02..a7343c08 100644 --- a/tests/cipher/cipher_test.c +++ b/tests/cipher/cipher_test.c @@ -68,7 +68,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); bts = gsm_bts_alloc(tall_bts_ctx, 0); if (bts_init(bts) < 0) { diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c index 1c0a4da7..c7bd8f8d 100644 --- a/tests/handover/handover_test.c +++ b/tests/handover/handover_test.c @@ -67,7 +67,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); osmo_stderr_target->categories[DHO].loglevel = LOGL_DEBUG; bts = gsm_bts_alloc(tall_bts_ctx, 0); diff --git a/tests/meas/meas_test.c b/tests/meas/meas_test.c index a283c476..cbc673fd 100644 --- a/tests/meas/meas_test.c +++ b/tests/meas/meas_test.c @@ -69,7 +69,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); osmo_stderr_target->categories[DMEAS].loglevel = LOGL_DEBUG; bts = gsm_bts_alloc(tall_bts_ctx, 0); diff --git a/tests/misc/misc_test.c b/tests/misc/misc_test.c index e4542354..c4d3a595 100644 --- a/tests/misc/misc_test.c +++ b/tests/misc/misc_test.c @@ -24,11 +24,14 @@ #include <osmo-bts/msg_utils.h> #include <osmo-bts/logging.h> +#include <osmocom/core/application.h> #include <osmocom/gsm/protocol/ipaccess.h> #include <stdlib.h> #include <stdio.h> +void *ctx = NULL; + static const uint8_t ipa_rsl_connect[] = { 0x00, 0x1c, 0xff, 0x10, 0x80, 0x00, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x70, 0x61, 0x63, @@ -161,7 +164,7 @@ static void test_bts_supports_cm(void) { struct gsm_bts *bts; - bts = gsm_bts_alloc(NULL, 0); + bts = gsm_bts_alloc(ctx, 0); gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1); gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1); @@ -184,7 +187,9 @@ static void test_bts_supports_cm(void) int main(int argc, char **argv) { - bts_log_init(NULL); + ctx = talloc_named_const(NULL, 0, "misc_test"); + + osmo_init_logging2(ctx, &bts_log_info); test_sacch_get(); test_msg_utils_ipa(); diff --git a/tests/paging/paging_test.c b/tests/paging/paging_test.c index f4f0934e..bf28661a 100644 --- a/tests/paging/paging_test.c +++ b/tests/paging/paging_test.c @@ -114,7 +114,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); bts = gsm_bts_alloc(tall_bts_ctx, 0); if (bts_init(bts) < 0) { diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c index a47d186c..ad3f68ce 100644 --- a/tests/tx_power/tx_power_test.c +++ b/tests/tx_power/tx_power_test.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); - bts_log_init(NULL); + osmo_init_logging2(tall_bts_ctx, &bts_log_info); osmo_stderr_target->categories[DL1C].loglevel = LOGL_DEBUG; log_set_print_filename(osmo_stderr_target, 0); |