Skip to content

Commit

Permalink
On non-Windows systems, send logs to syslog & stderr.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mambrus committed Nov 4, 2014
1 parent 90268d0 commit 4c4b5d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions host/common/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
*/
#ifdef LOGGING_ENABLED
#include <log.h>
#if defined(__linux__)
#include <syslog.h>
#endif
#include <stdio.h>
#include <stdarg.h>

Expand All @@ -38,7 +41,11 @@ void log_write(bladerf_log_level level, const char *format, ...)

/* Write the log message */
va_start(args, format);
#if !defined(__linux__)
vfprintf(stderr, format, args);
#else
vsyslog(LOG_USER, format, args);
#endif
va_end(args);
}
}
Expand Down
7 changes: 7 additions & 0 deletions host/libraries/libbladeRF/src/bladerf.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <stdio.h>
#include <string.h>
#include <limits.h>
#if defined(__linux__)
#include <syslog.h>
#endif
#include "rel_assert.h"

#include "libbladeRF.h" /* Public API */
Expand Down Expand Up @@ -1090,6 +1093,10 @@ const char * bladerf_strerror(int error)

void bladerf_version(struct bladerf_version *version)
{
#if !defined(WIN32) && !defined(__CYGWIN__)
openlog("bladeRF",
LOG_CONS | LOG_NDELAY | LOG_NOWAIT | LOG_PERROR | LOG_PID, LOG_USER);
#endif
version->major = LIBBLADERF_VERSION_MAJOR;
version->minor = LIBBLADERF_VERSION_MINOR;
version->patch = LIBBLADERF_VERSION_PATCH;
Expand Down

0 comments on commit 4c4b5d1

Please sign in to comment.