\hypertarget{eina_log_03_8c-example}{}\doxysection{eina\+\_\+log\+\_\+03.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{//gcc -\/Wall -\/o eina\_log\_03 eina\_log\_03.c `pkg-\/config -\/-\/cflags -\/-\/libs eina`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdlib.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define log(fmt, ...)                                    \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{   eina\_log\_print(EINA\_LOG\_LEVEL\_ERR, \_\_FILE\_\_, \_\_func\_\_, \_\_LINE\_\_, fmt, \#\#\_\_VA\_ARGS\_\_)}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Data Data;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{struct }\_Data}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{int} to\_stderr;}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void} print\_cb(\textcolor{keyword}{const} \mbox{\hyperlink{struct__Eina__Log__Domain}{Eina\_Log\_Domain}} *domain,}
\DoxyCodeLine{              \mbox{\hyperlink{group__Eina__Log__Group_ga5c0cd3a8463b76bb855805b70f58c7dd}{Eina\_Log\_Level}} level \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{              \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file,}
\DoxyCodeLine{              \textcolor{keyword}{const} \textcolor{keywordtype}{char} *fnc,}
\DoxyCodeLine{              \textcolor{keywordtype}{int} line,}
\DoxyCodeLine{              \textcolor{keyword}{const} \textcolor{keywordtype}{char} *fmt,}
\DoxyCodeLine{              \textcolor{keywordtype}{void} *data,}
\DoxyCodeLine{              va\_list args)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   Data *d;}
\DoxyCodeLine{   FILE *output;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str;}
\DoxyCodeLine{}
\DoxyCodeLine{   d = (Data*)data;}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (d-\/>to\_stderr)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        output = stderr;}
\DoxyCodeLine{        str = \textcolor{stringliteral}{"{}stderr"{}};}
\DoxyCodeLine{    \}}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     \{}
\DoxyCodeLine{       output = stdout;}
\DoxyCodeLine{        str = \textcolor{stringliteral}{"{}stdout"{}};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   fprintf(output, \textcolor{stringliteral}{"{}\%s:\%s:\%s (\%d) \%s: "{}},}
\DoxyCodeLine{           domain-\/>\mbox{\hyperlink{struct__Eina__Log__Domain_adac00ef51a0009e12583ca5932275f2e}{domain\_str}}, file, fnc, line, str);}
\DoxyCodeLine{   vfprintf(output, fmt, args);}
\DoxyCodeLine{   putc(\textcolor{charliteral}{'\(\backslash\)n'}, output);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void} test(Data *data, \textcolor{keywordtype}{int} i)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (i < 0)}
\DoxyCodeLine{      data-\/>to\_stderr = 0;}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{      data-\/>to\_stderr = 1;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Log__Group_gafb145e82df0f9441244832c94e87a21b}{EINA\_LOG\_INFO}}(\textcolor{stringliteral}{"{}Log message..."{}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int} main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   Data data;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Main__Group_ga81b8137665b8a4d2cb38ca50017d4c74}{eina\_init}}())}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        printf(\textcolor{stringliteral}{"{}log during the initialization of Eina\_Log module\(\backslash\)n"{}});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Log__Group_ga163f303fe131ed5c15dc5754945d2f62}{eina\_log\_print\_cb\_set}}(print\_cb, \&data);}
\DoxyCodeLine{}
\DoxyCodeLine{   test(\&data, -\/1);}
\DoxyCodeLine{   test(\&data, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_ga5bf35513199d5220341437c05696285d}{eina\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_SUCCESS;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 