$treeview $search $mathjax $extrastylesheet
librsync
2.3.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- 00002 * 00003 * librsync -- generate and apply network deltas 00004 * 00005 * Copyright (C) 2000, 2001, 2004 by Martin Pool <mbp@sourcefrog.net> 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU Lesser General Public License as published by 00009 * the Free Software Foundation; either version 2.1 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 /** \file trace.h 00023 * logging functions. 00024 * 00025 * trace may be turned off. 00026 * 00027 * error is always on, but you can return and continue in some way. 00028 * 00029 * fatal terminates the whole process. 00030 * 00031 * \todo A function like perror that includes strerror output. Apache does this 00032 * by adding flags as well as the severity level which say whether such 00033 * information should be included. */ 00034 00035 #include <inttypes.h> 00036 /* Printf format patters for standard librsync types. */ 00037 #define FMT_LONG "%"PRIdMAX 00038 #define FMT_WEAKSUM "%08"PRIx32 00039 /* Old MSVC compilers don't support "%zu" and have "%Iu" instead. */ 00040 #ifdef HAVE_PRINTF_Z 00041 # define FMT_SIZE "%zu" 00042 #else 00043 # define FMT_SIZE "%Iu" 00044 #endif 00045 00046 /* Some old compilers don't support __func_ and have __FUNCTION__ instead. */ 00047 #ifndef HAVE___FUNC__ 00048 # ifdef HAVE___FUNCTION__ 00049 # define __func__ __FUNCTION__ 00050 # else 00051 # define __func__ "" 00052 # endif 00053 #endif 00054 00055 /* Non-GNUC compatible compilers don't support __attribute__(). */ 00056 #ifndef __GNUC__ 00057 # define __attribute__(x) 00058 #endif 00059 00060 void rs_log0(int level, char const *fn, char const *fmt, ...) 00061 __attribute__((format(printf, 3, 4))); 00062 00063 /** \def rs_trace_enabled() 00064 * Call this before putting too much effort into generating trace messages. */ 00065 #ifdef DO_RS_TRACE 00066 # define rs_trace_enabled() ((rs_trace_level & RS_LOG_PRIMASK) >= RS_LOG_DEBUG) 00067 # define rs_trace(...) rs_log0(RS_LOG_DEBUG, __func__, __VA_ARGS__) 00068 #else 00069 # define rs_trace_enabled() 0 00070 # define rs_trace(...) 00071 #endif /* !DO_RS_TRACE */ 00072 00073 #define rs_log(l, ...) rs_log0((l), __func__, __VA_ARGS__) 00074 #define rs_error(...) rs_log0(RS_LOG_ERR, __func__, __VA_ARGS__) 00075 #define rs_fatal(...) do { \ 00076 rs_log0(RS_LOG_CRIT, __func__, __VA_ARGS__); \ 00077 abort(); \ 00078 } while (0) 00079 00080 enum { 00081 RS_LOG_PRIMASK = 7, /**< Mask to extract priority part. \internal */ 00082 RS_LOG_NONAME = 8 /**< \b Don't show function name in message. */ 00083 }; 00084 00085 extern int rs_trace_level;