\hypertarget{lirc__log_8c}{}\section{/home/mk/tmp/lirc/lib/lirc\+\_\+log.c File Reference}
\label{lirc__log_8c}\index{/home/mk/tmp/lirc/lib/lirc\+\_\+log.\+c(9394bcb 2015-\/08-\/20 11\+:25\+:48 +0200)@{/home/mk/tmp/lirc/lib/lirc\+\_\+log.\+c(9394bcb 2015-\/08-\/20 11\+:25\+:48 +0200)}}


Implements \hyperlink{lirc__log_8h}{lirc\+\_\+log.\+h}.  


{\ttfamily \#include $<$errno.\+h$>$}\\*
{\ttfamily \#include $<$stdarg.\+h$>$}\\*
{\ttfamily \#include $<$stdlib.\+h$>$}\\*
{\ttfamily \#include $<$stdio.\+h$>$}\\*
{\ttfamily \#include $<$string.\+h$>$}\\*
{\ttfamily \#include $<$sys/stat.\+h$>$}\\*
{\ttfamily \#include $<$time.\+h$>$}\\*
{\ttfamily \#include $<$pwd.\+h$>$}\\*
{\ttfamily \#include $<$unistd.\+h$>$}\\*
{\ttfamily \#include $<$limits.\+h$>$}\\*
{\ttfamily \#include $<$ctype.\+h$>$}\\*
{\ttfamily \#include $<$syslog.\+h$>$}\\*
{\ttfamily \#include \char`\"{}lirc/lirc\+\_\+log.\+h\char`\"{}}\\*
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\hypertarget{lirc__log_8c_acb4847a33bbb4f1de9fcc6cd7ea1c1cb}{}\#define {\bfseries H\+O\+S\+T\+N\+A\+M\+E\+\_\+\+L\+E\+N}~128\label{lirc__log_8c_acb4847a33bbb4f1de9fcc6cd7ea1c1cb}

\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{lirc__log_8c_a283ad387ae5bec5223df6d6a7589d2cb}{lirc\+\_\+log\+\_\+use\+\_\+syslog} (void)
\item 
void \hyperlink{lirc__log_8c_a2eaf417e2b2dd63861d17b2c836fe1b8}{lirc\+\_\+log\+\_\+set\+\_\+file} (const char $\ast$s)
\item 
int \hyperlink{lirc__log_8c_a3154a9cb342ea5f79edfe7ced8504ccd}{lirc\+\_\+log\+\_\+open} (const char $\ast$\+\_\+progname, int \+\_\+nodaemon, \hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} level)
\item 
int \hyperlink{lirc__log_8c_ac4cddc1f18ff055b1be8755c46d830bb}{lirc\+\_\+log\+\_\+close} (void)
\item 
\hypertarget{lirc__log_8c_af96aebf4f1b1b729d1b32ff2f00903ee}{}int {\bfseries lirc\+\_\+log\+\_\+reopen} (void)\label{lirc__log_8c_af96aebf4f1b1b729d1b32ff2f00903ee}

\item 
int \hyperlink{lirc__log_8c_a43d290e2c8b30ac1f72accfc0a22b9ba}{lirc\+\_\+log\+\_\+setlevel} (\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} level)
\item 
\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} \hyperlink{lirc__log_8c_ad9ecabbf33ad978a5dc9a265c3b16365}{lirc\+\_\+log\+\_\+defaultlevel} (void)
\item 
\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} \hyperlink{lirc__log_8c_a2a2913bd83563a14c1202e9aafd5900c}{string2loglevel} (const char $\ast$s)
\item 
void \hyperlink{lirc__log_8c_a29b67f5d1afc944a5c4487711d0f93b3}{logprintf} (\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} prio, const char $\ast$format\+\_\+str,...)
\item 
void \hyperlink{lirc__log_8c_aecf5f8345788bbd42f490f228fee30e0}{logperror} (\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} prio, const char $\ast$fmt,...)
\item 
int \hyperlink{lirc__log_8c_a5af3dc8e52fabe122ac7ec52c6852885}{lirc\+\_\+log\+\_\+get\+\_\+clientlog} (const char $\ast$basename, char $\ast$buffer, ssize\+\_\+t size)
\item 
void \hyperlink{lirc__log_8c_a30ad875dc57527c9a0037df67bab420f}{hexdump} (char $\ast$prefix, unsigned char $\ast$buf, int len)
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\hypertarget{lirc__log_8c_a351ae709d9bb8aa371e1f7f176002c9c}{}char {\bfseries hostname} \mbox{[}H\+O\+S\+T\+N\+A\+M\+E\+\_\+\+L\+E\+N+1\mbox{]}\label{lirc__log_8c_a351ae709d9bb8aa371e1f7f176002c9c}

\item 
\hypertarget{lirc__log_8c_aecc09945bbec7633acb6871d53fd2260}{}F\+I\+L\+E $\ast$ {\bfseries lf} = N\+U\+L\+L\label{lirc__log_8c_aecc09945bbec7633acb6871d53fd2260}

\item 
\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} \hyperlink{lirc__log_8c_a1c0866a106e32b72cfa74e9d352b255d}{loglevel} = L\+I\+R\+C\+\_\+\+N\+O\+L\+O\+G
\item 
\hypertarget{lirc__log_8c_a8d59f0b8b36622eacf0828098dc19ae4}{}const char $\ast$ {\bfseries syslogident} = \char`\"{}lircd-\/\char`\"{} V\+E\+R\+S\+I\+O\+N\label{lirc__log_8c_a8d59f0b8b36622eacf0828098dc19ae4}

\item 
\hypertarget{lirc__log_8c_abeb07ab8d2a220cc47b452df88e215c6}{}const char $\ast$ {\bfseries logfile} = \char`\"{}syslog\char`\"{}\label{lirc__log_8c_abeb07ab8d2a220cc47b452df88e215c6}

\item 
\hypertarget{lirc__log_8c_a2b2397fb25253f9de2014ac16c7fcf15}{}char {\bfseries progname} \mbox{[}128\mbox{]} = \{ \textquotesingle{}?\textquotesingle{}, \textquotesingle{}\textbackslash{}0\textquotesingle{} \}\label{lirc__log_8c_a2b2397fb25253f9de2014ac16c7fcf15}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Implements \hyperlink{lirc__log_8h}{lirc\+\_\+log.\+h}. 

\begin{DoxyAuthor}{Author}
Ralph Metzler, Christoph Bartelmus 
\end{DoxyAuthor}


\subsection{Function Documentation}
\hypertarget{lirc__log_8c_a30ad875dc57527c9a0037df67bab420f}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!hexdump@{hexdump}}
\index{hexdump@{hexdump}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{hexdump}]{\setlength{\rightskip}{0pt plus 5cm}void hexdump (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{prefix, }
\item[{unsigned char $\ast$}]{buf, }
\item[{int}]{len}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a30ad875dc57527c9a0037df67bab420f}
Print prefix + a hex dump of len bytes starting at $\ast$buf. 

Definition at line 348 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_ac4cddc1f18ff055b1be8755c46d830bb}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+close@{lirc\+\_\+log\+\_\+close}}
\index{lirc\+\_\+log\+\_\+close@{lirc\+\_\+log\+\_\+close}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+close}]{\setlength{\rightskip}{0pt plus 5cm}int lirc\+\_\+log\+\_\+close (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_ac4cddc1f18ff055b1be8755c46d830bb}
Close the log previosly opened with \hyperlink{lirc__log_8h_ab9796198d8a199d20171fd6dcc46f215}{lirc\+\_\+log\+\_\+open()}. 

Definition at line 120 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_ad9ecabbf33ad978a5dc9a265c3b16365}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+defaultlevel@{lirc\+\_\+log\+\_\+defaultlevel}}
\index{lirc\+\_\+log\+\_\+defaultlevel@{lirc\+\_\+log\+\_\+defaultlevel}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+defaultlevel}]{\setlength{\rightskip}{0pt plus 5cm}{\bf loglevel\+\_\+t} lirc\+\_\+log\+\_\+defaultlevel (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_ad9ecabbf33ad978a5dc9a265c3b16365}
Get the default level, from environment or hardcoded. 

Definition at line 202 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a5af3dc8e52fabe122ac7ec52c6852885}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+get\+\_\+clientlog@{lirc\+\_\+log\+\_\+get\+\_\+clientlog}}
\index{lirc\+\_\+log\+\_\+get\+\_\+clientlog@{lirc\+\_\+log\+\_\+get\+\_\+clientlog}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+get\+\_\+clientlog}]{\setlength{\rightskip}{0pt plus 5cm}int lirc\+\_\+log\+\_\+get\+\_\+clientlog (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{basename, }
\item[{char $\ast$}]{buffer, }
\item[{ssize\+\_\+t}]{size}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a5af3dc8e52fabe122ac7ec52c6852885}
Retrieve a client path for logging according to freedesktop specs.


\begin{DoxyParams}{Parameters}
{\em basename} & Basename for the logfile. \\
\hline
{\em buff} & Buffer to store result in. \\
\hline
{\em size} & Size of buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if O\+K, otherwise -\/1 
\end{DoxyReturn}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


Definition at line 311 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a3154a9cb342ea5f79edfe7ced8504ccd}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+open@{lirc\+\_\+log\+\_\+open}}
\index{lirc\+\_\+log\+\_\+open@{lirc\+\_\+log\+\_\+open}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+open}]{\setlength{\rightskip}{0pt plus 5cm}int lirc\+\_\+log\+\_\+open (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{progname, }
\item[{int}]{\+\_\+nodaemon, }
\item[{{\bf loglevel\+\_\+t}}]{level}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a3154a9cb342ea5f79edfe7ced8504ccd}
Open the log for upcoming logging


\begin{DoxyParams}{Parameters}
{\em progname} & Name of application, made available in global progname \\
\hline
{\em nodaemon} & If true, program runs in foreground and logging is on also on stdout. \\
\hline
{\em level} & The lowest level of messages to actually be logged. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if O\+K, else positive error code. 
\end{DoxyReturn}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


Definition at line 86 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a2eaf417e2b2dd63861d17b2c836fe1b8}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+set\+\_\+file@{lirc\+\_\+log\+\_\+set\+\_\+file}}
\index{lirc\+\_\+log\+\_\+set\+\_\+file@{lirc\+\_\+log\+\_\+set\+\_\+file}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+set\+\_\+file}]{\setlength{\rightskip}{0pt plus 5cm}void lirc\+\_\+log\+\_\+set\+\_\+file (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{s}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a2eaf417e2b2dd63861d17b2c836fe1b8}
Set logfile. Either a regular path or the string \textquotesingle{}syslog\textquotesingle{}; the latter does indeed use syslog(1) instead. Must be called before \hyperlink{lirc__log_8h_ab9796198d8a199d20171fd6dcc46f215}{lirc\+\_\+log\+\_\+open()}. \begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


Definition at line 75 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a43d290e2c8b30ac1f72accfc0a22b9ba}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+setlevel@{lirc\+\_\+log\+\_\+setlevel}}
\index{lirc\+\_\+log\+\_\+setlevel@{lirc\+\_\+log\+\_\+setlevel}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+setlevel}]{\setlength{\rightskip}{0pt plus 5cm}int lirc\+\_\+log\+\_\+setlevel (
\begin{DoxyParamCaption}
\item[{{\bf loglevel\+\_\+t}}]{level}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a43d290e2c8b30ac1f72accfc0a22b9ba}
Set the level. Returns 1 if ok, 0 on errors. 

Definition at line 162 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a283ad387ae5bec5223df6d6a7589d2cb}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!lirc\+\_\+log\+\_\+use\+\_\+syslog@{lirc\+\_\+log\+\_\+use\+\_\+syslog}}
\index{lirc\+\_\+log\+\_\+use\+\_\+syslog@{lirc\+\_\+log\+\_\+use\+\_\+syslog}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{lirc\+\_\+log\+\_\+use\+\_\+syslog}]{\setlength{\rightskip}{0pt plus 5cm}int lirc\+\_\+log\+\_\+use\+\_\+syslog (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a283ad387ae5bec5223df6d6a7589d2cb}
Check if log is set up to use syslog or not. 

Definition at line 69 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_aecf5f8345788bbd42f490f228fee30e0}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!logperror@{logperror}}
\index{logperror@{logperror}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{logperror}]{\setlength{\rightskip}{0pt plus 5cm}void logperror (
\begin{DoxyParamCaption}
\item[{{\bf loglevel\+\_\+t}}]{prio, }
\item[{const char $\ast$}]{fmt, }
\item[{}]{...}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_aecf5f8345788bbd42f490f228fee30e0}
Prints a description of the last error to the log. 
\begin{DoxyParams}{Parameters}
{\em prio} & Priority of log request. \\
\hline
{\em fmt} & printf-\/style format string \\
\hline
\end{DoxyParams}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


Definition at line 289 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a29b67f5d1afc944a5c4487711d0f93b3}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!logprintf@{logprintf}}
\index{logprintf@{logprintf}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{logprintf}]{\setlength{\rightskip}{0pt plus 5cm}void logprintf (
\begin{DoxyParamCaption}
\item[{{\bf loglevel\+\_\+t}}]{prio, }
\item[{const char $\ast$}]{format\+\_\+str, }
\item[{}]{...}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a29b67f5d1afc944a5c4487711d0f93b3}
Prints the log request to the log, if the priority fits. 
\begin{DoxyParams}{Parameters}
{\em prio} & Priority of log request \\
\hline
{\em format\+\_\+str} & Format string in the usual C sense. \\
\hline
{\em ...} & Additional vararg parameters. \\
\hline
\end{DoxyParams}


Definition at line 243 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a2a2913bd83563a14c1202e9aafd5900c}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!string2loglevel@{string2loglevel}}
\index{string2loglevel@{string2loglevel}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{string2loglevel}]{\setlength{\rightskip}{0pt plus 5cm}{\bf loglevel\+\_\+t} string2loglevel (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{level}
\end{DoxyParamCaption}
)}\label{lirc__log_8c_a2a2913bd83563a14c1202e9aafd5900c}
Convert a string, either a number or \textquotesingle{}info\textquotesingle{}, \textquotesingle{}trace1\textquotesingle{}, error etc. to a loglevel. \begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


Definition at line 217 of file lirc\+\_\+log.\+c.



\subsection{Variable Documentation}
\hypertarget{lirc__log_8c_a1c0866a106e32b72cfa74e9d352b255d}{}\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!loglevel@{loglevel}}
\index{loglevel@{loglevel}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection[{loglevel}]{\setlength{\rightskip}{0pt plus 5cm}{\bf loglevel\+\_\+t} loglevel = L\+I\+R\+C\+\_\+\+N\+O\+L\+O\+G}\label{lirc__log_8c_a1c0866a106e32b72cfa74e9d352b255d}
The actual loglevel. Should not be changed directly by external code. 

Definition at line 40 of file lirc\+\_\+log.\+c.

