1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/src/XPCLog.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=99: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/* Debug Logging support. */ 1.11 + 1.12 +#ifndef xpclog_h___ 1.13 +#define xpclog_h___ 1.14 + 1.15 +#include "prlog.h" 1.16 + 1.17 +/* 1.18 + * This uses prlog.h See prlog.h for environment settings for output. 1.19 + * The module name used here is 'xpclog'. These environment settings 1.20 + * should work... 1.21 + * 1.22 + * SET NSPR_LOG_MODULES=xpclog:5 1.23 + * SET NSPR_LOG_FILE=logfile.txt 1.24 + * 1.25 + * usage: 1.26 + * XPC_LOG_ERROR(("my comment number %d", 5)) // note the double parens 1.27 + * 1.28 + */ 1.29 + 1.30 +#ifdef DEBUG 1.31 +#define XPC_LOG_INTERNAL(number,_args) \ 1.32 + do{if (XPC_Log_Check(number)){XPC_Log_print _args;}}while (0) 1.33 + 1.34 +#define XPC_LOG_ALWAYS(_args) XPC_LOG_INTERNAL(1,_args) 1.35 +#define XPC_LOG_ERROR(_args) XPC_LOG_INTERNAL(2,_args) 1.36 +#define XPC_LOG_WARNING(_args) XPC_LOG_INTERNAL(3,_args) 1.37 +#define XPC_LOG_DEBUG(_args) XPC_LOG_INTERNAL(4,_args) 1.38 +#define XPC_LOG_FLUSH() PR_LogFlush() 1.39 +#define XPC_LOG_INDENT() XPC_Log_Indent() 1.40 +#define XPC_LOG_OUTDENT() XPC_Log_Outdent() 1.41 +#define XPC_LOG_CLEAR_INDENT() XPC_Log_Clear_Indent() 1.42 +#define XPC_LOG_FINISH() XPC_Log_Finish() 1.43 + 1.44 +extern "C" { 1.45 + 1.46 +void XPC_Log_print(const char *fmt, ...); 1.47 +bool XPC_Log_Check(int i); 1.48 +void XPC_Log_Indent(); 1.49 +void XPC_Log_Outdent(); 1.50 +void XPC_Log_Clear_Indent(); 1.51 +void XPC_Log_Finish(); 1.52 + 1.53 +} // extern "C" 1.54 + 1.55 +#else 1.56 + 1.57 +#define XPC_LOG_ALWAYS(_args) ((void)0) 1.58 +#define XPC_LOG_ERROR(_args) ((void)0) 1.59 +#define XPC_LOG_WARNING(_args) ((void)0) 1.60 +#define XPC_LOG_DEBUG(_args) ((void)0) 1.61 +#define XPC_LOG_FLUSH() ((void)0) 1.62 +#define XPC_LOG_INDENT() ((void)0) 1.63 +#define XPC_LOG_OUTDENT() ((void)0) 1.64 +#define XPC_LOG_CLEAR_INDENT() ((void)0) 1.65 +#define XPC_LOG_FINISH() ((void)0) 1.66 +#endif 1.67 + 1.68 +#endif /* xpclog_h___ */