1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* Debug Logging support. */ 8 9 #ifndef xpclog_h___ 10 #define xpclog_h___ 11 12 #include "mozilla/Attributes.h" 13 #include "mozilla/Logging.h" 14 15 /* 16 * This uses mozilla/Logging.h. The module name used here is 'xpclog'. 17 * These environment settings should work... 18 * 19 * SET MOZ_LOG=xpclog:5 20 * SET MOZ_LOG_FILE=logfile.txt 21 * 22 * usage: 23 * XPC_LOG_ERROR(("my comment number %d", 5)) // note the double parens 24 * 25 */ 26 27 #ifdef DEBUG 28 # define XPC_LOG_INTERNAL(number, _args) \ 29 do { \ 30 if (XPC_Log_Check(number)) { \ 31 XPC_Log_print _args; \ 32 } \ 33 } while (0) 34 35 # define XPC_LOG_ALWAYS(_args) XPC_LOG_INTERNAL(1, _args) 36 # define XPC_LOG_ERROR(_args) XPC_LOG_INTERNAL(2, _args) 37 # define XPC_LOG_WARNING(_args) XPC_LOG_INTERNAL(3, _args) 38 # define XPC_LOG_DEBUG(_args) XPC_LOG_INTERNAL(4, _args) 39 # define XPC_LOG_FLUSH() PR_LogFlush() 40 # define XPC_LOG_INDENT() XPC_Log_Indent() 41 # define XPC_LOG_OUTDENT() XPC_Log_Outdent() 42 # define XPC_LOG_CLEAR_INDENT() XPC_Log_Clear_Indent() 43 # define XPC_LOG_FINISH() XPC_Log_Finish() 44 45 extern "C" { 46 47 void XPC_Log_print(const char* fmt, ...) MOZ_FORMAT_PRINTF(1, 2); 48 bool XPC_Log_Check(int i); 49 void XPC_Log_Indent(); 50 void XPC_Log_Outdent(); 51 void XPC_Log_Clear_Indent(); 52 void XPC_Log_Finish(); 53 54 } // extern "C" 55 56 #else 57 58 # define XPC_LOG_ALWAYS(_args) ((void)0) 59 # define XPC_LOG_ERROR(_args) ((void)0) 60 # define XPC_LOG_WARNING(_args) ((void)0) 61 # define XPC_LOG_DEBUG(_args) ((void)0) 62 # define XPC_LOG_FLUSH() ((void)0) 63 # define XPC_LOG_INDENT() ((void)0) 64 # define XPC_LOG_OUTDENT() ((void)0) 65 # define XPC_LOG_CLEAR_INDENT() ((void)0) 66 # define XPC_LOG_FINISH() ((void)0) 67 #endif 68 69 #endif /* xpclog_h___ */ 70