Discussion:
How to enable logging in olsr2?
Henning Rogge
2013-05-27 07:31:52 UTC
Permalink
Hi,
what is required to enable oonf_api logging to stderr/syslog and
setting a log level from within the code?
A good question, time for another mail to explain things about Olsrd2..
(sending this to the olsr-dev list too).

I just pushed some cleanup to the logging system, so please run a "git
pull" on both repositories.

The OONF-Logging System
***********************

The OONF-api currently use a logging system with three log severities
(debug, info, warning) and a large number of logging sources. Each of
these logging sources can be set to log only warnings, warnings and info
messages or all logging messages.

Default behavior is to log all warnings.

In addition to logging sources the OONF-api use logging "handlers" as
consumers of logging messages. There can be multiple handlers at the
same time and they can be changed even at runtime (through a plugin for
example).

Each plugin can define additional logging sources, normally they should
use the plugin name as the logging source name (if they use one at all).

There are three logging handlers directly implemented in the oonf-api,
"stderr", "syslog" and "file". Default logging handler is "stderr".


Configuration of the Logging System
***********************************

The logging system is configured in a section called "log". Run "olsrd2
--schema" to get a list of all configuration sections.

The logging system uses five entries in 'log', two for defining logging
sources, three for activating logging handlers. Run "olsrd2
--schema=log" to see the configuration entries in 'log'.

"debug" and "info" are lists, which mean they can be used multiple
times. Each value activates a single logging source for debug/info
level, warnings are always active. Run "olsrd2 --schema=log.debug" or
"olsrd2 --schema=log.info" to get a list of all logging sources. The
source "all" is a combination of all logging sources.


Example configuration file
**************************

[log]
debug os_routing
info http
syslog true


This example activates debug, info and warning messages for the
'os_routing' source and info/warnings for the 'http' source. It also
activates the 'syslog' handler.


Example configuration by parameters
***********************************

./olsrd2 --set log.debug=os_routing --set log.info=http --set
log.syslog=true


This command line triggers exactly the same configuration options as the
configuration file shown above.

You can mix both configuration file and command line options.


How to generate logging output in the code
******************************************

There are three macros to generate logging output (OONF_DEBUG, OONF_INFO
and OONF_WARN). All of them take a logging source (an 'enum
oonf_log_source') as the first parameter, the rest of the parameters are
the same as the printf() call. The macros also add a '\n' at the end if
your output string does not end with one.


OONF_DEBUG(LOG_TIMER, "Timer %s expired!", timer->name);


Henning Rogge
--
Diplom-Informatiker Henning Rogge , Fraunhofer-Institut für
Kommunikation, Informationsverarbeitung und Ergonomie FKIE
Kommunikationssysteme (KOM)
Fraunhofer Straße 20, 53343 Wachtberg, Germany
Telefon +49 228 9435-961, Fax +49 228 9435 685
mailto:***@fkie.fraunhofer.de http://www.fkie.fraunhofer.de
--
Olsr-dev mailing list
Olsr-***@lists.olsr.org
https://lists.olsr.org/mailman/listinfo/olsr-dev
Benjamin Valentin
2013-05-31 02:52:44 UTC
Permalink
Thank you a lot for your very detailed mail!
But since on RIOT, I neither have a command line nor config files, I'm
trying to enable logging with

cfg_cmd_handle_set(oonf_cfg_get_instance(), oonf_cfg_get_rawdb(), "log.debug=all", NULL);

This works when I insert it in oonf_main.c, but on my slightly
butchered version [1] of it (just stripped of signal handling and
command line parsing), the line doesn't seem to have any effect as I
only receive WARN messages still.

2013-05-31 04:33:32,636 - INFO # initializing timer…
2013-05-31 04:33:32,665 - INFO # TODO: select not implemented
2013-05-31 04:33:32,701 - INFO # select(0, 0x0, 0x0, 0x0, 2.100000)
2013-05-31 04:33:32,777 - INFO # (null) WARN(socket) oonf_socket.c 224: select error: Bad file number (9)
2013-05-31 04:33:32,806 - INFO # TODO: select not implemented
2013-05-31 04:33:32,842 - INFO # select(0, 0x0, 0x0, 0x0, 0.500000)
2013-05-31 04:33:32,975 - INFO # (null) WARN(socket) oonf_socket.c 224: select error: Bad file number (9)
2013-05-31 04:33:33,039 - INFO # (null) WARN(main) main.c 227: Grace period for shutdown failed.

(disregard select() being not available yet…)

The previous cfg_db_add_namedsection(oonf_cfg_get_rawdb(), CFG_INTERFACE_SECTION, "if0");
however seems to work, since without it I get

2013-05-31 04:32:04,993 - INFO # (null) WARN(config) oonf_cfg.c 304: Configuration validation failed
2013-05-31 04:32:05,039 - INFO # Missing mandatory section of type 'interface'
2013-05-31 04:32:05,085 - INFO # Missing mandatory section of type 'interface'
2013-05-31 04:32:05,131 - INFO # Missing mandatory section of type 'interface'

I know this is not your concern/code, but maybe you can give me a pointer
to what might be missing here.

Thank you
Benjamin

[1] https://github.com/benpicco/olsrd2/blob/master/riot/main.c#L152
--
Olsr-dev mailing list
Olsr-***@lists.olsr.org
https://list
Henning Rogge
2013-05-31 10:24:25 UTC
Permalink
Is there a reason why you try to sidestep the Cmake based build system?

Henning

On Fri, May 31, 2013 at 4:52 AM, Benjamin Valentin
Post by Benjamin Valentin
Thank you a lot for your very detailed mail!
But since on RIOT, I neither have a command line nor config files, I'm
trying to enable logging with
cfg_cmd_handle_set(oonf_cfg_get_instance(), oonf_cfg_get_rawdb(), "log.debug=all", NULL);
This works when I insert it in oonf_main.c, but on my slightly
butchered version [1] of it (just stripped of signal handling and
command line parsing), the line doesn't seem to have any effect as I
only receive WARN messages still.
2013-05-31 04:33:32,636 - INFO # initializing timer…
2013-05-31 04:33:32,665 - INFO # TODO: select not implemented
2013-05-31 04:33:32,701 - INFO # select(0, 0x0, 0x0, 0x0, 2.100000)
2013-05-31 04:33:32,777 - INFO # (null) WARN(socket) oonf_socket.c 224: select error: Bad file number (9)
2013-05-31 04:33:32,806 - INFO # TODO: select not implemented
2013-05-31 04:33:32,842 - INFO # select(0, 0x0, 0x0, 0x0, 0.500000)
2013-05-31 04:33:32,975 - INFO # (null) WARN(socket) oonf_socket.c 224: select error: Bad file number (9)
2013-05-31 04:33:33,039 - INFO # (null) WARN(main) main.c 227: Grace period for shutdown failed.
(disregard select() being not available yet…)
The previous cfg_db_add_namedsection(oonf_cfg_get_rawdb(), CFG_INTERFACE_SECTION, "if0");
however seems to work, since without it I get
2013-05-31 04:32:04,993 - INFO # (null) WARN(config) oonf_cfg.c 304: Configuration validation failed
2013-05-31 04:32:05,039 - INFO # Missing mandatory section of type 'interface'
2013-05-31 04:32:05,085 - INFO # Missing mandatory section of type 'interface'
2013-05-31 04:32:05,131 - INFO # Missing mandatory section of type 'interface'
I know this is not your concern/code, but maybe you can give me a pointer
to what might be missing here.
Thank you
Benjamin
[1] https://github.com/benpicco/olsrd2/blob/master/riot/main.c#L152
--
Olsr-dev mailing list
https://lists.olsr.org/mailman/listinfo/olsr-dev
--
We began as wanderers, and we are wanderers still. We have lingered
long enough on the shores of the cosmic ocean. We are ready at last to
set sail for the stars - Carl Sagan
--
Olsr-dev mailing list
Olsr-***@lists.olsr.org
https://lists.olsr.org/mailman/listinfo/olsr-dev
Henning Rogge
2013-05-31 10:42:57 UTC
Permalink
Hi,

after looking through your code I would say that your selfmade
makefile system is just incomplete. the oonf-API (and olsrd2) allow to
remove the code for the debug/info messages based on a set of compiler
defines. I would guess that you don't handle this part so debug/info
are not in the code you compile.

As a quick hack to test this I would suggest adding

-DOONF_LOG_INFO -DOONF_LOG_DEBUG_INFO

to your compilter options.

Henning

On Fri, May 31, 2013 at 4:52 AM, Benjamin Valentin
Post by Benjamin Valentin
Thank you a lot for your very detailed mail!
But since on RIOT, I neither have a command line nor config files, I'm
trying to enable logging with
cfg_cmd_handle_set(oonf_cfg_get_instance(), oonf_cfg_get_rawdb(), "log.debug=all", NULL);
This works when I insert it in oonf_main.c, but on my slightly
butchered version [1] of it (just stripped of signal handling and
command line parsing), the line doesn't seem to have any effect as I
only receive WARN messages still.
2013-05-31 04:33:32,636 - INFO # initializing timer…
2013-05-31 04:33:32,665 - INFO # TODO: select not implemented
2013-05-31 04:33:32,701 - INFO # select(0, 0x0, 0x0, 0x0, 2.100000)
2013-05-31 04:33:32,777 - INFO # (null) WARN(socket) oonf_socket.c 224: select error: Bad file number (9)
2013-05-31 04:33:32,806 - INFO # TODO: select not implemented
2013-05-31 04:33:32,842 - INFO # select(0, 0x0, 0x0, 0x0, 0.500000)
2013-05-31 04:33:32,975 - INFO # (null) WARN(socket) oonf_socket.c 224: select error: Bad file number (9)
2013-05-31 04:33:33,039 - INFO # (null) WARN(main) main.c 227: Grace period for shutdown failed.
(disregard select() being not available yet…)
The previous cfg_db_add_namedsection(oonf_cfg_get_rawdb(), CFG_INTERFACE_SECTION, "if0");
however seems to work, since without it I get
2013-05-31 04:32:04,993 - INFO # (null) WARN(config) oonf_cfg.c 304: Configuration validation failed
2013-05-31 04:32:05,039 - INFO # Missing mandatory section of type 'interface'
2013-05-31 04:32:05,085 - INFO # Missing mandatory section of type 'interface'
2013-05-31 04:32:05,131 - INFO # Missing mandatory section of type 'interface'
I know this is not your concern/code, but maybe you can give me a pointer
to what might be missing here.
Thank you
Benjamin
[1] https://github.com/benpicco/olsrd2/blob/master/riot/main.c#L152
--
Olsr-dev mailing list
https://lists.olsr.org/mailman/listinfo/olsr-dev
--
We began as wanderers, and we are wanderers still. We have lingered
long enough on the shores of the cosmic ocean. We are ready at last to
set sail for the stars - Carl Sagan
--
Olsr-dev mailing list
Olsr-***@lists.olsr.org
https://lists.olsr.org/mailman/listinfo/olsr-dev
Benjamin Valentin
2013-05-31 14:00:35 UTC
Permalink
Am Fri, 31 May 2013 12:42:57 +0200
Post by Henning Rogge
As a quick hack to test this I would suggest adding
-DOONF_LOG_INFO -DOONF_LOG_DEBUG_INFO
to your compilter options.
Thank you, that works.
Post by Henning Rogge
Is there a reason why you try to sidestep the Cmake based build
system?
Since I'm not familiar with setting up CMake CrossCompile, especially
for a system yet unknown to CMake, I found this to be the easiest
solution. All RIOT applications so far are integrated into the Makefile
based RIOT buildsystem (and linked directly against the RIOT Kernel and
newlib, there is a single binary that gets flashed onto the device), so
I did the same with olsr2.

Benjamin
--
Olsr-dev mailing list
Olsr-***@lists.olsr.org
https://lists.olsr.org/mailman/listinfo/olsr-dev
Henning Rogge
2013-05-31 14:07:44 UTC
Permalink
There are a few crosscompile examples in the cmake/cross subdirectory.
I think one for clang (just different compiler) and one for win32.

Henning

On Fri, May 31, 2013 at 4:00 PM, Benjamin Valentin
Post by Benjamin Valentin
Am Fri, 31 May 2013 12:42:57 +0200
Post by Henning Rogge
As a quick hack to test this I would suggest adding
-DOONF_LOG_INFO -DOONF_LOG_DEBUG_INFO
to your compilter options.
Thank you, that works.
Post by Henning Rogge
Is there a reason why you try to sidestep the Cmake based build
system?
Since I'm not familiar with setting up CMake CrossCompile, especially
for a system yet unknown to CMake, I found this to be the easiest
solution. All RIOT applications so far are integrated into the Makefile
based RIOT buildsystem (and linked directly against the RIOT Kernel and
newlib, there is a single binary that gets flashed onto the device), so
I did the same with olsr2.
Benjamin
--
Olsr-dev mailing list
https://lists.olsr.org/mailman/listinfo/olsr-dev
--
We began as wanderers, and we are wanderers still. We have lingered
long enough on the shores of the cosmic ocean. We are ready at last to
set sail for the stars - Carl Sagan
--
Olsr-dev mailing list
Olsr-***@lists.olsr.org
https://lists.olsr.org/mailman/listinfo/olsr-dev
Loading...