Commit Graph

127 Commits

Author SHA1 Message Date
Harald Welte 1f0b8c26f7 add LAPDm code from osmocom-bb into libosmocore 2011-06-27 10:51:37 +02:00
Harald Welte b43bc048eb logging: introduce library-internal logging categories
We do this by using a trick: library-internal log categories use
negative subsystem numbers, which are converted into positive
array indexes at the time of logging.

library-internal log categories need to be knwo at compile-time,
while application-specified categories now are of unlimited number,
as they are dynamically allocated.
2011-06-27 10:40:25 +02:00
Pablo Neira Ayuso dd93bf46ed logging: fix corrupted output
Harald reported a problem in the logging:
http://lists.osmocom.org/pipermail/openbsc/2011-May/002896.html

Reverting 81e9636454 seems to
fix the problem. However, that workaround looks ugly.

Holger gives us another clue on what was wrong:
http://lists.osmocom.org/pipermail/openbsc/2011-May/002905.html

While digging in the manpage, I found this:

"The functions vprintf(), vfprintf(), vsprintf(), vsnprintf()
are equivalent to the functions printf(), fprintf(), sprintf(),
snprintf(), respectively, except that they are called with a
va_list instead of a variable number of arguments. These functions
do not call the va_end macro. Consequently, the value of ap is
undefined after the call. The application should call va_end(ap)
itself afterwards."
2011-05-19 01:40:43 +02:00
Pablo Neira Ayuso 534ba81328 logging: make sure the output is null-terminated
If we reach the buffer size or snprintf fails, we want to make sure
that the output is null-terminated.
2011-05-04 11:07:13 +02:00
Pablo Neira Ayuso 81e9636454 logging: remove workaround now that _output() has been reworked
This patch removes a workaround to fix some strange memory corruption
now that _output() has been completely reworked and we make use of
snprintf appropriately.
2011-05-04 11:07:13 +02:00
Pablo Neira Ayuso 7503fb8e3e logging: rework _output() function
This patch reworks _output() to handle snprintf() return value
appropriately and to use one single buffer to build the logging
string, instead of four.
2011-05-04 11:07:13 +02:00
Pablo Neira Ayuso f1fae4dd06 logging: several memory allocation belong to tall_log_ctx context
Several talloc_zero in logging use NULL context, use tall_log_ctx
instead.
2011-05-04 11:07:13 +02:00
Pablo Neira Ayuso d6b5195be2 logging: fix missing description of global loglevel
OpenBSC> logging level
  all    Global setting for all subsystems <----- this description was missing
  rll    A-bis Radio Link Layer (RLL)
[...]

This problem was introduced by myself in:
"vty: integration with logging framework"
04139f14b6
2011-05-04 11:07:13 +02:00
Holger Hans Peter Freyther 952a18ed19 logging: Add the 'all' category back to the log level command
This is required to be able to set a global log level. The all
command is emitted by the VTY logging code.
2011-03-29 17:03:56 +02:00
Pablo Neira Ayuso 3abad6a6f9 utils: move OSMO_SNPRINT_RET() macro definition to osmocom/core/utils.h
This is used by the logging to vty conversion functions by now, but it
may be of help for other functions that plan to use snprintf().
2011-03-28 20:00:45 +02:00
Pablo Neira Ayuso 8341934844 include: reorganize headers file to include/osmocom/[gsm|core]
This patch moves all GSM-specific definitions to include/osmocom/gsm.
Moreover, the headers in include/osmocore/ have been moved to
include/osmocom/core.

This has been proposed by Harald Welte and Sylvain Munaunt.

Tested with `make distcheck'.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:09:28 +01:00
Pablo Neira Ayuso 04139f14b6 vty: integration with logging framework
The logging categories are registered by the applications, like
osmo-nitb, during startup. Thus, the VTY have to provide the logging
commands according to the logging categories that the application
has registered.

Before this patch, the VTY contained the logging categories
hardcoded. Thus, any change in the logging categories by the
application would not be shown by the VTY.

So far, this was not a problem because all applications used the
same logging categories. However, according to what Harald told
me, this may be a problem in the future.

This patch resolve the lack of integration between the logging
framework and the VTY by generating the VTY logging commands
from the logging categories registered.

Since this patch changes one function of the libosmocore API,
it follows another patch for the openbsc application to get in
sync with the new function layout.

I have reworked and renamed the functions:

 * log_vty_category_string()
 * log_vty_level_string()

to provide the new ones that generate the exact output that VTY
requires.

This patch does not release the memory allocated by
talloc_zero_size() to store the VTY strings for the commands
and the description. I found no exit function that can clean
up resources that were allocated.
2011-03-19 18:33:48 -03:00
Harald Welte 2822296ddb 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)
2011-02-18 20:37:04 +01:00
Harald Welte 76e72abe32 LOGGING: Pass the log level down to the log target output function
This will be required for mapping osmocore log levels to syslog priorities.
2011-02-17 15:52:39 +01:00
Sylvain Munaut af5ee34c35 Make sure we don't user std{err,in,out} if they don't exist.
This is required for target build in libosmocore

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-09-17 14:38:17 +02:00
Harald Welte 3086c394de logging: add log target logging into text file and log target destroy function 2010-08-25 19:10:50 +02:00
Harald Welte 0083cd381c logging: rename tgt_stdout to tgt_file 2010-08-25 18:10:19 +02:00
Harald Welte a439a3a505 logging: Make sure we don't use "end of color" code if colors are turned off 2010-07-30 21:01:54 +02:00
Harald Welte 40481e8954 move hexdump() from logging.c to utils.c 2010-07-30 11:40:32 +02:00
Harald Welte 4ebdf74728 rename log_info to osmo_log_info to avoid namespace clash with app 2010-05-25 22:28:40 +02:00
Harald Welte 3fb0b6f26e Create libosmovty as library from OpenBSC VTY functions 2010-05-25 22:28:39 +02:00
Harald Welte 7638af95fd logging: add log_vty_{level,category}_string() 2010-05-11 16:39:22 +02:00
Harald Welte 9ac2225ff4 logging: introuduce log_level_str() to obtain the name of a log level 2010-05-11 11:19:40 +02:00
Harald Welte a3b844cf45 logging: only compile stderr target if we actualy have stderr 2010-03-27 00:04:40 +08:00
Harald Welte 01fd5cb3f0 only include strings.h if it is actually preent 2010-03-26 23:51:31 +08:00
Harald Welte cc6313cc69 logging: fix default initialization of per-category loglevels
Before this patch, there was a bug in the code caused by a memcpy
from one data structure to another. unfortuantely the data structures
were not the same, so we have to explicitly iterate over the array
and assign the structure members manually.
2010-03-26 22:04:03 +08:00
Harald Welte 3ae2758fba rename 'debug' interface to 'logging' interface
It's not really about debugging, but about generic logging...
2010-03-26 21:26:01 +08:00