diff options
author | phintuka <phintuka> | 2008-11-04 11:55:42 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2008-11-04 11:55:42 +0000 |
commit | 6be338300efacd47400691300ecd5237b75a5a05 (patch) | |
tree | 633fb97b4fc2dcd6ce770008cea6a38202465ec0 | |
parent | f2316d4ca0cee19a23b9ea6a009ed35fff930915 (diff) | |
download | xineliboutput-6be338300efacd47400691300ecd5237b75a5a05.tar.gz xineliboutput-6be338300efacd47400691300ecd5237b75a5a05.tar.bz2 |
New file: moving x_syslog from logdefs.h to own compilation unit.
There's no need to have static x_syslog in n+1 modules ...
-rw-r--r-- | logdefs.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/logdefs.c b/logdefs.c new file mode 100644 index 00000000..444af5ce --- /dev/null +++ b/logdefs.c @@ -0,0 +1,49 @@ +/* + * logdefs.c: Logging and debug output + * + * See the main source file 'xineliboutput.c' for copyright information and + * how to reach the author. + * + * $Id: logdefs.c,v 1.1 2008-11-04 11:55:42 phintuka Exp $ + * + */ + +#include "logdefs.h" + +#include <stdio.h> +#include <unistd.h> +#include <sys/syscall.h> +#include <stdarg.h> + +#ifndef __APPLE__ +# include <linux/unistd.h> /* syscall(__NR_gettid) */ +#endif + +extern int LogToSysLog; /* xine_frontend.c, log to syslog instead of console */ + +void x_syslog(int level, const char *module, const char *fmt, ...) +{ + va_list argp; + char buf[512]; + + va_start(argp, fmt); + vsnprintf(buf, 512, fmt, argp); + buf[sizeof(buf)-1] = 0; + +#ifndef __APPLE__ + if(!LogToSysLog) { + fprintf(stderr,"[%ld] %s%s\n", (long int)syscall(__NR_gettid), module, buf); + } else { + syslog(level, "[%ld] %s%s", (long int)syscall(__NR_gettid), module, buf); + } +#else + if(!LogToSysLog) { + fprintf(stderr, "%s%s\n", module, buf); + } else { + syslog(level, "%s%s", module, buf); + } +#endif + + va_end(argp); +} + |