\doxysection{Osmocom ringbuffer-\/backed logging}
\label{group__loggingrb}\index{Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}}


This adds a log which consist of an in-\/memory ring buffer.  


\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ loggingrb.\+h}
\item 
file \textbf{ loggingrb.\+c}
\begin{DoxyCompactList}\small\item\em Ringbuffer-\/backed logging support code. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
size\+\_\+t \textbf{ log\+\_\+target\+\_\+rb\+\_\+used\+\_\+size} (struct \textbf{ log\+\_\+target} const $\ast$target)
\begin{DoxyCompactList}\small\item\em Return the number of log strings in the osmo\+\_\+strrb-\/backed target. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ log\+\_\+target\+\_\+rb\+\_\+avail\+\_\+size} (struct \textbf{ log\+\_\+target} const $\ast$target)
\begin{DoxyCompactList}\small\item\em Return the capacity of the osmo\+\_\+strrb-\/backed target. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ log\+\_\+target\+\_\+rb\+\_\+get} (struct \textbf{ log\+\_\+target} const $\ast$target, size\+\_\+t logindex)
\begin{DoxyCompactList}\small\item\em Return the nth log entry in a target. \end{DoxyCompactList}\item 
struct \textbf{ log\+\_\+target} $\ast$ \textbf{ log\+\_\+target\+\_\+create\+\_\+rb} (size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Create a new logging target for ringbuffer-\/backed logging. \end{DoxyCompactList}\item 
static void \textbf{ \+\_\+rb\+\_\+output} (struct \textbf{ log\+\_\+target} $\ast$target, unsigned int \textbf{ level}, const char $\ast$log)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This adds a log which consist of an in-\/memory ring buffer. 

The idea is that the user can configure his logging in a way that critical messages get stored in the ring buffer, and that the last few critical messages can then always obtained by dumping the ring buffer. It can hence be used as a more generic version of the \char`\"{}show me the last N alarms\char`\"{} functionality. 

\doxysubsection{Function Documentation}
\mbox{\label{group__loggingrb_ga5cdd3e33d00d006eb4595e35de7460e0}} 
\index{Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}!\_rb\_output@{\_rb\_output}}
\index{\_rb\_output@{\_rb\_output}!Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}}
\doxysubsubsection{\_rb\_output()}
{\footnotesize\ttfamily static void \+\_\+rb\+\_\+output (\begin{DoxyParamCaption}\item[{struct \textbf{ log\+\_\+target} $\ast$}]{target,  }\item[{unsigned int}]{level,  }\item[{const char $\ast$}]{log }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+strrb\+\_\+add()}, \textbf{ log\+\_\+target\+::rb}, and \textbf{ log\+\_\+target\+::tgt\+\_\+rb}.



Referenced by \textbf{ log\+\_\+target\+\_\+create\+\_\+rb()}.

\mbox{\label{group__loggingrb_gabb32bbd39408f38bb623c92485feecbd}} 
\index{Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}!log\_target\_create\_rb@{log\_target\_create\_rb}}
\index{log\_target\_create\_rb@{log\_target\_create\_rb}!Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}}
\doxysubsubsection{log\_target\_create\_rb()}
{\footnotesize\ttfamily struct \textbf{ log\+\_\+target} $\ast$ log\+\_\+target\+\_\+create\+\_\+rb (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Create a new logging target for ringbuffer-\/backed logging. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em size} & The capacity (number of messages) of the logging target. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A log target in case of success, NULL in case of error. 
\end{DoxyReturn}


References \textbf{ \+\_\+rb\+\_\+output()}, \textbf{ log\+\_\+target\+\_\+create()}, \textbf{ log\+\_\+target\+\_\+destroy()}, \textbf{ LOG\+\_\+\+TGT\+\_\+\+TYPE\+\_\+\+STRRB}, \textbf{ osmo\+\_\+strrb\+\_\+create()}, \textbf{ log\+\_\+target\+::output}, \textbf{ log\+\_\+target\+::rb}, \textbf{ osmo\+\_\+strrb\+::size}, \textbf{ log\+\_\+target\+::tgt\+\_\+rb}, and \textbf{ log\+\_\+target\+::type}.

\mbox{\label{group__loggingrb_ga426cd3cb62e9f6c29ffa34624f131a7e}} 
\index{Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}!log\_target\_rb\_avail\_size@{log\_target\_rb\_avail\_size}}
\index{log\_target\_rb\_avail\_size@{log\_target\_rb\_avail\_size}!Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}}
\doxysubsubsection{log\_target\_rb\_avail\_size()}
{\footnotesize\ttfamily size\+\_\+t log\+\_\+target\+\_\+rb\+\_\+avail\+\_\+size (\begin{DoxyParamCaption}\item[{struct \textbf{ log\+\_\+target} const $\ast$}]{target }\end{DoxyParamCaption})}



Return the capacity of the osmo\+\_\+strrb-\/backed target. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em target} & The target to search.\\
\hline
\end{DoxyParams}
Note that this is the capacity (aka max number of messages). It is not the number of unused message slots. \begin{DoxyReturn}{Returns}
The number of log strings in the osmo\+\_\+strrb-\/backed target. 
\end{DoxyReturn}


References \textbf{ log\+\_\+target\+::rb}, \textbf{ osmo\+\_\+strrb\+::size}, and \textbf{ log\+\_\+target\+::tgt\+\_\+rb}.

\mbox{\label{group__loggingrb_gac5c43e52e67ec342d2a5542046219fc3}} 
\index{Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}!log\_target\_rb\_get@{log\_target\_rb\_get}}
\index{log\_target\_rb\_get@{log\_target\_rb\_get}!Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}}
\doxysubsubsection{log\_target\_rb\_get()}
{\footnotesize\ttfamily const char $\ast$ log\+\_\+target\+\_\+rb\+\_\+get (\begin{DoxyParamCaption}\item[{struct \textbf{ log\+\_\+target} const $\ast$}]{target,  }\item[{size\+\_\+t}]{logindex }\end{DoxyParamCaption})}



Return the nth log entry in a target. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em target} & The target to search. \\
\hline
\mbox{\texttt{ in}}  & {\em logindex} & The index of the log entry/error message.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to the nth message, or NULL if logindex is invalid. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+strrb\+\_\+get\+\_\+nth()}, \textbf{ log\+\_\+target\+::rb}, and \textbf{ log\+\_\+target\+::tgt\+\_\+rb}.

\mbox{\label{group__loggingrb_gac9a845e64d56b9a0304adcdc20a8edad}} 
\index{Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}!log\_target\_rb\_used\_size@{log\_target\_rb\_used\_size}}
\index{log\_target\_rb\_used\_size@{log\_target\_rb\_used\_size}!Osmocom ringbuffer-\/backed logging@{Osmocom ringbuffer-\/backed logging}}
\doxysubsubsection{log\_target\_rb\_used\_size()}
{\footnotesize\ttfamily size\+\_\+t log\+\_\+target\+\_\+rb\+\_\+used\+\_\+size (\begin{DoxyParamCaption}\item[{struct \textbf{ log\+\_\+target} const $\ast$}]{target }\end{DoxyParamCaption})}



Return the number of log strings in the osmo\+\_\+strrb-\/backed target. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em target} & The target to search.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of log strings in the osmo\+\_\+strrb-\/backed target. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+strrb\+\_\+elements()}, \textbf{ log\+\_\+target\+::rb}, and \textbf{ log\+\_\+target\+::tgt\+\_\+rb}.

