OSyslog.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of openSDK.
00003  *
00004  * Copyright (C) 2006-2007 openSDK team
00005  *
00006  * openSDK is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; version 2.
00009  *
00010  * openSDK is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with openSDK; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  *     $Id: OSyslog.cc,v 1.6 2007/01/26 23:12:05 nuno-lopes Exp $
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 }

Generated on Sun Dec 2 23:04:30 2007 for openSDK by  doxygen 1.3.9.1