reSIProcate/rutil  9694
Logger.hxx
Go to the documentation of this file.
00001 #ifndef RESIP_Logger_hxx
00002 #define RESIP_Logger_hxx
00003 
00004 #include "rutil/Log.hxx"
00005 #include "rutil/Lock.hxx"
00006 #include "rutil/DataStream.hxx"
00007 #include "rutil/Data.hxx"
00008 #include "rutil/Subsystem.hxx"
00009 
00010 #ifdef WIN32
00011 #include <windows.h>
00012 #endif 
00013 
00115 #define DELIM 
00116 
00117 
00118 
00119 // unconditionally output to cerr -- easily change back and forth
00120 #define CerrLog(args_)                                                  \
00121         resip::Log::tags(resip::Log::StdErr, RESIPROCATE_SUBSYSTEM,           \
00122                    __FILE__, __LINE__, resipCerr) << ' ' << '|' << ' '  \
00123           args_ << std::endl;
00124 
00125 #define StackLog(args_)                                                         \
00126 GenericLog(RESIPROCATE_SUBSYSTEM, resip::Log::Stack, args_)
00127 
00128 #define DebugLog(args_) \
00129 GenericLog(RESIPROCATE_SUBSYSTEM, resip::Log::Debug, args_)
00130 
00131 #define InfoLog(args_) \
00132 GenericLog(RESIPROCATE_SUBSYSTEM, resip::Log::Info, args_)
00133 
00134 #define WarningLog(args_) \
00135 GenericLog(RESIPROCATE_SUBSYSTEM, resip::Log::Warning, args_)
00136 
00137 #define ErrLog(args_) \
00138 GenericLog(RESIPROCATE_SUBSYSTEM, resip::Log::Err, args_)
00139 
00140 #define CritLog(args_) \
00141 GenericLog(RESIPROCATE_SUBSYSTEM, resip::Log::Crit, args_)
00142 
00143 static inline bool
00144 genericLogCheckLevel(resip::Log::Level level, const resip::Subsystem& sub)
00145 {
00146    return resip::Log::isLogging(level, sub);
00147 }
00148 
00149 // do/while allows a {} block in an expression
00150 #define GenericLog(system_, level_, args_)                              \
00151    do                                                                   \
00152    {                                                                    \
00153       if (genericLogCheckLevel(level_, system_))                        \
00154       {                                                                 \
00155          resip::Log::Guard _resip_log_guard(level_, system_, __FILE__, __LINE__); \
00156          _resip_log_guard.asStream()  args_;                            \
00157       }                                                                 \
00158    } while (false)
00159 
00160 #ifdef NO_DEBUG
00161 // Suppress debug logging at compile time
00162 #undef DebugLog
00163 #define DebugLog(args_)
00164 #undef StackLog 
00165 #define StackLog(args_)
00166 #endif
00167 
00168 namespace resip
00169 {
00171 typedef Log GenericLogImpl;
00172 }
00173 
00174 #endif
00175 
00176 /* ====================================================================
00177  * The Vovida Software License, Version 1.0 
00178  * 
00179  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00180  * 
00181  * Redistribution and use in source and binary forms, with or without
00182  * modification, are permitted provided that the following conditions
00183  * are met:
00184  * 
00185  * 1. Redistributions of source code must retain the above copyright
00186  *    notice, this list of conditions and the following disclaimer.
00187  * 
00188  * 2. Redistributions in binary form must reproduce the above copyright
00189  *    notice, this list of conditions and the following disclaimer in
00190  *    the documentation and/or other materials provided with the
00191  *    distribution.
00192  * 
00193  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00194  *    and "Vovida Open Communication Application Library (VOCAL)" must
00195  *    not be used to endorse or promote products derived from this
00196  *    software without prior written permission. For written
00197  *    permission, please contact vocal@vovida.org.
00198  *
00199  * 4. Products derived from this software may not be called "VOCAL", nor
00200  *    may "VOCAL" appear in their name, without prior written
00201  *    permission of Vovida Networks, Inc.
00202  * 
00203  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00204  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00205  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00206  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00207  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00208  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00209  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00210  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00211  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00212  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00213  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00214  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00215  * DAMAGE.
00216  * 
00217  * ====================================================================
00218  * 
00219  * This software consists of voluntary contributions made by Vovida
00220  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00221  * Inc.  For more information on Vovida Networks, Inc., please see
00222  * <http://www.vovida.org/>.
00223  *
00224  */