\subsection*{Step by Step Guide}

\subsubsection*{Preparation}


\begin{DoxyEnumerate}
\item Import the logging library in your code\+:
\end{DoxyEnumerate}


\begin{DoxyCode}
\textcolor{preprocessor}{#include <\hyperlink{kdblogger_8h}{kdblogger.h}>}
\end{DoxyCode}



\begin{DoxyEnumerate}
\item Insert logging statements\+:
\end{DoxyEnumerate}


\begin{DoxyCode}
ELEKTRA\_LOG(\textcolor{stringliteral}{"Hello, %s!"}, \textcolor{stringliteral}{"🌎"});
\end{DoxyCode}


\paragraph*{Log Everything}

If Elektra should display all log messages, then please follow the steps below.


\begin{DoxyEnumerate}
\item Uncomment the line\+:
\end{DoxyEnumerate}


\begin{DoxyCode}
\textcolor{comment}{// #define NO\_FILTER}
\end{DoxyCode}


in the file {\ttfamily \hyperlink{log_8c}{src/libs/elektra/log.\+c}}.


\begin{DoxyEnumerate}
\item Optional\+: Change the debug level in {\ttfamily \hyperlink{kdblogger_8h}{src/include/kdblogger.\+h}}. For example, if you want to see debug messages too, then change the line
\end{DoxyEnumerate}


\begin{DoxyCode}
\hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba21501cbc3aa651fb5fdc0ed1e0c5c5eb}{ELEKTRA\_LOG\_LEVEL} = \hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba01618746c91d9d1090f599f604b9b832}{ELEKTRA\_LOG\_LEVEL\_INFO},
\end{DoxyCode}


to


\begin{DoxyCode}
\hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba21501cbc3aa651fb5fdc0ed1e0c5c5eb}{ELEKTRA\_LOG\_LEVEL} = \hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba24c7a4c44a8b99b978dc99806d083386}{ELEKTRA\_LOG\_LEVEL\_DEBUG},
\end{DoxyCode}


\paragraph*{File Specific Logging}

If you want to only log messages below a specific directory prefix, then please follow the steps below.


\begin{DoxyEnumerate}
\item Search for the code\+:
\end{DoxyEnumerate}


\begin{DoxyCode}
\textcolor{preprocessor}{#ifndef NO\_FILTER}
     \textcolor{comment}{// XXX Filter level …}
\textcolor{preprocessor}{#endif}
\end{DoxyCode}


in the file {\ttfamily \hyperlink{log_8c}{src/libs/elektra/log.\+c}}.


\begin{DoxyEnumerate}
\item Replace the code with something like\+:
\end{DoxyEnumerate}


\begin{DoxyCode}
\textcolor{preprocessor}{#ifndef NO\_FILTER}
     \textcolor{keywordflow}{if} (strncmp (file, \textcolor{stringliteral}{"src/postfix/"}, \textcolor{keyword}{sizeof} (\textcolor{stringliteral}{"src/postfix"}))) \textcolor{keywordflow}{goto} end;
\textcolor{preprocessor}{#endif}
\end{DoxyCode}


, where {\ttfamily src/postfix} contains all source files with logging statements that Elektra should log. For example, if you want to log everything from the {\ttfamily yamlcpp} plugin, then use the following code.


\begin{DoxyCode}
\textcolor{preprocessor}{#ifndef NO\_FILTER}
     \textcolor{keywordflow}{if} (strncmp (file, \textcolor{stringliteral}{"src/plugins/yamlcpp/"}, \textcolor{keyword}{sizeof} (\textcolor{stringliteral}{"src/plugins/yamlcpp"}))) \textcolor{keywordflow}{goto} end;
\textcolor{preprocessor}{#endif}
\end{DoxyCode}


\subsubsection*{Compilation}


\begin{DoxyEnumerate}
\item Enable the logger\+: e.\+g. run {\ttfamily cmake} with the switch {\ttfamily -\/\+D\+E\+N\+A\+B\+L\+E\+\_\+\+L\+O\+G\+G\+ER=ON}
\item Build Elektra
\end{DoxyEnumerate}

\subsection*{Log Levels}

There are four log levels (E\+R\+R\+OR is reserved for aborts within {\ttfamily E\+L\+E\+K\+T\+R\+A\+\_\+\+A\+S\+S\+E\+RT})\+:


\begin{DoxyItemize}
\item E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+W\+A\+R\+N\+I\+NG, something critical that should be shown to the user (e.\+g. A\+PI misuse), see \hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba0524fff5c46e0cf07287c473c46cc8e2}{E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+L\+E\+V\+E\+L\+\_\+\+W\+A\+R\+N\+I\+NG}
\item E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+N\+O\+T\+I\+CE, something important developers are likely interested in, see \hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba329fc1e04c797ab8e54a137b21f41baf}{E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+L\+E\+V\+E\+L\+\_\+\+N\+O\+T\+I\+CE}
\item E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+OG, standard level gives information what the code is doing without flooding the log, see \hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba01618746c91d9d1090f599f604b9b832}{E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+L\+E\+V\+E\+L\+\_\+\+I\+N\+FO}
\item E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+D\+E\+B\+UG, for less important logs, see \hyperlink{kdblogger_8h_a4096a2ccd61c6f5ad60e9015fd1bbb4ba24c7a4c44a8b99b978dc99806d083386}{E\+L\+E\+K\+T\+R\+A\+\_\+\+L\+O\+G\+\_\+\+L\+E\+V\+E\+L\+\_\+\+D\+E\+B\+UG} 
\end{DoxyItemize}