New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On non-Windows systems, send logs to syslog & stderr. #340
Conversation
jynik: Haven't tested this yet. But I think something like this might suite the need? |
¤2 According to request ¤3 Is a suggestion. Consider it and cherry-pick if it's to your liking, but please don't if you don't like it. Note that even though it has it's benefits, it does not aid to readability. It does however provide a mechanism to initialize which is otherwise easily forgotten by the whoever uses a library. For further explanation and alternative ways, see my answer here: http://stackoverflow.com/questions/2053029/how-exactly-does-attribute-constructor-work |
653d806
to
6430e91
Compare
Drawbacks improved. Should at be testable on any platform without braking either build or behavior. Note: pushed with '-f' due to rebase, squashes and amend. Pulls will not merge clean. Throw away old branches and start over (i.e. git fetch, git checkout e.t.a.) |
I mean of course s/improved/eliminated/ , s/at/at least/ and s/braking/breaking/ |
Quickly test drove this on Linux and OSX -- seems to work well! I still have to just double check for any Windows-related build issues. Did you have any particular qualms or concerns with the init/fini items? I don't think there's much of a readability issue. Did you have functional or portability concerns? Otherwise, it seems fine to me. I think the only feedback I have for now is that the "Log verbosity has been set to" and "BladeRF host software (de)initializing" messages at the INFO level create a lot of noise. I'd prefer that these be moved to the DEBUG or VERBOSE levels. To move forward with pulling this in...
|
Sorry for the late response. Regarding further functional concerns, I assume what is meant not the the I'm always concerned by portability. I have no Windows machine to try on, My thoughts where furthermore as follows:
Will fix squash, log-level and icaa ASAP. Regards Quickly test drove this on Linux and OSX -- seems to work well! I still Did you have any particular qualms or concerns with the init/fini items? I I think the only feedback I have for now is that the "Log verbosity has To move forward with pulling this in...
@mambrus https://github.com/mambrus, — |
6430e91
to
45da75d
Compare
New upload according to comments. NOTE: This is a forced push. Original pre-squashed commits (complete branch) is moved here for future reference: https://github.com/mambrus/bladeRF/tree/log2syslog_NOT_squashed |
OpenBTS and YateBTS fork a transceiver sub-process and redirect stderr and stdout, which effectively hide any bladerf logs. For debugging time-critical code, printf debugging (or logging) is simple yet practically essential. Logging to syslog made opt-in. To enable: -DDENABLE_LIBBLADERF_SYSLOG To make this as transparent as possible, a generic mechanism for initializing libraries without having to use any specific pre-known function has been introduced (see init_fini.c). Currently it's only real purpose is to closelog() upon unloading library. Failing doing this is an error affecting the case library is unloaded manually.
Commit covers two cases: 1) bladerf-CLI type of case where bladerf_log_set_verbosity is set by the application, one doesn't want unexpected verbosity during app-startup. 2) Spawned processes that use bladerf as a library. These need a fair default, but also require verbosity to be adjustable without requiring additional interfaces. To cover both these, fall-back default is to have verbosity set to BLADERF_LOG_LEVEL_WARNING. However, libbladerf will listen to the environment variable BLADERF_LOG_LEVEL. If set, it's value will be used as library default instead.
9cbd39a
to
1fe953f
Compare
I pulled this into the Nuand repo in a dev-issue_345 branch with a couple minor changes. As you'll see, I'd prefer the use of str2loglevel() over atoi(), allowing the use of BLADERF_LOG_LEVEL=debug or BLADERF_LOG_LEVEL=verbose rather than numbers that I personally could never remember. |
Tested on OSX. Just a heads up, it looks like each log_*() call causes a broadcast message to be sent to every TTY. This is just with a Do you have any OSX boxes to take a gander at this? |
Looks like the above behavior is the result of a system config for emergency messages, based on my
|
Integrated in 344d497 |
OpenBTS and YateBTS fork a transceiver sub-process and redirect stderr and
stdout, which effectively hide any bladerf logs. For debugging time-critical
code, printf debugging (or logging) is simple yet practically essential.