Commit Graph

40 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
Harald Welte 3d79240fb4 logging: Use __BASE_FILE__ instead of __FILE__
Apparently __FILE__ expands to nasty '../../..' paths when BUILDDIR !=
SRCDIR.  This in turn leads to ugly log lines like:

<0000> ../../../../osmo-bts/src/common/rsl.c:1642 (bts=0,trx=0,ts=0,ss=0) Handing RLL msg UNIT_DATA_IND from LAPDm to MEAS REP

Where we certainly wouldn't want the "../../../../osmo-bts" part.

Change-Id: If6d2de33c3b6bb2943954bbd81eff261dc279d58
Reviewed-on: https://gerrit.osmocom.org/38
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-12 11:15:22 +00:00
Harald Welte 3b6fb0880c import gprs_gsup_message.[ch] from openbsc as gsup.[ch]
Move those routines from OpenBSC to libosmogsm, so they can be
re-used from other programs.  I think it was a mistake to add them only
inside the openbsc repository in the first place.  We need to pay more
attention to this in the future.
2016-05-06 11:21:06 +02: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
Jacob Erlbeck a89d22c0f0 log: Add conditional logging based on log_check_level
Currently the LOGP/DEBUGP arguments are always evaluated even if
no logging will happen at all. This can be expensive, for instance
if hexdumps or pretty printed object names are generated. This causes
high base load especially on embedded devices and is a major part of
CPU usage e.g. of the osmo-pcu.

This commit uses the log_check_level function to avoid the evaluation
of the parameters if it is known in advance, that no logging entry
will be generated.

Sponsored-by: On-Waves ehf
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
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 fb84f325b8 logging: Add ability to save/print current log filters
This enables the persistent configuration of let's say
'log filter imsi 012345678' for a given log file in the config
file.
2014-08-25 10:09:42 +02: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
Sylvain Munaut 12ba778afd include: Switch to #pragma once pattern
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 10:17:27 +02: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
Katerina Barone-Adesi 3309a43ef5 Added a ring buffer log target to store the last N log messages.
The log target can be used via log alarms and show alarms.
Why? This feature was proposed/requested at
http://openbsc.osmocom.org/trac/wiki/Tasks/ErrorLogTarget
All messages use the same amount of space, prioritizing simplicity.
2013-02-27 15:13:45 +01:00
Holger Hans Peter Freyther efd2bd691f Revert "Added a ring buffer log target to store the last N log messages."
I noticed some more issues and it is the easiest to revert and include
the fixed version.

This reverts commit 73377229bb.
2013-02-27 14:51:33 +01:00
Katerina Barone-Adesi 73377229bb Added a ring buffer log target to store the last N log messages.
The log target can be used via log alarms and show alarms.
Why? This feature was proposed/requested at
http://openbsc.osmocom.org/trac/wiki/Tasks/ErrorLogTarget
All messages use the same amount of space, prioritizing simplicity.
2013-02-27 14:45:48 +01:00
Katerina Barone-Adesi c28c6a02d2 misc: Doxygen tweaks: fixed some typos and minor errors
Doxygen generates quite a lot of warnings on libosmocore. Some of them
are obvious typos - this patch aims to fix such low-hanging fruit.
2013-02-15 13:27:59 +01: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
Andreas Eversberg 2d6563b78e logging: Avoid compiler warnings when compiling c++ code
this patch i use to suppress warnings when compiling osmo-pcu (c++).
since __FILE__ is constant, the called logging function with parameter
"file" must be constant too, in order to avoid compiler warnings.
2012-07-10 13:10:15 +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
Christoph Fritz ab7c9c766b logging: include stdarg.h for va_list
fixes tiny compile error:

  CC     socket.lo
  In file included from socket.c:13:
  ../include/osmocom/core/logging.h:31: error: expected declaration
specifiers or ‘...’ before ‘va_list’
  make[3]: *** [socket.lo] Error 1
2011-09-01 17:44:35 +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
Harald Welte bd598e3c5e start to add doxygen documentation to libosmocore headers 2011-08-16 23:26:52 +02:00
Harald Welte 2af435986f fix off-by-one error in OSMO_NUM_DLIB
This bug was introduced in 95f7eb288c and
it caused a segfault on 'write terminal'
2011-07-29 15:12:41 +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 87dbca148f don't use signed bit-fields
detected by Smatch
2011-07-16 12:03:46 +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 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