From: Jan Pospíšil Date: Fri, 10 Jul 2009 14:10:06 +0000 (+0000) Subject: initial import of common logging X-Git-Tag: gridsite-core_R_1_7_4~18 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=80e4857b1328f87c3bddca0e16d5236ef14f285d;p=jra1mw.git initial import of common logging --- diff --git a/org.glite.lbjp-common.log/LICENSE b/org.glite.lbjp-common.log/LICENSE new file mode 100644 index 0000000..01b973b --- /dev/null +++ b/org.glite.lbjp-common.log/LICENSE @@ -0,0 +1,69 @@ +LICENSE file for EGEE Middleware +================================ + +Copyright (c) 2004 on behalf of the EU EGEE Project: +The European Organization for Nuclear Research (CERN), +Istituto Nazionale di Fisica Nucleare (INFN), Italy +Datamat Spa, Italy +Centre National de la Recherche Scientifique (CNRS), France +CS Systeme d'Information (CSSI), France +Royal Institute of Technology, Center for Parallel Computers (KTH-PDC), Sweden +Universiteit van Amsterdam (UvA), Netherlands +University of Helsinki (UH.HIP), Finlan +University of Bergen (UiB), Norway +Council for the Central Laboratory of the Research Councils (CCLRC), United Kingdom + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. The end-user documentation included with the redistribution, if +any, must include the following acknowledgment: "This product includes +software developed by The EU EGEE Project (http://cern.ch/eu-egee/)." +Alternatively, this acknowledgment may appear in the software itself, if +and wherever such third-party acknowledgments normally appear. + +4. The names EGEE and the EU EGEE Project must not be +used to endorse or promote products derived from this software without +prior written permission. For written permission, please contact +. + +5. You are under no obligation whatsoever to provide anyone with any +bug fixes, patches, or upgrades to the features, functionality or +performance of the Software ("Enhancements") that you may develop over +time; however, if you choose to provide your Enhancements to The EU +EGEE Project, or if you choose to otherwise publish or distribute your +Enhancements, in source code form without contemporaneously requiring +end users of The EU EGEE Proejct to enter into a separate written license +agreement for such Enhancements, then you hereby grant The EU EGEE Project +a non-exclusive, royalty-free perpetual license to install, use, copy, +modify, prepare derivative works, incorporate into the EGEE Middleware +or any other computer software, distribute, and sublicense your +Enhancements or derivative works thereof, in binary and source code +form (if any), whether developed by The EU EGEE Project or third parties. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL PROJECT OR ITS CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +This software consists of voluntary contributions made by many +individuals on behalf of the EU EGEE Prject. For more information on The +EU EGEE Project, please see http://cern.ch/eu-egee/. For more information on +EGEE Middleware, please see http://egee-jra1.web.cern.ch/egee-jra1/ + + diff --git a/org.glite.lbjp-common.log/Makefile b/org.glite.lbjp-common.log/Makefile new file mode 100644 index 0000000..b0b5601 --- /dev/null +++ b/org.glite.lbjp-common.log/Makefile @@ -0,0 +1,32 @@ +top_srcdir=.. +stagedir=../stage +globalprefix=glite +lbutilsprefix=lbu +package=glite-lbu-log +version=0.0.0 +PREFIX=/opt/glite + +log4c_prefix=/usr + +-include Makefile.inc +-include ./project/version.properties + +HEADER=log.h +EXAMPLE=log4crc.example + +default: compile + +compile: + +stage: compile + $(MAKE) install PREFIX=${stagedir} + +install: compile + mkdir -p ${PREFIX}/include/${globalprefix}/${lbutilsprefix} + install -m 644 ${HEADER} ${PREFIX}/include/${globalprefix}/${lbutilsprefix} + mkdir -p ${PREFIX}/share/doc/${package}-${version} + install -m 644 ${EXAMPLE} LICENSE ${PREFIX}/share/doc/${package}-${version} +clean: + rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/ + +check: diff --git a/org.glite.lbjp-common.log/Makefile.inc b/org.glite.lbjp-common.log/Makefile.inc new file mode 100644 index 0000000..6fac5b6 --- /dev/null +++ b/org.glite.lbjp-common.log/Makefile.inc @@ -0,0 +1,3 @@ +PREFIX = /home/honik/egee-sl4/glite-lb_HEAD/stage +stagedir = /home/honik/egee-sl4/glite-lb_HEAD/stage + diff --git a/org.glite.lbjp-common.log/log.h b/org.glite.lbjp-common.log/log.h new file mode 100644 index 0000000..3bd9031 --- /dev/null +++ b/org.glite.lbjp-common.log/log.h @@ -0,0 +1,121 @@ +#ifndef GLITE_LBU_LOG_H +#define GLITE_LBU_LOG_H + +#ident "$Header$" + +/* gLite common logging recommendations v1.1 https://twiki.cern.ch/twiki/pub/EGEE/EGEEgLite/logging.html */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* default categories */ +#define LOG_CATEGORY_NAME "root" +#define LOG_CATEGORY_SECURITY "SECURITY" +#define LOG_CATEGORY_ACCESS "ACCESS" +#define LOG_CATEGORY_CONTROL "CONTROL" +#define LOG_CATEGORY_LB "LB" +#define LOG_CATEGORY_LB_LOGD "LB.LOGD" +#define LOG_CATEGORY_LB_IL "LB.IL" +#define LOG_CATEGORY_LB_SERVER "LB.SERVER" + +/* default priorities */ +#define LOG_PRIORITY_FATAL LOG4C_PRIORITY_FATAL +#define LOG_PRIORITY_ERROR LOG4C_PRIORITY_ERROR +#define LOG_PRIORITY_WARN LOG4C_PRIORITY_WARN +#define LOG_PRIORITY_INFO LOG4C_PRIORITY_INFO +#define LOG_PRIORITY_DEBUG LOG4C_PRIORITY_DEBUG +#define LOG_PRIORITY_NOTSET LOG4C_PRIORITY_NOTSET + +#define SYSTEM_ERROR(my_err) { \ + if (errno !=0 ) \ + glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_ERROR,"%s: %s\n",my_err,strerror(errno)); \ + else \ + glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_ERROR,"%s\n",my_err); } + +/* logging functions */ + +/** + * constructor + * + * @returns 0 for success + */ +static inline int glite_common_log_init(void) { +#ifndef WITHOUT_LOG4C + return(log4c_init()); +#else + return 0; +#endif +} + +/** + * destructor + * + * @returns 0 for success + */ +static inline int glite_common_log_fini(void) { +#ifndef WITHOUT_LOG4C + return(log4c_fini()); +#else + return 0; +#endif +} + + +/** + * Log a message with the specified priority. + * @param catName category name + * @param a_priority The priority of this log message. + * @param msg message + **/ +static inline void glite_common_log_msg(char *catName,int a_priority, char *msg) { +#ifndef WITHOUT_LOG4C + const log4c_category_t* a_category = log4c_category_get(catName); + + if (log4c_category_is_priority_enabled(a_category, a_priority)) { + log4c_category_log(log4c_category_get(catName), a_priority, msg); + } +#else + printf(msg); +#endif +} + +/** + * Log a message with the specified priority. + * @param catName category name + * @param a_priority The priority of this log message. + * @param a_format Format specifier for the string to write in the log file. + * @param ... The arguments for a_format + **/ +static inline void glite_common_log(char *catName,int a_priority, const char* a_format,...) { +#ifndef WITHOUT_LOG4C + const log4c_category_t* a_category = log4c_category_get(catName); + + if (log4c_category_is_priority_enabled(a_category, a_priority)) { + va_list va; + + va_start(va, a_format); + log4c_category_vlog(a_category, a_priority, a_format, va); + va_end(va); + } +#else + va_list va; + + va_start(va, a_format); + vprintf(va, a_format); + va_end(va); +#endif +} + +static inline void glite_common_log_reread(void) { +} + +#ifdef __cplusplus +} +#endif + +#endif /* GLITE_LBU_LOG_H */ diff --git a/org.glite.lbjp-common.log/log4crc.example b/org.glite.lbjp-common.log/log4crc.example new file mode 100644 index 0000000..9e157b2 --- /dev/null +++ b/org.glite.lbjp-common.log/log4crc.example @@ -0,0 +1,33 @@ + + + + + + + 0 + + 0 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.glite.lbjp-common.log/project/version.properties b/org.glite.lbjp-common.log/project/version.properties new file mode 100644 index 0000000..97368fe --- /dev/null +++ b/org.glite.lbjp-common.log/project/version.properties @@ -0,0 +1,4 @@ +# $Header$ +module.version=0.0.0 +module.age=0 +