00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <OPENR/OSyslog.h>
00023 #include <stdio.h>
00024 #include <stdarg.h>
00025 #include <pthread.h>
00026 #include "ModuleData.h"
00027
00028 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
00029 #define LOCK() pthread_mutex_lock(&mutex)
00030 #define UNLOCK() pthread_mutex_unlock(&mutex)
00031
00032
00033 OStatus osyslog(OSyslogPriority priority, const char* format, ...)
00034 {
00035 va_list args;
00036 va_start(args, format);
00037
00038 LOCK();
00039 printf("[oid:%zd,prio:%ld] ", MOD_DATA(OID), (unsigned long)priority);
00040 vprintf(format, args);
00041 printf("\n");
00042 UNLOCK();
00043
00044 va_end(args);
00045 return oSUCCESS;
00046 }
00047
00048 OStatus osysprint(const char* format, ...)
00049 {
00050 va_list args;
00051 va_start(args, format);
00052
00053 LOCK();
00054 vprintf(format, args);
00055 UNLOCK();
00056
00057 va_end(args);
00058 return oSUCCESS;
00059 }