l4log.h

Go to the documentation of this file.
00001 /*!
00002  * \file   log/include/l4log.h
00003  * \brief  Logging facility - Macros and function declaration
00004  *
00005  * \date   03/14/2001
00006  * \author Jork Loeser <jork.loeser@inf.tu-dresden.de>
00007  */
00008 /* (c) 2003 Technische Universitaet Dresden
00009  * This file is part of DROPS, which is distributed under the terms of the
00010  * GNU General Public License 2. Please see the COPYING file for details.
00011  */
00012 
00013 #ifndef __LOG_INCLUDE_L4LOG_H_
00014 #define __LOG_INCLUDE_L4LOG_H_
00015 
00016 #include <l4/sys/compiler.h>
00017 
00018 EXTERN_C_BEGIN
00019 
00020 #include <l4/log/log_printf.h>
00021 
00022 /*!\brief Symbol defining the logtag.
00023  *
00024  * This is a weak symbol which can be overwritten to define the logtag.  The
00025  * intention is that you can set the logtag on compile-time, if you cannot
00026  * guarantee to call LOG_init() prior to first output for whatever reasons.
00027  *
00028  * Use one of the two methods to define the logtag, either by defining this
00029  * symbol or by calling LOG_init().
00030  *
00031  * \note The length of the symbol must be 9 characters in length, and it
00032  *       must be 0-terminated.
00033  * \see  LOG_init()
00034  */
00035 extern char LOG_tag[9];
00036 
00037 #if 0
00038 /*!\brief Initialize the lib.
00039  *
00040  * \param tag   the logtag
00041  *
00042  * This function sets the logtag, which is writted at the beginning
00043  * of each line.
00044  *
00045  * \see  LOG_tag.
00046  */
00047 extern void LOG_init(const char *tag);
00048 #else
00049 #define LOG_init(arg) LOG_init_is_deprecated=0
00050 /* LOG_setup_tag is called by setup code, don't call this from your program. */
00051 L4_CV void LOG_setup_tag(void);
00052 #endif
00053 
00054 
00055 /*!\brief variable containing the text output function
00056  *
00057  * This variable holds the function to output the formated string. You
00058  * can re-initialize it to use your own function. In non-server-mode this
00059  * points to a putchar-loop, in server-mode a string-ipc-function will
00060  * be used.
00061  */
00062 extern L4_CV void (*LOG_outstring)(const char*log_message);
00063 
00064 /*!\brief Log-output function printing to the fiasco tracebuffer
00065  *
00066  * This specific version of a text output function uses the fiasco
00067  * tracebuffer as output channel.
00068  */
00069 L4_CV void LOG_outstring_fiasco_tbuf(const char*log_message);
00070 
00071 /*!\brief flush all buffered data.
00072  *
00073  * This function ensures that all data logged so far is actually printed.
00074  * If used with the logserver, the logserver flushs all its buffered data.
00075  */
00076 L4_CV void LOG_flush(void);
00077 
00078 /*!\brief an allways-defined DEBUG flag
00079  */
00080 #ifdef DEBUG
00081 #define LOG_DEBUG 1
00082 #else
00083 #define LOG_DEBUG 0
00084 #endif
00085 
00086 L4_CV void LOG_log(const char*function, const char*format,...);
00087 L4_CV void LOG_logl(const char*file, int line, const char*function,
00088                     const char*format,...);
00089 L4_CV void LOG_logL(const char*file, int line, const char*function,
00090                     const char*format,...);
00091 
00092 #ifndef L4BID_RELEASE_MODE
00093 /* format_check: just for the compiler to check the format & args */
00094 L4_CV void LOG_format_check(const char*format,...)
00095   __attribute__((format(printf,1,2)));
00096 
00097 #define STRINGIFY_HELPER(nr)            #nr
00098 #define LINE_PRESCAN_SUBST(ln)          STRINGIFY_HELPER(ln)
00099 #define __LINE_STR__                    LINE_PRESCAN_SUBST(__LINE__)
00100 
00101 #define LOG(a...) do {                          \
00102   if(0)LOG_format_check(a);                     \
00103   LOG_log(__FUNCTION__, a);                     \
00104 } while(0)
00105 
00106 #define LOGl(a...) do {                         \
00107   if(0)LOG_format_check(a);                     \
00108   LOG_logl(__FILE__,__LINE__,__FUNCTION__, a);  \
00109 } while(0)
00110 
00111 #define LOGL(a...) do {                         \
00112   if(0)LOG_format_check(a);                     \
00113   LOG_logL(__FILE__,__LINE__,__FUNCTION__, a);  \
00114 } while(0)
00115 
00116 #define LOG_Enter(a...) do {                    \
00117   if(0)LOG_format_check("called "a);            \
00118   LOG_log(__FUNCTION__, "called "a);            \
00119 } while(0)
00120 
00121 #define LOGk(a...) do {                         \
00122   if(0)LOG_format_check(a);                     \
00123   LOG_logk(a);                                  \
00124 } while(0)
00125 
00126 #define LOGd_Enter(doit, msg...) do { if(doit) LOG_Enter(msg); } while (0)
00127 #define LOGd(doit, msg...)       do { if(doit) LOG(msg);       } while (0)
00128 #define LOGdl(doit,msg...)       do { if(doit) LOGl(msg);      } while (0)
00129 #define LOGdL(doit,msg...)       do { if(doit) LOGL(msg);      } while (0)
00130 #define LOGdk(doit,msg...)       do { if(doit) LOGk(msg);      } while (0)
00131 #define LOG_Error(msg...)        LOGL("Error: " msg)
00132 
00133 #define LOG_logk(format...)      do {                                     \
00134                                    char buf[35];                          \
00135                                    LOG_snprintf(buf,sizeof(buf),format);  \
00136                                    LOG_outstring_fiasco_tbuf(buf);        \
00137                                  } while (0)
00138 
00139 #else
00140 #define LOG(a...)
00141 #define LOGl(a...)
00142 #define LOGL(a...)
00143 #define LOGk(a...)
00144 #define LOG_Enter(a...)
00145 #define LOGd_Enter(doit, msg...)
00146 #define LOGd(doit, msg...)
00147 #define LOGdl(doit,msg...)
00148 #define LOGdL(doit,msg...)
00149 #define LOGdk(doit,msg...)
00150 #define LOG_Error(msg...)
00151 #endif
00152 
00153 EXTERN_C_END
00154 #endif

Generated on Wed Apr 11 06:40:52 2012 for Logging and output facility for DROPS by  doxygen 1.5.6