\doxysubsection{trace.\+h}
\label{trace_8h_source}\index{trace.h@{trace.h}}
\mbox{\hyperlink{trace_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001 \textcolor{comment}{/*= -\/*-\/ c-\/basic-\/offset: 4; indent-\/tabs-\/mode: nil; -\/*-\/}}
\DoxyCodeLine{00002 \textcolor{comment}{ *}}
\DoxyCodeLine{00003 \textcolor{comment}{ * librsync -\/-\/ generate and apply network deltas}}
\DoxyCodeLine{00004 \textcolor{comment}{ *}}
\DoxyCodeLine{00005 \textcolor{comment}{ * Copyright (C) 2000, 2001, 2004 by Martin Pool <mbp@sourcefrog.net>}}
\DoxyCodeLine{00006 \textcolor{comment}{ *}}
\DoxyCodeLine{00007 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{00008 \textcolor{comment}{ * it under the terms of the GNU Lesser General Public License as published by}}
\DoxyCodeLine{00009 \textcolor{comment}{ * the Free Software Foundation; either version 2.1 of the License, or}}
\DoxyCodeLine{00010 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{00011 \textcolor{comment}{ *}}
\DoxyCodeLine{00012 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{00013 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{00014 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{00015 \textcolor{comment}{ * GNU Lesser General Public License for more details.}}
\DoxyCodeLine{00016 \textcolor{comment}{ *}}
\DoxyCodeLine{00017 \textcolor{comment}{ * You should have received a copy of the GNU Lesser General Public License}}
\DoxyCodeLine{00018 \textcolor{comment}{ * along with this program; if not, write to the Free Software}}
\DoxyCodeLine{00019 \textcolor{comment}{ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.}}
\DoxyCodeLine{00020 \textcolor{comment}{ */}}
\DoxyCodeLine{00021 \textcolor{comment}{}}
\DoxyCodeLine{00022 \textcolor{comment}{/** \(\backslash\)file trace.h}}
\DoxyCodeLine{00023 \textcolor{comment}{ * logging functions.}}
\DoxyCodeLine{00024 \textcolor{comment}{ *}}
\DoxyCodeLine{00025 \textcolor{comment}{ * trace may be turned off.}}
\DoxyCodeLine{00026 \textcolor{comment}{ *}}
\DoxyCodeLine{00027 \textcolor{comment}{ * error is always on, but you can return and continue in some way.}}
\DoxyCodeLine{00028 \textcolor{comment}{ *}}
\DoxyCodeLine{00029 \textcolor{comment}{ * fatal terminates the whole process.}}
\DoxyCodeLine{00030 \textcolor{comment}{ *}}
\DoxyCodeLine{00031 \textcolor{comment}{ * \(\backslash\)todo A function like perror that includes strerror output. Apache does this}}
\DoxyCodeLine{00032 \textcolor{comment}{ * by adding flags as well as the severity level which say whether such}}
\DoxyCodeLine{00033 \textcolor{comment}{ * information should be included. */}}
\DoxyCodeLine{00034 \textcolor{preprocessor}{\#ifndef TRACE\_H}}
\DoxyCodeLine{00035 \textcolor{preprocessor}{\#  define TRACE\_H}}
\DoxyCodeLine{00036 }
\DoxyCodeLine{00037 \textcolor{preprocessor}{\#  include <inttypes.h>}}
\DoxyCodeLine{00038 \textcolor{preprocessor}{\#  include "{}config.h"{}}}
\DoxyCodeLine{00039 }
\DoxyCodeLine{00040 \textcolor{comment}{/* Printf format patters for standard librsync types. */}}
\DoxyCodeLine{00041 \textcolor{preprocessor}{\#  define FMT\_LONG "{}\%"{}}PRIdMAX}
\DoxyCodeLine{00042 \textcolor{preprocessor}{\#  define FMT\_WEAKSUM "{}\%08"{}}PRIx32}
\DoxyCodeLine{00043 \textcolor{comment}{/* Old MSVC compilers don't support "{}\%zu"{} and have "{}\%Iu"{} instead. */}}
\DoxyCodeLine{00044 \textcolor{preprocessor}{\#  ifdef HAVE\_PRINTF\_Z}}
\DoxyCodeLine{00045 \textcolor{preprocessor}{\#    define FMT\_SIZE "{}\%zu"{}}}
\DoxyCodeLine{00046 \textcolor{preprocessor}{\#  else}}
\DoxyCodeLine{00047 \textcolor{preprocessor}{\#    define FMT\_SIZE "{}\%Iu"{}}}
\DoxyCodeLine{00048 \textcolor{preprocessor}{\#  endif}}
\DoxyCodeLine{00049 }
\DoxyCodeLine{00050 \textcolor{comment}{/* Some old compilers don't support \_\_func\_ and have \_\_FUNCTION\_\_ instead. */}}
\DoxyCodeLine{00051 \textcolor{preprocessor}{\#  ifndef HAVE\_\_\_FUNC\_\_}}
\DoxyCodeLine{00052 \textcolor{preprocessor}{\#    ifdef HAVE\_\_\_FUNCTION\_\_}}
\DoxyCodeLine{00053 \textcolor{preprocessor}{\#      define \_\_func\_\_ \_\_FUNCTION\_\_}}
\DoxyCodeLine{00054 \textcolor{preprocessor}{\#    else}}
\DoxyCodeLine{00055 \textcolor{preprocessor}{\#      define \_\_func\_\_ "{}"{}}}
\DoxyCodeLine{00056 \textcolor{preprocessor}{\#    endif}}
\DoxyCodeLine{00057 \textcolor{preprocessor}{\#  endif}}
\DoxyCodeLine{00058 }
\DoxyCodeLine{00059 \textcolor{comment}{/* Non-\/GNUC compatible compilers don't support \_\_attribute\_\_(). */}}
\DoxyCodeLine{00060 \textcolor{preprocessor}{\#  ifndef \_\_GNUC\_\_}}
\DoxyCodeLine{00061 \textcolor{preprocessor}{\#    define \_\_attribute\_\_(x)}}
\DoxyCodeLine{00062 \textcolor{preprocessor}{\#  endif}}
\DoxyCodeLine{00063 }
\DoxyCodeLine{00064 \textcolor{keywordtype}{void} rs\_log0(\textcolor{keywordtype}{int} level, \textcolor{keywordtype}{char} \textcolor{keyword}{const} *fn, \textcolor{keywordtype}{char} \textcolor{keyword}{const} *fmt, ...)}
\DoxyCodeLine{00065     \_\_attribute\_\_((format(printf, 3, 4)));}
\DoxyCodeLine{00066 \textcolor{comment}{}}
\DoxyCodeLine{00067 \textcolor{comment}{/** \(\backslash\)def rs\_trace\_enabled()}}
\DoxyCodeLine{00068 \textcolor{comment}{ * Call this before putting too much effort into generating trace messages. */}}
\DoxyCodeLine{00069 \textcolor{preprocessor}{\#  ifdef DO\_RS\_TRACE}}
\DoxyCodeLine{00070 \textcolor{preprocessor}{\#    define rs\_trace\_enabled() ((rs\_trace\_level \& RS\_LOG\_PRIMASK) >= RS\_LOG\_DEBUG)}}
\DoxyCodeLine{00071 \textcolor{preprocessor}{\#    define rs\_trace(...) rs\_log0(RS\_LOG\_DEBUG, \_\_func\_\_, \_\_VA\_ARGS\_\_)}}
\DoxyCodeLine{00072 \textcolor{preprocessor}{\#  else}}
\DoxyCodeLine{00073 \textcolor{preprocessor}{\#    define rs\_trace\_enabled() 0}}
\DoxyCodeLine{00074 \textcolor{preprocessor}{\#    define rs\_trace(...)}}
\DoxyCodeLine{00075 \textcolor{preprocessor}{\#  endif                        }\textcolor{comment}{/* !DO\_RS\_TRACE */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00076 }
\DoxyCodeLine{00077 \textcolor{preprocessor}{\#  define rs\_log(l, ...) rs\_log0((l), \_\_func\_\_, \_\_VA\_ARGS\_\_)}}
\DoxyCodeLine{00078 \textcolor{preprocessor}{\#  define rs\_warn(...) rs\_log0(RS\_LOG\_WARNING, \_\_func\_\_, \_\_VA\_ARGS\_\_)}}
\DoxyCodeLine{00079 \textcolor{preprocessor}{\#  define rs\_error(...) rs\_log0(RS\_LOG\_ERR,  \_\_func\_\_, \_\_VA\_ARGS\_\_)}}
\DoxyCodeLine{00080 \textcolor{preprocessor}{\#  define rs\_fatal(...) do \{ \(\backslash\)}}
\DoxyCodeLine{00081 \textcolor{preprocessor}{    rs\_log0(RS\_LOG\_CRIT, \_\_func\_\_, \_\_VA\_ARGS\_\_); \(\backslash\)}}
\DoxyCodeLine{00082 \textcolor{preprocessor}{    abort(); \(\backslash\)}}
\DoxyCodeLine{00083 \textcolor{preprocessor}{\} while (0)}}
\DoxyCodeLine{00084 }
\DoxyCodeLine{00085 \textcolor{keyword}{enum} \{}
\DoxyCodeLine{00086     RS\_LOG\_PRIMASK = 7,         \textcolor{comment}{/**< Mask to extract priority part. \(\backslash\)internal */}}
\DoxyCodeLine{00087     RS\_LOG\_NONAME = 8           \textcolor{comment}{/**< \(\backslash\)b Don't show function name in message. */}}
\DoxyCodeLine{00088 \};}
\DoxyCodeLine{00089 }
\DoxyCodeLine{00090 \textcolor{keyword}{extern} \textcolor{keywordtype}{int} rs\_trace\_level;}
\DoxyCodeLine{00091 }
\DoxyCodeLine{00092 \textcolor{preprocessor}{\#endif                          }\textcolor{comment}{/* !TRACE\_H */}\textcolor{preprocessor}{}}

\end{DoxyCode}
