aboutsummaryrefslogtreecommitdiffstats
path: root/src/logging.c
AgeCommit message (Collapse)AuthorFilesLines
2017-04-03logging: Add log_info_cat for DLSS7/DLSCCP/DLSUA/DLM3UAHarald Welte1-0/+20
In Change-Id I61f452208088dc7097165deecef7c058ebb4bd4e we introduced the #defines but didn't introduce the new log_info_cat information. Change-Id: I218aa4cb1fc7640a75663be29bac672dfa8770f5
2017-03-16logging: fail gracefully if log_info() was not calledHarald Welte1-0/+21
The logging code crashes if osmo_log_info is not set, which is typically achieved by calling log_init(). Let's fail with a reasonable assert and error message if the user forgets that. Change-Id: If3007860d2efe6ea9aec27e7d7439d44a7cd19c2
2017-02-23logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*Neels Hofmeyr1-8/+8
My recent logging patch was merged to master a bit too soon. Accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING". libosmocore will not be backwards-compatible with the few commits from change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and following commits are backwards compatible with those before that short window. See also: * openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991 * osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93
2017-02-22logging: centrally define ctx and filter indexesNeels Hofmeyr1-7/+14
It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Taking this opportunity to also prepare for a split of struct gsm_subscriber in openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter index constants for both subscriber types. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067
2017-01-23disable various code if building for bare-iron embeddedHarald Welte1-0/+6
We don't have file-based I/O nor ethernet devices with mac addresses when building for OsmocomBB. Change-Id: I01a9e6d8dbe885dbeac2769b84931a4d44f7a3a5
2016-12-12fix logging: log_set_category_filter() for internal DL* logging catsNeels Hofmeyr1-1/+2
In log_set_category_filter(), passing a negative index lead to memory corruption. Particularly dangerous since the internal logging categories have negative values. Fix: apply map_subsys() to interpret negative values as internal logging categories. As a side effect, out-of-bounds logging categories will be mapped to DLGLOBAL instead of being dropped. Fix the expectations in logging_test to match the fixed bug. While at it also guard against a NULL logging target. Change-Id: Ib0725b22bc39498c6b3970a61eb3339cf56d19f1
2016-12-12fix logging: out-of-bounds check should end with user categoriesNeels Hofmeyr1-0/+5
To check category bounds, rather use num_cat_user, to redirect all semantically unknown categories to DLGLOBAL. Adjust logging_test expectations accordingly: "(d)" is now also shown. Note: subsys is and needs to be signed, while num_cat* are unsigned. Thus for a negative subsys, 'subsys >= num_cat_user' practically always yields true. Pay close attention to signedness and check upper bound only for positive values. Change-Id: I4a952b759f30d90fbfb81fedcfc56a8092ea18c1
2016-12-12fix logging: also catch first out-of-bounds logging catNeels Hofmeyr1-1/+3
In map_subsys(), fix the '>' condition to '>=' for array bounds checking. Also make the bounds checking more strict: after both invocations of subsys_lib2index(), re-check validity of the array index. If the final index is still wrong, which should never happen, exit by assertion. Change-Id: I7ca1a1d47724e40350f1c4dfebe90bad01c965f9
2016-12-12fix logging: redirection to DLGLOBAL for invalid categoriesNeels Hofmeyr1-1/+8
For out-of-bounds logging categories, redirect to the proper DLGLOBAL array index instead of returning -1. Adjust test expectation which shows that the bugs tested for are fixed. Note: there are separate bounds checking problems, left for another patch. Change-Id: I6ea9a59e005a22e0305454291714fdb9531c346b
2016-12-11import oap message parsing / encoding from openbsc.git; AGPL->GPLHarald Welte1-0/+5
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-11fix: DLGSUP logging category "unusable"0.9.5Neels Hofmeyr1-0/+5
All DL* categories are typically negative, but DLGSUP isn't, and it's also not in libosmocore's internal_cat array. See: 3b6fb0880c3ab1e23a3d7d738d073b00c2a794c2 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-09Implement GSMTAP log targetHarald Welte1-2/+2
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-02logging: Extend log_target with call-back for un-formatted log lineHarald Welte1-1/+4
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-09-22add osmo_gettimeofday as a shim around gettimeofdayNeels Hofmeyr1-1/+2
This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-05-25misc: Some spelling errors correctedRuben Undheim1-1/+1
Change-Id: Ibfc239b84879556624ca6020ae6a63d102640c94 Reviewed-on: https://gerrit.osmocom.org/114 Tested-by: Jenkins Builder Reviewed-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-05-05Update doxygen annotations in libosmocoreHarald Welte1-10/+47
This adds and improves doxygen API descriptions all over libosmocore, reducing the 'white spots' that don't have any documentation.
2016-05-05Add log_fini() function to release all memory allocated by logging frameworkHarald Welte1-0/+15
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-04-16logging.c: assert category_token allocation (CID #57871)Neels Hofmeyr1-0/+1
2016-02-29logging: Remove unused variable after recent changesHolger Hans Peter Freyther1-1/+0
The variable is not used anymore as the decision is done in the newly added check_log_to_target method.
2016-02-29logging: Move the filter check up as wellHolger Hans Peter Freyther1-11/+9
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-29logging: Remove some code duplicationHolger Hans Peter Freyther1-37/+37
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-29log: Add log_check_level functionJacob Erlbeck1-0/+39
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
2015-11-02log: Add new DLSTATS log levelJacob Erlbeck1-0/+5
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-03-18logging: Implement subsecond resolution of extended timestampsJacob Erlbeck1-4/+7
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
2014-12-28log: "logging level everything" is a badly named option.Holger Hans Peter Freyther1-1/+1
We tried to fix it but it isn't that easy. The original fix was cd6ed82d1ff48f47ad9e33e6322df62896a76ed5 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-05logging: Call color only once and use the resultHolger Hans Peter Freyther1-1/+1
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-05logging: Make it possible to print category/subsys and timestampsHolger Hans Peter Freyther1-1/+49
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-04gtp: Add a global region for the gtp library of OpenGGSNHolger Hans Peter Freyther1-0/+5
We want to use libosmocore/libosmovty in the GGSN sourcecode and reserve a global region here.
2014-08-21libctrl: Add DLCTRL as logging context for the control interfaceHarald Welte1-0/+5
... and make libctrl code use it
2013-12-29logging: Copy the filter_fn and fix the IMSI filter in OpenBSCHolger Hans Peter Freyther1-0/+1
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-03-19Revert "Follow up fix for the log level "everything""Harald Welte1-3/+0
This reverts commit a6428d2376034d619f342897d3ce415b3f9a3584.
2013-03-19Revert "Fix log level "everything" and make it equal to "debug""Harald Welte1-1/+1
This reverts commit cd6ed82d1ff48f47ad9e33e6322df62896a76ed5.
2013-03-18logging: add new log_targets_reopen() functionHarald Welte1-0/+20
This function will re-open all existing log files in the application, praticularly useful for SIGHUP handlers in case of logrotate
2013-02-27Follow up fix for the log level "everything"Holger Hans Peter Freyther1-0/+3
Commit cd6ed82d1ff48f47ad9e33e6322df62896a76ed5 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-19Fix log level "everything" and make it equal to "debug"Harald Welte1-1/+1
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-01-11add some missing doxygen annotation for libosmocore functionsHarald Welte1-0/+9
2012-09-27logging.c: Do not crash on empty category nameNico Golde1-5/+7
log_parse_category_mask(), skip log category name right away if name is NULL to prevent passing a NULL ptr to strlen.
2012-09-11logging: Introduce a print_filename flag for the logtargetHolger Hans Peter Freyther1-5/+17
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-11logging: Mark the log_info_cat pointer as constsHolger Hans Peter Freyther1-2/+3
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-07-12logging: Fix compile breakage introduced by the warning fixesHolger Hans Peter Freyther1-4/+4
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-04-18doc: Fix the Doxygen section endingsSylvain Munaut1-1/+1
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12gsm/sms: Added DLSMS debuggingAndreas Eversberg1-0/+6
Written-by: Andreas Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-10Changed logging of LAPD from DLLAPDM to DLLAPDroot1-3/+3
2011-08-31logging: add osmo_vlogp() as vararg / va_list compatible functionHarald Welte1-4/+5
2011-08-17doxygen documentation for logging frameworkHarald Welte1-5/+79
2011-08-11logging: fix parsing of logging mask (-d DMI case)Pablo Neira Ayuso1-0/+5
Without this patch, `-d DMI' enables logging for DMI and DMIB. Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-07-29use the 'L' prefix in debug names (DLINP instead of DINP)Harald Welte1-4/+4
2011-07-21remove DLRSL and DLNM, we don't need themHarald Welte1-12/+0
They are not used anywhere in our libraries, so they should be defined by the respective applications
2011-07-19make sure we don't have namespace clashes between libraries and appsHarald Welte1-6/+6
* 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-18logging: add libosmo-abis logging subsystemsPablo Neira Ayuso1-0/+34
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.