From: Adrian S. <a3s...@us...> - 2005-04-26 14:49:42
|
Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3333 Added Files: mlog.c mlog.h Log Message: Added logging code from gatherer - not yet exploited --- NEW FILE: mlog.h --- /* * $Id: mlog.h,v 1.1 2005/04/26 14:49:29 a3schuur Exp $ * * (C) Copyright IBM Corp. 2003, 2004 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Viktor Mihajlovski <mih...@de...m> * Contributors: * * Description: Logging * */ #ifndef MLOG_H #define MLOG_H #define M_DEBUG 1 #define M_INFO 2 #define M_ERROR 3 #define M_SHOW 1 #define M_QUIET 0 void m_start_logging(const char *name); void m_log(int priority, int errout, const char* fmt, ...); #endif --- NEW FILE: mlog.c --- /* * $Id: mlog.c,v 1.1 2005/04/26 14:49:29 a3schuur Exp $ * * (C) Copyright IBM Corp. 2003, 2004 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Viktor Mihajlovski <mih...@de...m> * Contributors: Michael Schuele <sch...@de...> * * Description: Metric Defintiona and Value data types. * */ const char *_mlog_id = "$Id: mlog.c,v 1.1 2005/04/26 14:49:29 a3schuur Exp $"; #include "mlog.h" #include <syslog.h> #include <stdarg.h> #include <stdio.h> void m_start_logging(const char *name) { openlog(name,LOG_PID,LOG_DAEMON); setlogmask(LOG_UPTO(LOG_INFO)); } void m_log(int priority, int errout, const char *fmt, ...) { va_list ap; int priosysl; char buf[4096]; switch (priority) { case M_DEBUG: priosysl=LOG_DEBUG; break; case M_INFO: priosysl=LOG_INFO; break; case M_ERROR: default: priosysl=LOG_ERR; break; } va_start(ap,fmt); vsnprintf(buf,4096,fmt,ap); syslog(priosysl,buf); if (errout) { vfprintf(stderr,fmt,ap); } va_end(ap); } |