Commit Graph

71 Commits

Author SHA1 Message Date
Harald Welte c0f0007292 import oap message parsing / encoding from openbsc.git; AGPL->GPL
In the process, also:
* Change the license from AGPLv3 to GPLv2-or-later;
* correct spelling of 'sysmocom' to lowercase;
* add '2016' to the copyright;
* rename to osmo_*;
* add API docs;
* add logging category DLOAP: define id and add to internal_cat;
* redirect all oap.c logging to DLOAP.

A unit test will follow in a subsequent patch, since it needs a minor tweak for
decoding of boolean values.

The related openbsc change-id is I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf.

Tweaked-by: Neels Hofmeyr
Change-Id: If5099e60681a215e798b6675f21813f26769c253
2016-12-11 03:42:58 +01:00
Neels Hofmeyr 9795cf1b12 fix: DLGSUP logging category "unusable"
All DL* categories are typically negative, but DLGSUP isn't, and it's also not
in libosmocore's internal_cat array.
See: 3b6fb0880c

This means that a program using DLGSUP has to include DLGSUP in its own logging
cat array (typically not needed for DL* categories), which means for osmo-nitb
that DLGSUP (11) replaces DMGCP (also 11), and DMGCP becomes unusable.

Fix this: make DLGSUP -11 and include in internal_cat.

In gsup_test.c, no longer add DLGSUP to the logging categories array.

External follow-ups are otherwise needed only in osmo-hlr.git and some pending
patches for openbsc (Id3938267fa062e1a997d3704cd678874306f86ee).

Change-Id: Id974c7be158e4d60421a98110f5c807aefd31119
2016-12-11 03:42:58 +01:00
Harald Welte aa00f99be2 Implement GSMTAP log target
This target wraps the to-be-logged string (With metadata) into a GSMTAP
packet and sends it to the configured destination address.

Change-Id: I9a7e72b8c9c6f6f2d76d1ea2332dcdee12394625
2016-12-09 17:59:58 +01:00
Harald Welte d7c0a373ff logging: Extend log_target with call-back for un-formatted log line
Some targets might not want to receive only an opaque, pre-formatted
string, but rather the unformatted arguments with metadata like
sub-system/level/file/line.  We solve this by introducing a
log_target->output_raw() function pointer.  If a target specifies this
function, it takes precedence over the regular log_target->output()
function.

Change-Id: I9dc9205d70dce9581458e7e9dc2d8a92991897bd
2016-12-02 13:52:59 +01:00
Neels Hofmeyr 8e2f7e87f4 add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.

Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-22 07:18:39 +02:00
Ruben Undheim 029f5a1c0d misc: Some spelling errors corrected
Change-Id: Ibfc239b84879556624ca6020ae6a63d102640c94
Reviewed-on: https://gerrit.osmocom.org/114
Tested-by: Jenkins Builder
Reviewed-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-05-25 19:43:56 +00:00
Harald Welte 2d2e2cca0d Update doxygen annotations in libosmocore
This adds and improves doxygen API descriptions all over libosmocore,
reducing the 'white spots' that don't have any documentation.
2016-05-05 18:49:27 +02:00
Harald Welte 69e6c3c7cd Add log_fini() function to release all memory allocated by logging framework
This is e.g. quite useful to call at the end of test code, in order to
show that all memory allocated actually is released before exit().
2016-05-05 18:49:22 +02:00
Neels Hofmeyr da1b20cd4f logging.c: assert category_token allocation (CID #57871) 2016-04-16 13:31:15 +02:00
Holger Hans Peter Freyther ed0ce47fa9 logging: Remove unused variable after recent changes
The variable is not used anymore as the decision is done in the
newly added check_log_to_target method.
2016-02-29 14:41:12 +01:00
Holger Hans Peter Freyther 79599acd66 logging: Move the filter check up as well
There doesn't seem to be a reason not to check the filter. Update
and extend the test. Currently the filter function will be called
once for the log check and once for the output of it.
2016-02-29 14:30:14 +01:00
Holger Hans Peter Freyther e0dc6a1c7c logging: Remove some code duplication
Extract the mapping of the subsystem number and the checking for
the loglevel to a inline method that is shared between the new
and old.
2016-02-29 14:30:14 +01:00
Jacob Erlbeck de6dd72dbb log: Add log_check_level function
This commit adds this predicate function which can be used to
avoid the execution of code if a certain log level is not enabled.

The function will only return 0 (false), if it is sure that a logging
call for the same facility and level will not produce any output.
This safety criterion shall ensure, that no logging output is lost
due to the use of this predicate as a guard. On the other hand, even
if the predicate returns != 0 (true), no logging output might get
generated by a similar logging command.

Note that the current implementation is not focussed on performance,
which could be improved by using a lookup table instead of iterating
through every target.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Jacob Erlbeck 79125ecf7d log: Add new DLSTATS log level
This log level is used by the stats subsystem log reporter to report
statistics to level INFO. Note that the default level of DLSTATS is
NOTICE.

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck b61b2ca1a0 logging: Implement subsecond resolution of extended timestamps
Currently when using 'logging print extended-timestamp 1', the
subsecond part (milliseconds) of the printed timestamp is always 0.
This makes it difficult to correlate log entries with PCAP file
entries if there are many of them per second.

This patch changes _output in logging.c to use gettimeofday() instead
of time() when extended timestamps are enabled and replaces the '000'
by the milliseconds computed from tv_usec.

Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther 6ec6bd9d88 log: "logging level everything" is a badly named option.
We tried to fix it but it isn't that easy. The original fix was
cd6ed82d1f but we had to revert it
as "everything" is present/used in existing config files.

If we ever change the ABI we can make everything be something
that is > 0. For now use a wording that makes it obvious that
people should not use "everything".
2014-12-28 18:30:59 +01:00
Holger Hans Peter Freyther 5f91a40068 logging: Call color only once and use the result
First we check if a color is defined and then we call it again
and use the result. Avoid the second call and use the result of
the previous call.
2014-12-05 10:29:45 +01:00
Holger Hans Peter Freyther 2d6ad13d8d logging: Make it possible to print category/subsys and timestamps
We want to see from which category/subsystem a certain log message
is coming from and use a different timestamp format as well. Add
two new bitfields. This doesn't change the size of the structure
and on 32bit we still have 27bits left.

The extended timestamp will take preference over the current and
default timestamp format.

Fixes: SYS#602
2014-12-05 10:23:28 +01:00
Holger Hans Peter Freyther a5dc19dc40 gtp: Add a global region for the gtp library of OpenGGSN
We want to use libosmocore/libosmovty in the GGSN sourcecode
and reserve a global region here.
2014-12-04 14:39:14 +01:00
Harald Welte 7fd0c830d9 libctrl: Add DLCTRL as logging context for the control interface
... and make libctrl code use it
2014-08-21 15:34:18 +02:00
Holger Hans Peter Freyther b7d0f4686b logging: Copy the filter_fn and fix the IMSI filter in OpenBSC
The filter_fn has not been copied into the new structure breaking
the imsi and other filters in OpenBSC. Looking at the code we should
also introduce a callback for the reset of the context so we could
use subscr_get/subscr_put on the subscriber structure.
2013-12-29 19:38:01 +01:00
Harald Welte 54c5ed1518 Revert "Follow up fix for the log level "everything""
This reverts commit a6428d2376.
2013-03-19 09:55:42 +01:00
Harald Welte 9b1867093f Revert "Fix log level "everything" and make it equal to "debug""
This reverts commit cd6ed82d1f.
2013-03-19 09:55:28 +01:00
Harald Welte 4de854dcf0 logging: add new log_targets_reopen() function
This function will re-open all existing log files in the application,
praticularly useful for SIGHUP handlers in case of logrotate
2013-03-18 19:05:46 +01:00
Holger Hans Peter Freyther a6428d2376 Follow up fix for the log level "everything"
Commit cd6ed82d1f made "EVERYTHING"
map to LOGL_DEBUG but when writing out the configuration the following
would be written:

  logging level all unknown 0x0

This happend because no string was found for the value 0. Address it
by adding a legacy check for 0 and write out the str from the index
0. Currently this is "EVERYTHING".
2013-02-27 15:32:51 +01:00
Harald Welte cd6ed82d1f Fix log level "everything" and make it equal to "debug"
As Holger points out "logging level XXX everything" wasn't working, as
it sets category->loglevel to 0, which is checked in osmo_vlogp() and
will never get logged.
2013-02-19 11:57:14 +01:00
Harald Welte de6e4983e7 add some missing doxygen annotation for libosmocore functions 2013-01-11 09:43:32 +01:00
Nico Golde 0262d3ff9f logging.c: Do not crash on empty category name
log_parse_category_mask(), skip log category name right away if
name is NULL to prevent passing a NULL ptr to strlen.
2012-09-27 13:45:03 +02:00
Holger Hans Peter Freyther db1533651f logging: Introduce a print_filename flag for the logtarget
Introduce a print_filename attribute for each logtarget. Initialize it
with 1 to be backward compatible with earlier versions. The bit is taken
from an existint bitfield. There were at least six bits left of the byte.
2012-09-11 11:24:51 +02:00
Holger Hans Peter Freyther 06f645542c logging: Mark the log_info_cat pointer as consts
Applications should keep the log area in a static const area. Mark
the pointer as const to address compiler warnings in OpenBSC, cast
the const away for the osmo_log_info as it is not declared as const.
2012-09-11 10:31:29 +02:00
Holger Hans Peter Freyther fb4bfc2ad5 logging: Fix compile breakage introduced by the warning fixes
Make sure the declaration and definition match, add const to
the functions called by logp/logp2.

Compile output:
logging.c:317: error: conflicting types for 'logp'
../include/osmocom/core/logging.h:34: note: previous declaration of 'logp' was here
logging.c:327: error: conflicting types for 'logp2'
../include/osmocom/core/logging.h:168: note: previous declaration of 'logp2' was here
make[3]: *** [logging.lo] Error 1
2012-07-12 09:26:25 +02:00
Sylvain Munaut dca7d2caaa doc: Fix the Doxygen section endings
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-04-18 21:53:23 +02:00
Andreas Eversberg c626da9f87 gsm/sms: Added DLSMS debugging
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
root 8a996b4844 Changed logging of LAPD from DLLAPDM to DLLAPD 2011-10-10 08:38:58 +02:00
Harald Welte 36c5a3e285 logging: add osmo_vlogp() as vararg / va_list compatible function 2011-08-31 19:40:03 +02:00
Harald Welte 18fc465b7f doxygen documentation for logging framework 2011-08-17 17:14:12 +02:00
Pablo Neira Ayuso 300e78d3e5 logging: fix parsing of logging mask (-d DMI case)
Without this patch, `-d DMI' enables logging for DMI and DMIB.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-08-11 14:33:16 +02:00
Harald Welte 087e1136eb use the 'L' prefix in debug names (DLINP instead of DINP) 2011-07-29 11:43:39 +02:00
Harald Welte 95f7eb288c remove DLRSL and DLNM, we don't need them
They are not used anywhere in our libraries, so they should be defined
by the respective applications
2011-07-21 16:58:44 +02:00
Harald Welte 892e621fec make sure we don't have namespace clashes between libraries and apps
* All loging prefixes in libraries should be DL like DLINP
* All signals / subsystems should be called S_L_* SS_L_*
* All command nodes should be called L_*_NODE

This makes sure existinc code still compiles as expected
2011-07-19 14:31:44 +02:00
Pablo Neira Ayuso 199f37723b logging: add libosmo-abis logging subsystems
This adds the libosmo-abis logging subsystems to libosmocore,
it uses the new change that harald proposed based on negative
numbers for library logging subsystems.
2011-07-18 17:00:08 +02:00
Harald Welte da127cbb3e fix against corrupted output in parallel logging
In 8256076722 it was attempted to fix
a bug previously introduced by logging related changes.  The problem
is that a va_list can be corrupted after it has been used once, so
we need to va_copy before each successive use.

And if we copy it, we also need to use the copy, and not the original ;)
2011-07-02 21:51:32 +02:00
Harald Welte ce9fec3e89 Fix the generation of the log_categories string + LAPDM
... I should do more testing :(

Conflicts:

	src/logging.c
2011-06-27 23:19:06 +02:00
Harald Welte 9fe1652212 logging: make sure to add the internal categories, as intended 2011-06-27 23:17:35 +02:00
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