Commit Graph

6 Commits

Author SHA1 Message Date
Neels Hofmeyr 957b8277a2 add API logging_vty_subsys_strip_leading_char()
Allow an application to use subsystem names without a leading 'D'. With
this patch, a program can:
- remove the 'D' from struct log_info_cat[] entries -- now VTY would
  strip the 'M' from "MAIN" and we'd get 'ain' on the VTY.
- call logging_vty_subsys_strip_leading_char(false) during startup --
  hence the VTY does not strip anything, and we get 'main' on the VTY
  config.

So this allows removing the odd 'D' from category names without any
changes in the VTY configuration.

Background: I am hacking on some project and decided to use libosmovty
and libosmocore logging, but I want logging subsys names without a
leading 'D'. So I noticed that the cfg file has mangled category names.

Change-Id: I5faedf7d6525d744a734ebe54c185fcc904f763e
2023-04-24 18:05:38 +02:00
Neels Hofmeyr 6496cf16e9 formalize log subsys stripping for vty
In osmocom, we historically have a leading 'D' in all of our logging
subsystem names -- not only in the enum entry name, but also as the
string in struct log_info_cat[].

As a result of this, our logging_vty code strips away the first
character of each logging subsystem name. In the VTY, we don't enter
'dmain', but only 'main' -- the VTY strips the 'D' from "DMAIN".

The intention is to make this stripping behavior optional in a
subsequent patch.

So far the code to do that is a magic "+ 1" thrown in here and there.
Instead, introduce log_subsys_name() and use it where ever logging_vty.c
does removal of the leading 'D'.

I would have liked to keep this within logging_vty.c, but unfortunately
it needs to be public API in logging.h, because of log_parse_category()
which also strips leading D and lives in logging.c.

Change-Id: I5f81343e8c7b714a4630e64ba654e391435c4244
2023-04-24 18:02:30 +02:00
Pau Espin fc37650381 logging.c: Sanitize calls to osmo_fd_unregister()
It makes no sense to call osmo_fd_unregister() on a negative fd.
Let's also make sure we set fd to negative value after unregistering +
closing, even if the struct is going to be freed afterwards.

Change-Id: I0790a63e603028c11cc475d483c6528e4d9aa9ab
2023-03-14 14:32:54 +01:00
Pau Espin 040548f790 logging: Unregister osmo_fd before closing fd
Change-Id: I0754ac3110b63d2a380068010830af6c85b0a653
2023-03-10 13:41:17 +00:00
Pau Espin 88955fb550 Fix all references to config.h
config.h is created in $(top_buildir)/config.h.
Let's make sure all CPPFLAGS add correct -Ipath includes,
and that all code includes the correct file.

Change-Id: Ie9ea38bb009bc715b01cde4d66d181f7bec2e7bd
2023-01-18 19:04:36 +01:00
Pau Espin d4c3dc8d59 Move src/*.{c,h} to src/core/
This way we have all libosmocore.so in an own subdir instead of having
lots of files in the parent dir, which also contains subdirs to other
libraries.
This also matches the schema under include/osmocom/.

Change-Id: I6c76fafebdd5e961aed88bbecd2c16bc69d580e2
2023-01-18 17:14:06 +01:00