UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /* 00003 * Version: MPL 1.1 / GPLv3+ / LGPLv3+ 00004 * 00005 * The contents of this file are subject to the Mozilla Public License Version 00006 * 1.1 (the "License"); you may not use this file except in compliance with 00007 * the License or as specified alternatively below. You may obtain a copy of 00008 * the License at http://www.mozilla.org/MPL/ 00009 * 00010 * Software distributed under the License is distributed on an "AS IS" basis, 00011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 * for the specific language governing rights and limitations under the 00013 * License. 00014 * 00015 * Major Contributor(s): 00016 * Copyright (C) 2011 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> 00017 * (initial developer) 00018 * 00019 * All Rights Reserved. 00020 * 00021 * For minor contributions see the git repository. 00022 * 00023 * Alternatively, the contents of this file may be used under the terms of 00024 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or 00025 * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), 00026 * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable 00027 * instead of those above. 00028 */ 00029 00030 #ifndef INCLUDED_SAL_DETAIL_LOG_H 00031 #define INCLUDED_SAL_DETAIL_LOG_H 00032 00033 #include "sal/config.h" 00034 00035 #include "sal/types.h" 00036 00039 /* This header makes available replacements working in both C and C++ for the 00040 obsolete osl/diagnose.h functionality that in turn is used from both C and 00041 C++ code and the obsolete tools/debug.hxx and 00042 canvas/inc/canvas/verbosetrace.hxx functionality that uses printf-style 00043 formatting. Once that obsolete functionality is removed, this header can be 00044 removed, too. 00045 00046 This header uses variadic macros in both C (where they are officially only 00047 supported since C99) and C++ (where they are officially only supported since 00048 C++11). It appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008 00049 Express) already support them in their C and C++ dialects. See also 00050 <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>. 00051 00052 Avoid the use of other sal code in this header as much as possible, so that 00053 this code can be called from other sal code without causing endless 00054 recursion. 00055 */ 00056 00057 #if defined __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 /* 00062 Clang warns about 'sal_True && sal_True' (those being integers and not booleans) 00063 when it sees preprocessed source (-save-temps or using icecream) 00064 */ 00065 #if defined __cplusplus 00066 #define SAL_LOG_TRUE true 00067 #define SAL_LOG_FALSE false 00068 #else 00069 #define SAL_LOG_TRUE sal_True 00070 #define SAL_LOG_FALSE sal_False 00071 #endif 00072 00073 enum sal_detail_LogLevel { 00074 SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN, 00075 SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM 00076 }; 00077 00078 SAL_DLLPUBLIC void SAL_CALL sal_detail_logFormat( 00079 enum sal_detail_LogLevel level, char const * area, char const * where, 00080 char const * format, ...) 00081 /* TODO: enabling this will produce a huge amount of -Werror=format errors: */ 00082 #if defined GCC && 0 00083 __attribute__((format(printf, 4, 5))) 00084 #endif 00085 ; 00086 00087 #if defined __cplusplus 00088 } 00089 #endif 00090 00091 #define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \ 00092 do { \ 00093 if (condition) { \ 00094 sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \ 00095 } \ 00096 } while (SAL_LOG_FALSE) 00097 00098 #if defined SAL_LOG_INFO 00099 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE 00100 #else 00101 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE 00102 #endif 00103 #if defined SAL_LOG_WARN 00104 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE 00105 #else 00106 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE 00107 #endif 00108 00109 #define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": " 00110 00111 #define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \ 00112 SAL_DETAIL_LOG_FORMAT( \ 00113 SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \ 00114 area, SAL_DETAIL_WHERE, __VA_ARGS__) 00115 00116 #define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \ 00117 SAL_DETAIL_LOG_FORMAT( \ 00118 SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \ 00119 area, SAL_DETAIL_WHERE, __VA_ARGS__) 00120 00123 #endif 00124 00125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */