\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(6bfe0ff 2016-\/04-\/26 15\+:59\+:19 +0200)@{/home/mk/tmp/lirc/lib/lirc\+\_\+log.\+c(6bfe0ff 2016-\/04-\/26 15\+:59\+:19 +0200)}}


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


{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stdarg.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$sys/stat.\+h$>$}\newline
{\ttfamily \#include $<$time.\+h$>$}\newline
{\ttfamily \#include $<$pwd.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$limits.\+h$>$}\newline
{\ttfamily \#include $<$ctype.\+h$>$}\newline
{\ttfamily \#include $<$syslog.\+h$>$}\newline
{\ttfamily \#include \char`\"{}lirc/lirc\+\_\+log.\+h\char`\"{}}\newline
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\hypertarget{lirc__log_8c_ac6afabdc09a49a433ee19d8a9486056d}{}\label{lirc__log_8c_ac6afabdc09a49a433ee19d8a9486056d} 
\#define {\bfseries min}(a,  b)~(a $<$ b ? a \+: b)
\item 
\hypertarget{lirc__log_8c_acb4847a33bbb4f1de9fcc6cd7ea1c1cb}{}\label{lirc__log_8c_acb4847a33bbb4f1de9fcc6cd7ea1c1cb} 
\#define {\bfseries H\+O\+S\+T\+N\+A\+M\+E\+\_\+\+L\+EN}~128
\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}{}\label{lirc__log_8c_af96aebf4f1b1b729d1b32ff2f00903ee} 
int {\bfseries lirc\+\_\+log\+\_\+reopen} (void)
\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_abf031435b06bf0e8a87af6b2ad58f499}{perrorf} (const char $\ast$format,...)
\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}{}\label{lirc__log_8c_a351ae709d9bb8aa371e1f7f176002c9c} 
char {\bfseries hostname} \mbox{[}H\+O\+S\+T\+N\+A\+M\+E\+\_\+\+L\+EN+1\mbox{]}
\item 
\hypertarget{lirc__log_8c_aecc09945bbec7633acb6871d53fd2260}{}\label{lirc__log_8c_aecc09945bbec7633acb6871d53fd2260} 
F\+I\+LE $\ast$ {\bfseries lf} = N\+U\+LL
\item 
\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} \hyperlink{lirc__log_8c_a1c0866a106e32b72cfa74e9d352b255d}{loglevel} = L\+I\+R\+C\+\_\+\+N\+O\+L\+OG
\item 
\hyperlink{lirc__log_8h_abffd9aa4ab9bcfacdbb9d7728037114b}{logchannel\+\_\+t} \hyperlink{lirc__log_8c_a89cb5b9dc5bd51cced8ff8b53ba3b408}{logged\+\_\+channels} = L\+O\+G\+\_\+\+A\+LL
\item 
\hypertarget{lirc__log_8c_a8d59f0b8b36622eacf0828098dc19ae4}{}\label{lirc__log_8c_a8d59f0b8b36622eacf0828098dc19ae4} 
const char $\ast$ {\bfseries syslogident} = \char`\"{}lircd-\/\char`\"{} V\+E\+R\+S\+I\+ON
\item 
\hypertarget{lirc__log_8c_abeb07ab8d2a220cc47b452df88e215c6}{}\label{lirc__log_8c_abeb07ab8d2a220cc47b452df88e215c6} 
const char $\ast$ {\bfseries logfile} = \char`\"{}syslog\char`\"{}
\item 
\hypertarget{lirc__log_8c_a2b2397fb25253f9de2014ac16c7fcf15}{}\label{lirc__log_8c_a2b2397fb25253f9de2014ac16c7fcf15} 
char {\bfseries progname} \mbox{[}128\mbox{]} = \{ \textquotesingle{}?\textquotesingle{}, \textquotesingle{}\textbackslash{}0\textquotesingle{} \}
\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}{}\label{lirc__log_8c_a30ad875dc57527c9a0037df67bab420f} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!hexdump@{hexdump}}
\index{hexdump@{hexdump}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{hexdump()}{hexdump()}}
{\footnotesize\ttfamily void hexdump (\begin{DoxyParamCaption}\item[{char $\ast$}]{prefix,  }\item[{unsigned char $\ast$}]{buf,  }\item[{int}]{len }\end{DoxyParamCaption})}

Print prefix + a hex dump of len bytes starting at $\ast$buf. 

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

\hypertarget{lirc__log_8c_ac4cddc1f18ff055b1be8755c46d830bb}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+close()}{lirc\_log\_close()}}
{\footnotesize\ttfamily int lirc\+\_\+log\+\_\+close (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}

Close the log previosly opened with \hyperlink{lirc__log_8h_ab9796198d8a199d20171fd6dcc46f215}{lirc\+\_\+log\+\_\+open()}. 

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

\hypertarget{lirc__log_8c_ad9ecabbf33ad978a5dc9a265c3b16365}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+defaultlevel()}{lirc\_log\_defaultlevel()}}
{\footnotesize\ttfamily \hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} lirc\+\_\+log\+\_\+defaultlevel (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}

Get the default level, from environment or hardcoded. 

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

\hypertarget{lirc__log_8c_a5af3dc8e52fabe122ac7ec52c6852885}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+get\+\_\+clientlog()}{lirc\_log\_get\_clientlog()}}
{\footnotesize\ttfamily int lirc\+\_\+log\+\_\+get\+\_\+clientlog (\begin{DoxyParamCaption}\item[{const char $\ast$}]{basename,  }\item[{char $\ast$}]{buffer,  }\item[{ssize\+\_\+t}]{size }\end{DoxyParamCaption})}

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 OK, otherwise -\/1 
\end{DoxyReturn}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


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

\hypertarget{lirc__log_8c_a3154a9cb342ea5f79edfe7ced8504ccd}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+open()}{lirc\_log\_open()}}
{\footnotesize\ttfamily int lirc\+\_\+log\+\_\+open (\begin{DoxyParamCaption}\item[{const char $\ast$}]{progname,  }\item[{int}]{\+\_\+nodaemon,  }\item[{\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t}}]{level }\end{DoxyParamCaption})}

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 OK, else positive error code. 
\end{DoxyReturn}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irexec_8cpp-example}{irexec.\+cpp}.\end{Desc}


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

\hypertarget{lirc__log_8c_a2eaf417e2b2dd63861d17b2c836fe1b8}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+set\+\_\+file()}{lirc\_log\_set\_file()}}
{\footnotesize\ttfamily void lirc\+\_\+log\+\_\+set\+\_\+file (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s }\end{DoxyParamCaption})}

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 84 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_a43d290e2c8b30ac1f72accfc0a22b9ba}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+setlevel()}{lirc\_log\_setlevel()}}
{\footnotesize\ttfamily int lirc\+\_\+log\+\_\+setlevel (\begin{DoxyParamCaption}\item[{\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t}}]{level }\end{DoxyParamCaption})}

Set the level. Returns 1 if ok, 0 on errors. 

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

\hypertarget{lirc__log_8c_a283ad387ae5bec5223df6d6a7589d2cb}{}\label{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{\texorpdfstring{lirc\+\_\+log\+\_\+use\+\_\+syslog()}{lirc\_log\_use\_syslog()}}
{\footnotesize\ttfamily int lirc\+\_\+log\+\_\+use\+\_\+syslog (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}

Check if log is set up to use syslog or not. 

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

\hypertarget{lirc__log_8c_aecf5f8345788bbd42f490f228fee30e0}{}\label{lirc__log_8c_aecf5f8345788bbd42f490f228fee30e0} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!logperror@{logperror}}
\index{logperror@{logperror}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{logperror()}{logperror()}}
{\footnotesize\ttfamily void logperror (\begin{DoxyParamCaption}\item[{\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t}}]{prio,  }\item[{const char $\ast$}]{fmt,  }\item[{}]{... }\end{DoxyParamCaption})}

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}


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

\hypertarget{lirc__log_8c_a29b67f5d1afc944a5c4487711d0f93b3}{}\label{lirc__log_8c_a29b67f5d1afc944a5c4487711d0f93b3} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!logprintf@{logprintf}}
\index{logprintf@{logprintf}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{logprintf()}{logprintf()}}
{\footnotesize\ttfamily void logprintf (\begin{DoxyParamCaption}\item[{\hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t}}]{prio,  }\item[{const char $\ast$}]{format\+\_\+str,  }\item[{}]{... }\end{DoxyParamCaption})}

Write a message to the log. Caller should use the log\+\_\+ macros and not call this directly. 
\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 272 of file lirc\+\_\+log.\+c.

\hypertarget{lirc__log_8c_abf031435b06bf0e8a87af6b2ad58f499}{}\label{lirc__log_8c_abf031435b06bf0e8a87af6b2ad58f499} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!perrorf@{perrorf}}
\index{perrorf@{perrorf}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{perrorf()}{perrorf()}}
{\footnotesize\ttfamily void perrorf (\begin{DoxyParamCaption}\item[{const char $\ast$}]{format,  }\item[{}]{... }\end{DoxyParamCaption})}

Adds printf-\/style arguments to perror(3). \begin{Desc}
\item[Examples\+: ]\par
\hyperlink{irsend_8cpp-example}{irsend.\+cpp}.\end{Desc}


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

\hypertarget{lirc__log_8c_a2a2913bd83563a14c1202e9aafd5900c}{}\label{lirc__log_8c_a2a2913bd83563a14c1202e9aafd5900c} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!string2loglevel@{string2loglevel}}
\index{string2loglevel@{string2loglevel}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{string2loglevel()}{string2loglevel()}}
{\footnotesize\ttfamily \hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} string2loglevel (\begin{DoxyParamCaption}\item[{const char $\ast$}]{level }\end{DoxyParamCaption})}

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 233 of file lirc\+\_\+log.\+c.



\subsection{Variable Documentation}
\hypertarget{lirc__log_8c_a89cb5b9dc5bd51cced8ff8b53ba3b408}{}\label{lirc__log_8c_a89cb5b9dc5bd51cced8ff8b53ba3b408} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!logged\+\_\+channels@{logged\+\_\+channels}}
\index{logged\+\_\+channels@{logged\+\_\+channels}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{logged\+\_\+channels}{logged\_channels}}
{\footnotesize\ttfamily \hyperlink{lirc__log_8h_abffd9aa4ab9bcfacdbb9d7728037114b}{logchannel\+\_\+t} logged\+\_\+channels = L\+O\+G\+\_\+\+A\+LL}

The actual logchannel. Should not be changed directly by external code. 

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

\hypertarget{lirc__log_8c_a1c0866a106e32b72cfa74e9d352b255d}{}\label{lirc__log_8c_a1c0866a106e32b72cfa74e9d352b255d} 
\index{lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}!loglevel@{loglevel}}
\index{loglevel@{loglevel}!lirc\+\_\+log.\+c@{lirc\+\_\+log.\+c}}
\subsubsection{\texorpdfstring{loglevel}{loglevel}}
{\footnotesize\ttfamily \hyperlink{lirc__log_8h_a24e101a095456e946efea0b971fc2ee3}{loglevel\+\_\+t} loglevel = L\+I\+R\+C\+\_\+\+N\+O\+L\+OG}

The actual loglevel. Should not be changed directly by external code. 

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

