\doxysection{logging.\+h}
\label{logging_8h_source}\index{include/osmocom/core/logging.h@{include/osmocom/core/logging.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <stdarg.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{11 \textcolor{preprocessor}{\#include <osmocom/core/defs.h>}}
\DoxyCodeLine{12 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{13 }
\DoxyCodeLine{14 \textcolor{keyword}{extern} \textcolor{keyword}{struct }log\_info *osmo\_log\_info;}
\DoxyCodeLine{15 }
\DoxyCodeLine{16 \textcolor{preprocessor}{\#ifndef DEBUG}}
\DoxyCodeLine{17 \textcolor{preprocessor}{\#define DEBUG}}
\DoxyCodeLine{18 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{19 }
\DoxyCodeLine{20 \textcolor{preprocessor}{\#ifdef LIBOSMOCORE\_NO\_LOGGING}}
\DoxyCodeLine{21 \textcolor{preprocessor}{\#undef DEBUG}}
\DoxyCodeLine{22 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{23 }
\DoxyCodeLine{24 \textcolor{preprocessor}{\#ifdef DEBUG}}
\DoxyCodeLine{30 \textcolor{preprocessor}{\#define DEBUGP(ss, fmt, args...) LOGP(ss, LOGL\_DEBUG, fmt, \#\#args)}}
\DoxyCodeLine{31 \textcolor{preprocessor}{\#define DEBUGPC(ss, fmt, args...) LOGPC(ss, LOGL\_DEBUG, fmt, \#\#args)}}
\DoxyCodeLine{32 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{33 \textcolor{preprocessor}{\#define DEBUGP(xss, fmt, args...)}}
\DoxyCodeLine{34 \textcolor{preprocessor}{\#define DEBUGPC(ss, fmt, args...)}}
\DoxyCodeLine{35 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{36 }
\DoxyCodeLine{37 }
\DoxyCodeLine{38 \textcolor{keywordtype}{void} osmo\_vlogp(\textcolor{keywordtype}{int} subsys, \textcolor{keywordtype}{int} level, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line,}
\DoxyCodeLine{39                 \textcolor{keywordtype}{int} cont, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *format, va\_list ap);}
\DoxyCodeLine{40 }
\DoxyCodeLine{41 \textcolor{keywordtype}{void} logp(\textcolor{keywordtype}{int} subsys, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line, \textcolor{keywordtype}{int} cont, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *format, ...) OSMO\_DEPRECATED("{}Use DEBUGP* macros instead"{});}
\DoxyCodeLine{42 }
\DoxyCodeLine{49 \textcolor{preprocessor}{\#define LOGP(ss, level, fmt, args...) \(\backslash\)}}
\DoxyCodeLine{50 \textcolor{preprocessor}{        LOGPSRC(ss, level, NULL, 0, fmt, \#\# args)}}
\DoxyCodeLine{51 }
\DoxyCodeLine{58 \textcolor{preprocessor}{\#ifndef LIBOSMOCORE\_NO\_LOGGING}}
\DoxyCodeLine{59 \textcolor{preprocessor}{\#define LOGPC(ss, level, fmt, args...) \(\backslash\)}}
\DoxyCodeLine{60 \textcolor{preprocessor}{        do \{ \(\backslash\)}}
\DoxyCodeLine{61 \textcolor{preprocessor}{                if (!osmo\_log\_info) \{ \(\backslash\)}}
\DoxyCodeLine{62 \textcolor{preprocessor}{                        logp\_stub(\_\_FILE\_\_, \_\_LINE\_\_, 1, fmt, \#\#args);  \(\backslash\)}}
\DoxyCodeLine{63 \textcolor{preprocessor}{                        break; \(\backslash\)}}
\DoxyCodeLine{64 \textcolor{preprocessor}{                \} \(\backslash\)}}
\DoxyCodeLine{65 \textcolor{preprocessor}{                if (log\_check\_level(ss, level)) \(\backslash\)}}
\DoxyCodeLine{66 \textcolor{preprocessor}{                        logp2(ss, level, \_\_FILE\_\_, \_\_LINE\_\_, 1, fmt, \#\#args); \(\backslash\)}}
\DoxyCodeLine{67 \textcolor{preprocessor}{        \} while(0)}}
\DoxyCodeLine{68 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{69 \textcolor{preprocessor}{\#define LOGPC(ss, level, fmt, args...)}}
\DoxyCodeLine{70 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{71 }
\DoxyCodeLine{84 \textcolor{preprocessor}{\#define LOGPSRC(ss, level, caller\_file, caller\_line, fmt, args...) \(\backslash\)}}
\DoxyCodeLine{85 \textcolor{preprocessor}{        LOGPSRCC(ss, level, caller\_file, caller\_line, 0, fmt, \#\#args)}}
\DoxyCodeLine{86 }
\DoxyCodeLine{100 \textcolor{preprocessor}{\#ifndef LIBOSMOCORE\_NO\_LOGGING}}
\DoxyCodeLine{101 \textcolor{preprocessor}{\#define LOGPSRCC(ss, level, caller\_file, caller\_line, cont, fmt, args...) \(\backslash\)}}
\DoxyCodeLine{102 \textcolor{preprocessor}{        do \{ \(\backslash\)}}
\DoxyCodeLine{103 \textcolor{preprocessor}{                if (!osmo\_log\_info) \{ \(\backslash\)}}
\DoxyCodeLine{104 \textcolor{preprocessor}{                        if (caller\_file) \(\backslash\)}}
\DoxyCodeLine{105 \textcolor{preprocessor}{                                logp\_stub(caller\_file, caller\_line, cont, fmt, \#\#args); \(\backslash\)}}
\DoxyCodeLine{106 \textcolor{preprocessor}{                        else \(\backslash\)}}
\DoxyCodeLine{107 \textcolor{preprocessor}{                                logp\_stub(\_\_FILE\_\_, \_\_LINE\_\_, cont, fmt, \#\#args); \(\backslash\)}}
\DoxyCodeLine{108 \textcolor{preprocessor}{                        break; \(\backslash\)}}
\DoxyCodeLine{109 \textcolor{preprocessor}{                \} \(\backslash\)}}
\DoxyCodeLine{110 \textcolor{preprocessor}{                if (log\_check\_level(ss, level)) \{\(\backslash\)}}
\DoxyCodeLine{111 \textcolor{preprocessor}{                        if (caller\_file) \(\backslash\)}}
\DoxyCodeLine{112 \textcolor{preprocessor}{                                logp2(ss, level, caller\_file, caller\_line, cont, fmt, \#\#args); \(\backslash\)}}
\DoxyCodeLine{113 \textcolor{preprocessor}{                        else \(\backslash\)}}
\DoxyCodeLine{114 \textcolor{preprocessor}{                                logp2(ss, level, \_\_FILE\_\_, \_\_LINE\_\_, cont, fmt, \#\#args); \(\backslash\)}}
\DoxyCodeLine{115 \textcolor{preprocessor}{                \}\(\backslash\)}}
\DoxyCodeLine{116 \textcolor{preprocessor}{        \} while(0)}}
\DoxyCodeLine{117 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{118 \textcolor{preprocessor}{\#define LOGPSRCC(ss, level, caller\_file, caller\_line, cont, fmt, args...)}}
\DoxyCodeLine{119 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{120 }
\DoxyCodeLine{122 \textcolor{preprocessor}{\#define LOGL\_DEBUG      1       }}
\DoxyCodeLine{123 \textcolor{preprocessor}{\#define LOGL\_INFO       3       }}
\DoxyCodeLine{124 \textcolor{preprocessor}{\#define LOGL\_NOTICE     5       }}
\DoxyCodeLine{125 \textcolor{preprocessor}{\#define LOGL\_ERROR      7       }}
\DoxyCodeLine{126 \textcolor{preprocessor}{\#define LOGL\_FATAL      8       }}
\DoxyCodeLine{128 \textcolor{comment}{/* logging subsystems defined by the library itself */}}
\DoxyCodeLine{129 \textcolor{preprocessor}{\#define DLGLOBAL        -\/1      }}
\DoxyCodeLine{130 \textcolor{preprocessor}{\#define DLLAPD          -\/2      }}
\DoxyCodeLine{131 \textcolor{preprocessor}{\#define DLINP           -\/3      }}
\DoxyCodeLine{132 \textcolor{preprocessor}{\#define DLMUX           -\/4      }}
\DoxyCodeLine{133 \textcolor{preprocessor}{\#define DLMI            -\/5      }}
\DoxyCodeLine{134 \textcolor{preprocessor}{\#define DLMIB           -\/6      }}
\DoxyCodeLine{135 \textcolor{preprocessor}{\#define DLSMS           -\/7      }}
\DoxyCodeLine{136 \textcolor{preprocessor}{\#define DLCTRL          -\/8      }}
\DoxyCodeLine{137 \textcolor{preprocessor}{\#define DLGTP           -\/9      }}
\DoxyCodeLine{138 \textcolor{preprocessor}{\#define DLSTATS         -\/10     }}
\DoxyCodeLine{139 \textcolor{preprocessor}{\#define DLGSUP          -\/11     }}
\DoxyCodeLine{140 \textcolor{preprocessor}{\#define DLOAP           -\/12     }}
\DoxyCodeLine{141 \textcolor{preprocessor}{\#define DLSS7           -\/13     }}
\DoxyCodeLine{142 \textcolor{preprocessor}{\#define DLSCCP          -\/14     }}
\DoxyCodeLine{143 \textcolor{preprocessor}{\#define DLSUA           -\/15     }}
\DoxyCodeLine{144 \textcolor{preprocessor}{\#define DLM3UA          -\/16     }}
\DoxyCodeLine{145 \textcolor{preprocessor}{\#define DLMGCP          -\/17     }}
\DoxyCodeLine{146 \textcolor{preprocessor}{\#define DLJIBUF         -\/18     }}
\DoxyCodeLine{147 \textcolor{preprocessor}{\#define DLRSPRO         -\/19     }}
\DoxyCodeLine{148 \textcolor{preprocessor}{\#define DLNS            -\/20     }}
\DoxyCodeLine{149 \textcolor{preprocessor}{\#define DLBSSGP         -\/21     }}
\DoxyCodeLine{150 \textcolor{preprocessor}{\#define DLNSDATA        -\/22     }}
\DoxyCodeLine{151 \textcolor{preprocessor}{\#define DLNSSIGNAL      -\/23     }}
\DoxyCodeLine{152 \textcolor{preprocessor}{\#define DLIUUP          -\/24     }}
\DoxyCodeLine{153 \textcolor{preprocessor}{\#define DLPFCP          -\/25     }}
\DoxyCodeLine{154 \textcolor{preprocessor}{\#define DLCSN1          -\/26     }}
\DoxyCodeLine{155 \textcolor{preprocessor}{\#define DLM2PA          -\/27     }}
\DoxyCodeLine{156 \textcolor{preprocessor}{\#define DLM2UA          -\/28     }}
\DoxyCodeLine{157 \textcolor{preprocessor}{\#define DLIO            -\/29     }}
\DoxyCodeLine{158 \textcolor{preprocessor}{\#define OSMO\_NUM\_DLIB   29      }}
\DoxyCodeLine{160 \textcolor{comment}{/* Colors that can be used in log\_info\_cat.color */}}
\DoxyCodeLine{161 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_NORMAL NULL}}
\DoxyCodeLine{162 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_RED "{}\(\backslash\)033[1;31m"{}}}
\DoxyCodeLine{163 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_GREEN "{}\(\backslash\)033[1;32m"{}}}
\DoxyCodeLine{164 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_YELLOW "{}\(\backslash\)033[1;33m"{}}}
\DoxyCodeLine{165 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_BLUE "{}\(\backslash\)033[1;34m"{}}}
\DoxyCodeLine{166 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_PURPLE "{}\(\backslash\)033[1;35m"{}}}
\DoxyCodeLine{167 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_CYAN "{}\(\backslash\)033[1;36m"{}}}
\DoxyCodeLine{168 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKRED "{}\(\backslash\)033[31m"{}}}
\DoxyCodeLine{169 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKGREEN "{}\(\backslash\)033[32m"{}}}
\DoxyCodeLine{170 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKYELLOW "{}\(\backslash\)033[33m"{}}}
\DoxyCodeLine{171 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKBLUE "{}\(\backslash\)033[34m"{}}}
\DoxyCodeLine{172 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKPURPLE "{}\(\backslash\)033[35m"{}}}
\DoxyCodeLine{173 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKCYAN "{}\(\backslash\)033[36m"{}}}
\DoxyCodeLine{174 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKGREY "{}\(\backslash\)033[1;30m"{}}}
\DoxyCodeLine{175 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_GREY "{}\(\backslash\)033[37m"{}}}
\DoxyCodeLine{176 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_BRIGHTWHITE "{}\(\backslash\)033[1;37m"{}}}
\DoxyCodeLine{177 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_END "{}\(\backslash\)033[0;m"{}}}
\DoxyCodeLine{178 }
\DoxyCodeLine{180 \textcolor{keyword}{struct }log\_category \{}
\DoxyCodeLine{181         uint8\_t loglevel;       }
\DoxyCodeLine{182         uint8\_t enabled; }
\DoxyCodeLine{183 \};}
\DoxyCodeLine{184 }
\DoxyCodeLine{186 \textcolor{keyword}{struct }log\_info\_cat \{}
\DoxyCodeLine{187         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;           }
\DoxyCodeLine{188         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *color;         }
\DoxyCodeLine{189         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *description;     }
\DoxyCodeLine{190         uint8\_t loglevel;               }
\DoxyCodeLine{191         uint8\_t enabled;         }
\DoxyCodeLine{192 \};}
\DoxyCodeLine{193 }
\DoxyCodeLine{196 \textcolor{keyword}{enum} log\_ctx\_index \{}
\DoxyCodeLine{197         LOG\_CTX\_GB\_NSVC,}
\DoxyCodeLine{198         LOG\_CTX\_GB\_BVC,}
\DoxyCodeLine{199         LOG\_CTX\_BSC\_SUBSCR,}
\DoxyCodeLine{200         LOG\_CTX\_VLR\_SUBSCR,}
\DoxyCodeLine{201         LOG\_CTX\_L1\_SAPI,}
\DoxyCodeLine{202         LOG\_CTX\_GB\_NSE,}
\DoxyCodeLine{203         \_LOG\_CTX\_COUNT}
\DoxyCodeLine{204 \};}
\DoxyCodeLine{205 }
\DoxyCodeLine{209 \textcolor{keyword}{enum} log\_filter\_index \{}
\DoxyCodeLine{210         LOG\_FLT\_ALL,}
\DoxyCodeLine{211         LOG\_FLT\_GB\_NSVC,}
\DoxyCodeLine{212         LOG\_FLT\_GB\_BVC,}
\DoxyCodeLine{213         LOG\_FLT\_BSC\_SUBSCR,}
\DoxyCodeLine{214         LOG\_FLT\_VLR\_SUBSCR,}
\DoxyCodeLine{215         LOG\_FLT\_L1\_SAPI,}
\DoxyCodeLine{216         LOG\_FLT\_GB\_NSE,}
\DoxyCodeLine{217         \_LOG\_FLT\_COUNT}
\DoxyCodeLine{218 \};}
\DoxyCodeLine{219 }
\DoxyCodeLine{221 \textcolor{preprocessor}{\#define LOG\_MAX\_CTX     \_LOG\_CTX\_COUNT}}
\DoxyCodeLine{223 \textcolor{preprocessor}{\#define LOG\_MAX\_FILTERS \_LOG\_FLT\_COUNT}}
\DoxyCodeLine{224 }
\DoxyCodeLine{226 \textcolor{keyword}{struct }log\_context \{}
\DoxyCodeLine{227         \textcolor{keywordtype}{void} *ctx[LOG\_MAX\_CTX+1];}
\DoxyCodeLine{228 \};}
\DoxyCodeLine{229 }
\DoxyCodeLine{231 \textcolor{preprocessor}{\#define LOG\_FILTER\_ALL (1<<LOG\_FLT\_ALL)}}
\DoxyCodeLine{233 \textcolor{preprocessor}{\#define GPRS\_CTX\_NSVC LOG\_CTX\_GB\_NSVC}}
\DoxyCodeLine{235 \textcolor{preprocessor}{\#define GPRS\_CTX\_BVC LOG\_CTX\_GB\_BVC}}
\DoxyCodeLine{239 \textcolor{keyword}{struct }log\_target;}
\DoxyCodeLine{240 }
\DoxyCodeLine{242 \textcolor{keyword}{typedef} \textcolor{keywordtype}{int} log\_filter(\textcolor{keyword}{const} \textcolor{keyword}{struct} log\_context *ctx,}
\DoxyCodeLine{243                        \textcolor{keyword}{struct} log\_target *target);}
\DoxyCodeLine{244 }
\DoxyCodeLine{245 \textcolor{keyword}{struct }log\_info;}
\DoxyCodeLine{246 \textcolor{keyword}{struct }vty;}
\DoxyCodeLine{247 \textcolor{keyword}{struct }gsmtap\_inst;}
\DoxyCodeLine{248 }
\DoxyCodeLine{249 \textcolor{keyword}{typedef} \textcolor{keywordtype}{void} log\_print\_filters(\textcolor{keyword}{struct} vty *vty,}
\DoxyCodeLine{250                                \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_info *info,}
\DoxyCodeLine{251                                \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_target *tgt);}
\DoxyCodeLine{252 }
\DoxyCodeLine{253 \textcolor{keyword}{typedef} \textcolor{keywordtype}{void} log\_save\_filters(\textcolor{keyword}{struct} vty *vty,}
\DoxyCodeLine{254                               \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_info *info,}
\DoxyCodeLine{255                               \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_target *tgt);}
\DoxyCodeLine{256 }
\DoxyCodeLine{258 \textcolor{keyword}{struct }log\_info \{}
\DoxyCodeLine{259         \textcolor{comment}{/* filter callback function */}}
\DoxyCodeLine{260         log\_filter *filter\_fn;}
\DoxyCodeLine{261 }
\DoxyCodeLine{263         \textcolor{keyword}{const} \textcolor{keyword}{struct }log\_info\_cat *cat;}
\DoxyCodeLine{265         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_cat;}
\DoxyCodeLine{267         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_cat\_user;}
\DoxyCodeLine{268 }
\DoxyCodeLine{270         log\_save\_filters *save\_fn;}
\DoxyCodeLine{272         log\_print\_filters *print\_fn;}
\DoxyCodeLine{273 \};}
\DoxyCodeLine{274 }
\DoxyCodeLine{276 \textcolor{keyword}{enum} log\_target\_type \{}
\DoxyCodeLine{277         LOG\_TGT\_TYPE\_VTY,       }
\DoxyCodeLine{278         LOG\_TGT\_TYPE\_SYSLOG, }
\DoxyCodeLine{279         LOG\_TGT\_TYPE\_FILE,     }
\DoxyCodeLine{280         LOG\_TGT\_TYPE\_STDERR, }
\DoxyCodeLine{281         LOG\_TGT\_TYPE\_STRRB,   }
\DoxyCodeLine{282         LOG\_TGT\_TYPE\_GSMTAP, }
\DoxyCodeLine{283         LOG\_TGT\_TYPE\_SYSTEMD,       }
\DoxyCodeLine{284 \};}
\DoxyCodeLine{285 }
\DoxyCodeLine{287 \textcolor{keyword}{enum} log\_filename\_type \{}
\DoxyCodeLine{288         LOG\_FILENAME\_NONE,}
\DoxyCodeLine{289         LOG\_FILENAME\_PATH,}
\DoxyCodeLine{290         LOG\_FILENAME\_BASENAME,}
\DoxyCodeLine{291 \};}
\DoxyCodeLine{292 }
\DoxyCodeLine{294 \textcolor{keyword}{enum} log\_filename\_pos \{}
\DoxyCodeLine{295         LOG\_FILENAME\_POS\_HEADER\_END,}
\DoxyCodeLine{296         LOG\_FILENAME\_POS\_LINE\_END,}
\DoxyCodeLine{297 \};}
\DoxyCodeLine{298 }
\DoxyCodeLine{300 \textcolor{keyword}{struct }log\_target \{}
\DoxyCodeLine{301         \textcolor{keyword}{struct }llist\_head entry;         }
\DoxyCodeLine{304         \textcolor{keywordtype}{int} filter\_map;}
\DoxyCodeLine{306         \textcolor{keywordtype}{void} *filter\_data[LOG\_MAX\_FILTERS+1];}
\DoxyCodeLine{307 }
\DoxyCodeLine{309         \textcolor{keyword}{struct }log\_category *categories;}
\DoxyCodeLine{310 }
\DoxyCodeLine{312         uint8\_t loglevel;}
\DoxyCodeLine{314         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} use\_color:1;}
\DoxyCodeLine{316         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_timestamp:1;}
\DoxyCodeLine{318         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_tid:1;}
\DoxyCodeLine{320         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_filename:1;}
\DoxyCodeLine{322         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_category:1;}
\DoxyCodeLine{324         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_ext\_timestamp:1;}
\DoxyCodeLine{325 }
\DoxyCodeLine{327         \textcolor{keyword}{enum} log\_target\_type type;}
\DoxyCodeLine{328 }
\DoxyCodeLine{329         \textcolor{keyword}{union }\{}
\DoxyCodeLine{330                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{331                         \textcolor{comment}{/* direct, blocking output via stdio */}}
\DoxyCodeLine{332                         FILE *out;}
\DoxyCodeLine{333                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *fname;}
\DoxyCodeLine{334                         \textcolor{comment}{/* indirect output via write\_queue and osmo\_select\_main() */}}
\DoxyCodeLine{335                         \textcolor{keyword}{struct }osmo\_wqueue *wqueue;}
\DoxyCodeLine{336                 \} tgt\_file;}
\DoxyCodeLine{337 }
\DoxyCodeLine{338                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{339                         \textcolor{keywordtype}{int} priority;}
\DoxyCodeLine{340                         \textcolor{keywordtype}{int} facility;}
\DoxyCodeLine{341                 \} tgt\_syslog;}
\DoxyCodeLine{342 }
\DoxyCodeLine{343                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{344                         \textcolor{keywordtype}{void} *vty;}
\DoxyCodeLine{345                 \} tgt\_vty;}
\DoxyCodeLine{346 }
\DoxyCodeLine{347                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{348                         \textcolor{keywordtype}{void} *rb;}
\DoxyCodeLine{349                 \} tgt\_rb;}
\DoxyCodeLine{350 }
\DoxyCodeLine{351                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{352                         \textcolor{keyword}{struct }gsmtap\_inst *gsmtap\_inst;}
\DoxyCodeLine{353                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *ident;}
\DoxyCodeLine{354                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *hostname;}
\DoxyCodeLine{355                 \} tgt\_gsmtap;}
\DoxyCodeLine{356 }
\DoxyCodeLine{357                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{358                         \textcolor{keywordtype}{bool} raw;}
\DoxyCodeLine{359                 \} sd\_journal;}
\DoxyCodeLine{360         \};}
\DoxyCodeLine{361 }
\DoxyCodeLine{368         void (*output) (\textcolor{keyword}{struct }log\_target *target, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level,}
\DoxyCodeLine{369                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *string);}
\DoxyCodeLine{370 }
\DoxyCodeLine{383         void (*raw\_output)(\textcolor{keyword}{struct }log\_target *target, \textcolor{keywordtype}{int} subsys,}
\DoxyCodeLine{384                            \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line,}
\DoxyCodeLine{385                            \textcolor{keywordtype}{int} cont, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *format, va\_list ap);}
\DoxyCodeLine{386 }
\DoxyCodeLine{387         \textcolor{comment}{/* Should the log level be printed? */}}
\DoxyCodeLine{388         \textcolor{keywordtype}{bool} print\_level;}
\DoxyCodeLine{389         \textcolor{comment}{/* Should we print the subsys in hex like '<000b>'? */}}
\DoxyCodeLine{390         \textcolor{keywordtype}{bool} print\_category\_hex;}
\DoxyCodeLine{391         \textcolor{comment}{/* Should we print the source file and line, and in which way? */}}
\DoxyCodeLine{392         \textcolor{keyword}{enum} log\_filename\_type print\_filename2;}
\DoxyCodeLine{393         \textcolor{comment}{/* Where on a log line to put the source file info. */}}
\DoxyCodeLine{394         \textcolor{keyword}{enum} log\_filename\_pos print\_filename\_pos;}
\DoxyCodeLine{395 \};}
\DoxyCodeLine{396 }
\DoxyCodeLine{397 \textcolor{comment}{/* use the above macros */}}
\DoxyCodeLine{398 \textcolor{keywordtype}{void} logp2(\textcolor{keywordtype}{int} subsys, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file,}
\DoxyCodeLine{399            \textcolor{keywordtype}{int} line, \textcolor{keywordtype}{int} cont, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *format, ...)}
\DoxyCodeLine{400                                 \_\_attribute\_\_ ((format (printf, 6, 7)));}
\DoxyCodeLine{401 \textcolor{keywordtype}{void} logp\_stub(const \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line, \textcolor{keywordtype}{int} cont, const \textcolor{keywordtype}{char} *format, ...);}
\DoxyCodeLine{402 \textcolor{keywordtype}{int} log\_init(const struct log\_info *inf, \textcolor{keywordtype}{void} *talloc\_ctx);}
\DoxyCodeLine{403 \textcolor{keywordtype}{void} log\_fini(\textcolor{keywordtype}{void});}
\DoxyCodeLine{404 \textcolor{keywordtype}{int} log\_check\_level(\textcolor{keywordtype}{int} subsys, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level);}
\DoxyCodeLine{405 }
\DoxyCodeLine{406 \textcolor{comment}{/* context management */}}
\DoxyCodeLine{407 \textcolor{keywordtype}{void} log\_reset\_context(\textcolor{keywordtype}{void});}
\DoxyCodeLine{408 \textcolor{keywordtype}{int} log\_set\_context(uint8\_t ctx, \textcolor{keywordtype}{void} *value);}
\DoxyCodeLine{409 }
\DoxyCodeLine{410 \textcolor{comment}{/* filter on the targets */}}
\DoxyCodeLine{411 \textcolor{keywordtype}{void} log\_set\_all\_filter(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{412 \textcolor{keywordtype}{int} log\_cache\_enable(\textcolor{keywordtype}{void});}
\DoxyCodeLine{413 \textcolor{keywordtype}{void} log\_cache\_update(\textcolor{keywordtype}{int} mapped\_subsys, uint8\_t enabled, uint8\_t level);}
\DoxyCodeLine{414 \textcolor{keywordtype}{void} log\_set\_use\_color(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{415 \textcolor{keywordtype}{void} log\_set\_print\_extended\_timestamp(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{416 \textcolor{keywordtype}{void} log\_set\_print\_timestamp(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{417 \textcolor{keywordtype}{void} log\_set\_print\_tid(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{418 \textcolor{keywordtype}{void} log\_set\_print\_filename(struct log\_target *target, \textcolor{keywordtype}{int}) OSMO\_DEPRECATED("{}Use log\_set\_print\_filename2() instead"{});}
\DoxyCodeLine{419 \textcolor{keywordtype}{void} log\_set\_print\_filename2(struct log\_target *target, enum log\_filename\_type lft);}
\DoxyCodeLine{420 \textcolor{keywordtype}{void} log\_set\_print\_filename\_pos(struct log\_target *target, enum log\_filename\_pos pos);}
\DoxyCodeLine{421 \textcolor{keywordtype}{void} log\_set\_print\_category(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{422 \textcolor{keywordtype}{void} log\_set\_print\_category\_hex(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{423 \textcolor{keywordtype}{void} log\_set\_print\_level(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{424 \textcolor{keywordtype}{void} log\_set\_log\_level(struct log\_target *target, \textcolor{keywordtype}{int} log\_level);}
\DoxyCodeLine{425 \textcolor{keywordtype}{void} log\_parse\_category\_mask(struct log\_target *target, const \textcolor{keywordtype}{char}* mask);}
\DoxyCodeLine{426 const \textcolor{keywordtype}{char}* log\_category\_name(\textcolor{keywordtype}{int} subsys);}
\DoxyCodeLine{427 \textcolor{keywordtype}{int} log\_parse\_level(const \textcolor{keywordtype}{char} *lvl) OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE;}
\DoxyCodeLine{428 const \textcolor{keywordtype}{char} *log\_level\_str(\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} lvl) OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE;}
\DoxyCodeLine{429 \textcolor{keywordtype}{int} log\_parse\_category(const \textcolor{keywordtype}{char} *category);}
\DoxyCodeLine{430 \textcolor{keywordtype}{void} log\_set\_category\_filter(struct log\_target *target, \textcolor{keywordtype}{int} category,}
\DoxyCodeLine{431                                \textcolor{keywordtype}{int} enable, \textcolor{keywordtype}{int} level);}
\DoxyCodeLine{432 }
\DoxyCodeLine{433 \textcolor{comment}{/* management of the targets */}}
\DoxyCodeLine{434 struct log\_target *log\_target\_create(\textcolor{keywordtype}{void});}
\DoxyCodeLine{435 \textcolor{keywordtype}{void} log\_target\_destroy(struct log\_target *target);}
\DoxyCodeLine{436 struct log\_target *log\_target\_create\_stderr(\textcolor{keywordtype}{void});}
\DoxyCodeLine{437 struct log\_target *log\_target\_create\_file(const \textcolor{keywordtype}{char} *fname);}
\DoxyCodeLine{438 struct log\_target *log\_target\_create\_syslog(const \textcolor{keywordtype}{char} *ident, \textcolor{keywordtype}{int} option,}
\DoxyCodeLine{439                                             \textcolor{keywordtype}{int} facility);}
\DoxyCodeLine{440 struct log\_target *log\_target\_create\_gsmtap(const \textcolor{keywordtype}{char} *host, uint16\_t port,}
\DoxyCodeLine{441                                             const \textcolor{keywordtype}{char} *ident,}
\DoxyCodeLine{442                                             \textcolor{keywordtype}{bool} ofd\_wq\_mode,}
\DoxyCodeLine{443                                             \textcolor{keywordtype}{bool} add\_sink);}
\DoxyCodeLine{444 struct log\_target *log\_target\_create\_systemd(\textcolor{keywordtype}{bool} raw);}
\DoxyCodeLine{445 \textcolor{keywordtype}{void} log\_target\_systemd\_set\_raw(struct log\_target *target, \textcolor{keywordtype}{bool} raw);}
\DoxyCodeLine{446 \textcolor{keywordtype}{int} log\_target\_file\_reopen(struct log\_target *tgt);}
\DoxyCodeLine{447 \textcolor{keywordtype}{int} log\_target\_file\_switch\_to\_stream(struct log\_target *tgt);}
\DoxyCodeLine{448 \textcolor{keywordtype}{int} log\_target\_file\_switch\_to\_wqueue(struct log\_target *tgt);}
\DoxyCodeLine{449 \textcolor{keywordtype}{int} log\_targets\_reopen(\textcolor{keywordtype}{void});}
\DoxyCodeLine{450 }
\DoxyCodeLine{451 \textcolor{keywordtype}{void} log\_add\_target(struct log\_target *target);}
\DoxyCodeLine{452 \textcolor{keywordtype}{void} log\_del\_target(struct log\_target *target);}
\DoxyCodeLine{453 }
\DoxyCodeLine{454 struct log\_target *log\_target\_find(enum log\_target\_type type, const \textcolor{keywordtype}{char} *fname);}
\DoxyCodeLine{455 }
\DoxyCodeLine{456 \textcolor{keywordtype}{void} log\_enable\_multithread(\textcolor{keywordtype}{void});}
\DoxyCodeLine{457 }
\DoxyCodeLine{458 \textcolor{keywordtype}{void} log\_tgt\_mutex\_lock\_impl(\textcolor{keywordtype}{void});}
\DoxyCodeLine{459 \textcolor{keywordtype}{void} log\_tgt\_mutex\_unlock\_impl(\textcolor{keywordtype}{void});}
\DoxyCodeLine{460 \textcolor{preprocessor}{\#define LOG\_MTX\_DEBUG 0}}
\DoxyCodeLine{461 \textcolor{preprocessor}{\#if LOG\_MTX\_DEBUG}}
\DoxyCodeLine{462 \textcolor{preprocessor}{        \#include <pthread.h>}}
\DoxyCodeLine{463 \textcolor{preprocessor}{        \#define log\_tgt\_mutex\_lock() do \{ fprintf(stderr, "{}[\%lu] \%s:\%d [\%s] lock\(\backslash\)n"{}}, pthread\_self(), \_\_FILE\_\_, \_\_LINE\_\_, \_\_func\_\_); log\_tgt\_mutex\_lock\_impl(); \} while (0)}
\DoxyCodeLine{464 \textcolor{preprocessor}{        \#define log\_tgt\_mutex\_unlock() do \{ fprintf(stderr, "{}[\%lu] \%s:\%d [\%s] unlock\(\backslash\)n"{}}, pthread\_self(), \_\_FILE\_\_, \_\_LINE\_\_, \_\_func\_\_); log\_tgt\_mutex\_unlock\_impl(); \} while (0)}
\DoxyCodeLine{465 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{466 \textcolor{preprocessor}{        \#define log\_tgt\_mutex\_lock() log\_tgt\_mutex\_lock\_impl()}}
\DoxyCodeLine{467 \textcolor{preprocessor}{        \#define log\_tgt\_mutex\_unlock() log\_tgt\_mutex\_unlock\_impl()}}
\DoxyCodeLine{468 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{469 }

\end{DoxyCode}
