Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

pantheios/trace.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        pantheios/trace.h
00003  *
00004  * Purpose:     Pantheios Tracing API.
00005  *
00006  * Created:     11th November 2007
00007  * Updated:     23rd July 2010
00008  *
00009  * Home:        http://www.pantheios.org/
00010  *
00011  * Copyright (c) 2007-2010, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are
00016  * met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice,
00019  *   this list of conditions and the following disclaimer.
00020  * - Redistributions in binary form must reproduce the above copyright
00021  *   notice, this list of conditions and the following disclaimer in the
00022  *   documentation and/or other materials provided with the distribution.
00023  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
00024  *   names of any contributors may be used to endorse or promote products
00025  *   derived from this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00028  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00029  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00031  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * ////////////////////////////////////////////////////////////////////// */
00040 
00041 
00047 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_TRACE
00048 #define PANTHEIOS_INCL_PANTHEIOS_H_TRACE
00049 
00050 /* /////////////////////////////////////////////////////////////////////////
00051  * Version information
00052  */
00053 
00054 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00055 # define PANTHEIOS_VER_PANTHEIOS_H_TRACE_MAJOR      1
00056 # define PANTHEIOS_VER_PANTHEIOS_H_TRACE_MINOR      3
00057 # define PANTHEIOS_VER_PANTHEIOS_H_TRACE_REVISION   1
00058 # define PANTHEIOS_VER_PANTHEIOS_H_TRACE_EDIT       16
00059 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00060 
00061 /* /////////////////////////////////////////////////////////////////////////
00062  * Includes
00063  */
00064 
00065 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
00066 # include <pantheios/pantheios.h>
00067 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
00068 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_FILELINE
00069 # include <pantheios/fileline.h>
00070 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_FILELINE */
00071 
00072 #ifdef PANTHEIOS_USE_WIDE_STRINGS
00073 # error The Pantheios Tracing API is currently only supported in multibyte builds
00074 #endif /* PANTHEIOS_USE_WIDE_STRINGS */
00075 
00076 #include <stlsoft/stlsoft.h>
00077 
00078 /* /////////////////////////////////////////////////////////////////////////
00079  * Tracing features
00080  */
00081 
00118 #if defined(STLSOFT_CF_SUPPORTS_VARIADIC_MACROS) && \
00119     !defined(PANTHEIOS_NO_USE_VARIADIC_MACROS)
00120 # define PANTHEIOS_USES_VARIADIC_MACROS
00121 #endif /* STLSOFT_CF_SUPPORTS_VARIADIC_MACROS && !PANTHEIOS_NO_USE_VARIADIC_MACROS */
00122 
00123 
00124 
00144  /* Now define the prefix, if the user has not already done so. */
00145 # if !defined(PANTHEIOS_TRACE_PREFIX)
00146 #  define PANTHEIOS_TRACE_PREFIX                PANTHEIOS_FILELINE
00147 #  ifdef __cplusplus
00148 #   define PANTHEIOS_TRACE_LOG_PREFIX           ::pantheios::pan_slice_t(PANTHEIOS_FILELINE, STLSOFT_NUM_ELEMENTS(PANTHEIOS_FILELINE) - 1)
00149 #  else /* ? __cplusplus */
00150 #   define PANTHEIOS_TRACE_LOG_PREFIX           PANTHEIOS_FILELINE
00151 #  endif /* __cplusplus */
00152 # else /* ? PANTHEIOS_TRACE_PREFIX */
00153 #  define PANTHEIOS_TRACE_LOG_PREFIX            PANTHEIOS_TRACE_PREFIX
00154 # endif /* !PANTHEIOS_TRACE_PREFIX */
00155 
00156  /* Now define the Pantheios Tracing API */
00157 
00158 #if defined(PANTHEIOS_USES_VARIADIC_MACROS) || \
00159     defined(PANTHEIOS_DOCUMENTATION_SKIP_SECTION)
00160 
00172 # if !defined(PANTHEIOS_NO_NAMESPACE) || \
00173      defined(PANTHEIOS_DOCUMENTATION_SKIP_SECTION)
00174 #  define PANTHEIOS_TRACE_PRINTF(sev, fmt, ...) ::pantheios::pantheios_logprintf((sev), "%s" fmt, stlsoft_static_cast(PANTHEIOS_NS_QUAL(pan_char_t) const*, PANTHEIOS_TRACE_PREFIX), __VA_ARGS__)
00175 # else /* ? __cplusplus */
00176 #  define PANTHEIOS_TRACE_PRINTF(sev, fmt, ...)              pantheios_logprintf((sev), "%s" fmt, stlsoft_static_cast(PANTHEIOS_NS_QUAL(pan_char_t) const*, PANTHEIOS_TRACE_PREFIX), __VA_ARGS__)
00177 # endif /* __cplusplus */
00178 
00179 # if !defined(PANTHEIOS_NO_NAMESPACE) || \
00180      defined(PANTHEIOS_DOCUMENTATION_SKIP_SECTION)
00181 
00256 #  define PANTHEIOS_TRACE(sev, ...)             ::pantheios::log((sev), PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00257 #  if !defined(PANTHEIOS_NO_STOCK_LEVELS)
00258 #   define PANTHEIOS_TRACE_EMERGENCY(...)       ::pantheios::log(PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00259 #   define PANTHEIOS_TRACE_ALERT(...)           ::pantheios::log(PANTHEIOS_SEV_ALERT, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00260 #   define PANTHEIOS_TRACE_CRITICAL(...)        ::pantheios::log(PANTHEIOS_SEV_CRITICAL, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00261 #   define PANTHEIOS_TRACE_ERROR(...)           ::pantheios::log(PANTHEIOS_SEV_ERROR, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00262 #   define PANTHEIOS_TRACE_WARNING(...)         ::pantheios::log(PANTHEIOS_SEV_WARNING, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00263 #   define PANTHEIOS_TRACE_NOTICE(...)          ::pantheios::log(PANTHEIOS_SEV_NOTICE, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00264 #   define PANTHEIOS_TRACE_INFORMATIONAL(...)   ::pantheios::log(PANTHEIOS_SEV_INFORMATIONAL, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00265 #   define PANTHEIOS_TRACE_DEBUG(...)           ::pantheios::log(PANTHEIOS_SEV_DEBUG, PANTHEIOS_TRACE_LOG_PREFIX, __VA_ARGS__)
00266 #  endif /* !PANTHEIOS_NO_STOCK_LEVELS */
00267 # endif /* __cplusplus */
00268 
00269 #endif /* PANTHEIOS_USES_VARIADIC_MACROS */
00270 
00271 /* /////////////////////////////////////////////////////////////////////////
00272  * Inclusion
00273  */
00274 
00275 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00276 # pragma once
00277 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
00278 
00279 /* ////////////////////////////////////////////////////////////////////// */
00280 
00281 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_TRACE */
00282 
00283 /* ///////////////////////////// end of file //////////////////////////// */

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo