\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 DLTCAP          -\/30     }}
\DoxyCodeLine{159 \textcolor{preprocessor}{\#define OSMO\_NUM\_DLIB   30      }}
\DoxyCodeLine{161 \textcolor{comment}{/* Colors that can be used in log\_info\_cat.color */}}
\DoxyCodeLine{162 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_NORMAL NULL}}
\DoxyCodeLine{163 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_RED "{}\(\backslash\)033[1;31m"{}}}
\DoxyCodeLine{164 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_GREEN "{}\(\backslash\)033[1;32m"{}}}
\DoxyCodeLine{165 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_YELLOW "{}\(\backslash\)033[1;33m"{}}}
\DoxyCodeLine{166 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_BLUE "{}\(\backslash\)033[1;34m"{}}}
\DoxyCodeLine{167 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_PURPLE "{}\(\backslash\)033[1;35m"{}}}
\DoxyCodeLine{168 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_CYAN "{}\(\backslash\)033[1;36m"{}}}
\DoxyCodeLine{169 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKRED "{}\(\backslash\)033[31m"{}}}
\DoxyCodeLine{170 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKGREEN "{}\(\backslash\)033[32m"{}}}
\DoxyCodeLine{171 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKYELLOW "{}\(\backslash\)033[33m"{}}}
\DoxyCodeLine{172 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKBLUE "{}\(\backslash\)033[34m"{}}}
\DoxyCodeLine{173 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKPURPLE "{}\(\backslash\)033[35m"{}}}
\DoxyCodeLine{174 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKCYAN "{}\(\backslash\)033[36m"{}}}
\DoxyCodeLine{175 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_DARKGREY "{}\(\backslash\)033[1;30m"{}}}
\DoxyCodeLine{176 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_GREY "{}\(\backslash\)033[37m"{}}}
\DoxyCodeLine{177 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_BRIGHTWHITE "{}\(\backslash\)033[1;37m"{}}}
\DoxyCodeLine{178 \textcolor{preprocessor}{\#define OSMO\_LOGCOLOR\_END "{}\(\backslash\)033[0;m"{}}}
\DoxyCodeLine{179 }
\DoxyCodeLine{181 \textcolor{keyword}{struct }log\_category \{}
\DoxyCodeLine{182         uint8\_t loglevel;       }
\DoxyCodeLine{183         uint8\_t enabled; }
\DoxyCodeLine{184 \};}
\DoxyCodeLine{185 }
\DoxyCodeLine{187 \textcolor{keyword}{struct }log\_info\_cat \{}
\DoxyCodeLine{188         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;           }
\DoxyCodeLine{189         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *color;         }
\DoxyCodeLine{190         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *description;     }
\DoxyCodeLine{191         uint8\_t loglevel;               }
\DoxyCodeLine{192         uint8\_t enabled;         }
\DoxyCodeLine{193 \};}
\DoxyCodeLine{194 }
\DoxyCodeLine{197 \textcolor{keyword}{enum} log\_ctx\_index \{}
\DoxyCodeLine{198         LOG\_CTX\_GB\_NSVC,}
\DoxyCodeLine{199         LOG\_CTX\_GB\_BVC,}
\DoxyCodeLine{200         LOG\_CTX\_BSC\_SUBSCR,}
\DoxyCodeLine{201         LOG\_CTX\_VLR\_SUBSCR,}
\DoxyCodeLine{202         LOG\_CTX\_L1\_SAPI,}
\DoxyCodeLine{203         LOG\_CTX\_GB\_NSE,}
\DoxyCodeLine{204         \_LOG\_CTX\_COUNT}
\DoxyCodeLine{205 \};}
\DoxyCodeLine{206 }
\DoxyCodeLine{210 \textcolor{keyword}{enum} log\_filter\_index \{}
\DoxyCodeLine{211         LOG\_FLT\_ALL,}
\DoxyCodeLine{212         LOG\_FLT\_GB\_NSVC,}
\DoxyCodeLine{213         LOG\_FLT\_GB\_BVC,}
\DoxyCodeLine{214         LOG\_FLT\_BSC\_SUBSCR,}
\DoxyCodeLine{215         LOG\_FLT\_VLR\_SUBSCR,}
\DoxyCodeLine{216         LOG\_FLT\_L1\_SAPI,}
\DoxyCodeLine{217         LOG\_FLT\_GB\_NSE,}
\DoxyCodeLine{218         \_LOG\_FLT\_COUNT}
\DoxyCodeLine{219 \};}
\DoxyCodeLine{220 }
\DoxyCodeLine{222 \textcolor{preprocessor}{\#define LOG\_MAX\_CTX     \_LOG\_CTX\_COUNT}}
\DoxyCodeLine{224 \textcolor{preprocessor}{\#define LOG\_MAX\_FILTERS \_LOG\_FLT\_COUNT}}
\DoxyCodeLine{225 }
\DoxyCodeLine{227 \textcolor{keyword}{struct }log\_context \{}
\DoxyCodeLine{228         \textcolor{keywordtype}{void} *ctx[LOG\_MAX\_CTX+1] OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Accessing struct log\_context members directly is deprecated"{}});}
\DoxyCodeLine{229 \};}
\DoxyCodeLine{230 }
\DoxyCodeLine{232 \textcolor{preprocessor}{\#define LOG\_FILTER\_ALL (1<<LOG\_FLT\_ALL)}}
\DoxyCodeLine{234 \textcolor{preprocessor}{\#define GPRS\_CTX\_NSVC LOG\_CTX\_GB\_NSVC}}
\DoxyCodeLine{236 \textcolor{preprocessor}{\#define GPRS\_CTX\_BVC LOG\_CTX\_GB\_BVC}}
\DoxyCodeLine{240 \textcolor{keyword}{struct }log\_target;}
\DoxyCodeLine{241 }
\DoxyCodeLine{243 \textcolor{keyword}{typedef} \textcolor{keywordtype}{int} log\_filter(\textcolor{keyword}{const} \textcolor{keyword}{struct} log\_context *ctx,}
\DoxyCodeLine{244                        \textcolor{keyword}{struct} log\_target *target);}
\DoxyCodeLine{245 }
\DoxyCodeLine{246 \textcolor{keyword}{struct }log\_info;}
\DoxyCodeLine{247 \textcolor{keyword}{struct }vty;}
\DoxyCodeLine{248 \textcolor{keyword}{struct }gsmtap\_inst;}
\DoxyCodeLine{249 }
\DoxyCodeLine{250 \textcolor{keyword}{typedef} \textcolor{keywordtype}{void} log\_print\_filters(\textcolor{keyword}{struct} vty *vty,}
\DoxyCodeLine{251                                \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_info *info,}
\DoxyCodeLine{252                                \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_target *tgt);}
\DoxyCodeLine{253 }
\DoxyCodeLine{254 \textcolor{keyword}{typedef} \textcolor{keywordtype}{void} log\_save\_filters(\textcolor{keyword}{struct} vty *vty,}
\DoxyCodeLine{255                               \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_info *info,}
\DoxyCodeLine{256                               \textcolor{keyword}{const} \textcolor{keyword}{struct} log\_target *tgt);}
\DoxyCodeLine{257 }
\DoxyCodeLine{259 \textcolor{keyword}{struct }log\_info \{}
\DoxyCodeLine{260         \textcolor{comment}{/* filter callback function */}}
\DoxyCodeLine{261         log\_filter *filter\_fn;}
\DoxyCodeLine{262 }
\DoxyCodeLine{264         \textcolor{keyword}{const} \textcolor{keyword}{struct }log\_info\_cat *cat;}
\DoxyCodeLine{266         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_cat;}
\DoxyCodeLine{268         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_cat\_user;}
\DoxyCodeLine{269 }
\DoxyCodeLine{271         log\_save\_filters *save\_fn;}
\DoxyCodeLine{273         log\_print\_filters *print\_fn;}
\DoxyCodeLine{274 \};}
\DoxyCodeLine{275 }
\DoxyCodeLine{277 \textcolor{keyword}{enum} log\_target\_type \{}
\DoxyCodeLine{278         LOG\_TGT\_TYPE\_VTY,       }
\DoxyCodeLine{279         LOG\_TGT\_TYPE\_SYSLOG, }
\DoxyCodeLine{280         LOG\_TGT\_TYPE\_FILE,     }
\DoxyCodeLine{281         LOG\_TGT\_TYPE\_STDERR, }
\DoxyCodeLine{282         LOG\_TGT\_TYPE\_STRRB,   }
\DoxyCodeLine{283         LOG\_TGT\_TYPE\_GSMTAP, }
\DoxyCodeLine{284         LOG\_TGT\_TYPE\_SYSTEMD,       }
\DoxyCodeLine{285         LOG\_TGT\_TYPE\_EMSCRIPTEN, }
\DoxyCodeLine{286 \};}
\DoxyCodeLine{287 }
\DoxyCodeLine{289 \textcolor{keyword}{enum} log\_filename\_type \{}
\DoxyCodeLine{290         LOG\_FILENAME\_NONE,}
\DoxyCodeLine{291         LOG\_FILENAME\_PATH,}
\DoxyCodeLine{292         LOG\_FILENAME\_BASENAME,}
\DoxyCodeLine{293 \};}
\DoxyCodeLine{294 }
\DoxyCodeLine{296 \textcolor{keyword}{enum} log\_filename\_pos \{}
\DoxyCodeLine{297         LOG\_FILENAME\_POS\_HEADER\_END,}
\DoxyCodeLine{298         LOG\_FILENAME\_POS\_LINE\_END,}
\DoxyCodeLine{299 \};}
\DoxyCodeLine{300 }
\DoxyCodeLine{302 \textcolor{preprocessor}{\#define OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE\_LOG\_TARGET \(\backslash\)}}
\DoxyCodeLine{303 \textcolor{preprocessor}{        OSMO\_DEPRECATED\_OUTSIDE("{}Accessing struct log\_target members directly is deprecated"{}})}
\DoxyCodeLine{304 \textcolor{keyword}{struct }log\_target \{}
\DoxyCodeLine{305         \textcolor{keyword}{struct }llist\_head entry;         }
\DoxyCodeLine{308         \textcolor{keywordtype}{int} filter\_map OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE\_LOG\_TARGET;}
\DoxyCodeLine{310         \textcolor{keywordtype}{void} *filter\_data[LOG\_MAX\_FILTERS+1] OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE\_LOG\_TARGET;}
\DoxyCodeLine{311 }
\DoxyCodeLine{313         \textcolor{keyword}{struct }log\_category *categories;}
\DoxyCodeLine{314 }
\DoxyCodeLine{316         uint8\_t loglevel;}
\DoxyCodeLine{318         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} use\_color:1;}
\DoxyCodeLine{320         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_timestamp:1;}
\DoxyCodeLine{322         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_tid:1;}
\DoxyCodeLine{324         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_filename:1;}
\DoxyCodeLine{326         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_category:1;}
\DoxyCodeLine{328         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} print\_ext\_timestamp:1;}
\DoxyCodeLine{329 }
\DoxyCodeLine{331         \textcolor{keyword}{enum} log\_target\_type type;}
\DoxyCodeLine{332 }
\DoxyCodeLine{333         \textcolor{keyword}{union }\{}
\DoxyCodeLine{334                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{335                         \textcolor{comment}{/* direct, blocking output via stdio */}}
\DoxyCodeLine{336                         FILE *out;}
\DoxyCodeLine{337                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *fname;}
\DoxyCodeLine{338                         \textcolor{comment}{/* indirect output via write\_queue and osmo\_select\_main() */}}
\DoxyCodeLine{339                         \textcolor{keyword}{struct }osmo\_wqueue *wqueue;}
\DoxyCodeLine{340                 \} tgt\_file;}
\DoxyCodeLine{341 }
\DoxyCodeLine{342                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{343                         \textcolor{keywordtype}{int} priority;}
\DoxyCodeLine{344                         \textcolor{keywordtype}{int} facility;}
\DoxyCodeLine{345                 \} tgt\_syslog;}
\DoxyCodeLine{346 }
\DoxyCodeLine{347                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{348                         \textcolor{keywordtype}{void} *vty;}
\DoxyCodeLine{349                 \} tgt\_vty;}
\DoxyCodeLine{350 }
\DoxyCodeLine{351                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{352                         \textcolor{keywordtype}{void} *rb;}
\DoxyCodeLine{353                 \} tgt\_rb;}
\DoxyCodeLine{354 }
\DoxyCodeLine{355                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{356                         \textcolor{keyword}{struct }gsmtap\_inst *gsmtap\_inst;}
\DoxyCodeLine{357                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *ident;}
\DoxyCodeLine{358                         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *hostname;}
\DoxyCodeLine{359                 \} tgt\_gsmtap;}
\DoxyCodeLine{360 }
\DoxyCodeLine{361                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{362                         \textcolor{keywordtype}{bool} raw;}
\DoxyCodeLine{363                 \} sd\_journal;}
\DoxyCodeLine{364         \};}
\DoxyCodeLine{365 }
\DoxyCodeLine{372         void (*output)(\textcolor{keyword}{struct }log\_target *target, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level,}
\DoxyCodeLine{373                        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *string);}
\DoxyCodeLine{374 }
\DoxyCodeLine{387         void (*raw\_output)(\textcolor{keyword}{struct }log\_target *target, \textcolor{keywordtype}{int} subsys,}
\DoxyCodeLine{388                            \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line,}
\DoxyCodeLine{389                            \textcolor{keywordtype}{int} cont, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *format, va\_list ap);}
\DoxyCodeLine{390 }
\DoxyCodeLine{391         \textcolor{comment}{/* Should the log level be printed? */}}
\DoxyCodeLine{392         \textcolor{keywordtype}{bool} print\_level;}
\DoxyCodeLine{393         \textcolor{comment}{/* Should we print the subsys in hex like '<000b>'? */}}
\DoxyCodeLine{394         \textcolor{keywordtype}{bool} print\_category\_hex;}
\DoxyCodeLine{395         \textcolor{comment}{/* Should we print the source file and line, and in which way? */}}
\DoxyCodeLine{396         \textcolor{keyword}{enum} log\_filename\_type print\_filename2;}
\DoxyCodeLine{397         \textcolor{comment}{/* Where on a log line to put the source file info. */}}
\DoxyCodeLine{398         \textcolor{keyword}{enum} log\_filename\_pos print\_filename\_pos;}
\DoxyCodeLine{399 \};}
\DoxyCodeLine{400 }
\DoxyCodeLine{401 \textcolor{comment}{/* use the above macros */}}
\DoxyCodeLine{402 \textcolor{keywordtype}{void} logp2(\textcolor{keywordtype}{int} subsys, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file,}
\DoxyCodeLine{403            \textcolor{keywordtype}{int} line, \textcolor{keywordtype}{int} cont, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *format, ...)}
\DoxyCodeLine{404                                 \_\_attribute\_\_ ((format (printf, 6, 7)));}
\DoxyCodeLine{405 \textcolor{keywordtype}{void} logp\_stub(const \textcolor{keywordtype}{char} *file, \textcolor{keywordtype}{int} line, \textcolor{keywordtype}{int} cont, const \textcolor{keywordtype}{char} *format, ...);}
\DoxyCodeLine{406 \textcolor{keywordtype}{int} log\_init(const struct log\_info *inf, \textcolor{keywordtype}{void} *talloc\_ctx);}
\DoxyCodeLine{407 \textcolor{keywordtype}{void} log\_fini(\textcolor{keywordtype}{void});}
\DoxyCodeLine{408 \textcolor{keywordtype}{int} log\_check\_level(\textcolor{keywordtype}{int} subsys, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} level);}
\DoxyCodeLine{409 }
\DoxyCodeLine{410 \textcolor{comment}{/* context management */}}
\DoxyCodeLine{411 \textcolor{keywordtype}{void} log\_reset\_context(\textcolor{keywordtype}{void});}
\DoxyCodeLine{412 \textcolor{keywordtype}{int} log\_set\_context(uint8\_t ctx\_nr, \textcolor{keywordtype}{void} *value);}
\DoxyCodeLine{413 \textcolor{keywordtype}{void} *log\_get\_context(const struct log\_context *ctx, uint8\_t ctx\_nr);}
\DoxyCodeLine{414 }
\DoxyCodeLine{415 \textcolor{comment}{/* filter on the targets */}}
\DoxyCodeLine{416 \textcolor{keywordtype}{void} log\_set\_all\_filter(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{417 \textcolor{keywordtype}{bool} log\_get\_filter(const struct log\_target *target, \textcolor{keywordtype}{int} log\_filter\_index);}
\DoxyCodeLine{418 \textcolor{keywordtype}{int} log\_set\_filter(struct log\_target *target, \textcolor{keywordtype}{int} log\_filter\_index, \textcolor{keywordtype}{bool} enable);}
\DoxyCodeLine{419 \textcolor{keywordtype}{void} *log\_get\_filter\_data(const struct log\_target *target, \textcolor{keywordtype}{int} log\_filter\_index);}
\DoxyCodeLine{420 \textcolor{keywordtype}{int} log\_set\_filter\_data(struct log\_target *target, \textcolor{keywordtype}{int} log\_filter\_index, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{421 }
\DoxyCodeLine{422 \textcolor{keywordtype}{int} log\_cache\_enable(\textcolor{keywordtype}{void});}
\DoxyCodeLine{423 \textcolor{keywordtype}{void} log\_cache\_update(\textcolor{keywordtype}{int} mapped\_subsys, uint8\_t enabled, uint8\_t level);}
\DoxyCodeLine{424 \textcolor{keywordtype}{void} log\_set\_use\_color(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{425 \textcolor{keywordtype}{void} log\_set\_print\_extended\_timestamp(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{426 \textcolor{keywordtype}{void} log\_set\_print\_timestamp(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{427 \textcolor{keywordtype}{void} log\_set\_print\_tid(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{428 \textcolor{keywordtype}{void} log\_set\_print\_filename(struct log\_target *target, \textcolor{keywordtype}{int}) OSMO\_DEPRECATED("{}Use log\_set\_print\_filename2() instead"{});}
\DoxyCodeLine{429 \textcolor{keywordtype}{void} log\_set\_print\_filename2(struct log\_target *target, enum log\_filename\_type lft);}
\DoxyCodeLine{430 \textcolor{keywordtype}{void} log\_set\_print\_filename\_pos(struct log\_target *target, enum log\_filename\_pos pos);}
\DoxyCodeLine{431 \textcolor{keywordtype}{void} log\_set\_print\_category(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{432 \textcolor{keywordtype}{void} log\_set\_print\_category\_hex(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{433 \textcolor{keywordtype}{void} log\_set\_print\_level(struct log\_target *target, \textcolor{keywordtype}{int});}
\DoxyCodeLine{434 \textcolor{keywordtype}{void} log\_set\_log\_level(struct log\_target *target, \textcolor{keywordtype}{int} log\_level);}
\DoxyCodeLine{435 \textcolor{keywordtype}{void} log\_parse\_category\_mask(struct log\_target *target, const \textcolor{keywordtype}{char}* mask);}
\DoxyCodeLine{436 const \textcolor{keywordtype}{char}* log\_category\_name(\textcolor{keywordtype}{int} subsys);}
\DoxyCodeLine{437 \textcolor{keywordtype}{int} log\_parse\_level(const \textcolor{keywordtype}{char} *lvl) OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE;}
\DoxyCodeLine{438 const \textcolor{keywordtype}{char} *log\_level\_str(\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} lvl) OSMO\_DEPRECATED\_OUTSIDE\_LIBOSMOCORE;}
\DoxyCodeLine{439 \textcolor{keywordtype}{int} log\_parse\_category(const \textcolor{keywordtype}{char} *category);}
\DoxyCodeLine{440 \textcolor{keywordtype}{void} log\_set\_category\_filter(struct log\_target *target, \textcolor{keywordtype}{int} category,}
\DoxyCodeLine{441                                \textcolor{keywordtype}{int} enable, \textcolor{keywordtype}{int} level);}
\DoxyCodeLine{442 }
\DoxyCodeLine{443 \textcolor{comment}{/* management of the targets */}}
\DoxyCodeLine{444 struct log\_target *log\_target\_create(\textcolor{keywordtype}{void});}
\DoxyCodeLine{445 \textcolor{keywordtype}{void} log\_target\_destroy(struct log\_target *target);}
\DoxyCodeLine{446 struct log\_target *log\_target\_create\_stderr(\textcolor{keywordtype}{void});}
\DoxyCodeLine{447 struct log\_target *log\_target\_create\_file(const \textcolor{keywordtype}{char} *fname);}
\DoxyCodeLine{448 struct log\_target *log\_target\_create\_syslog(const \textcolor{keywordtype}{char} *ident, \textcolor{keywordtype}{int} option,}
\DoxyCodeLine{449                                             \textcolor{keywordtype}{int} facility);}
\DoxyCodeLine{450 struct log\_target *log\_target\_create\_gsmtap(const \textcolor{keywordtype}{char} *host, uint16\_t port,}
\DoxyCodeLine{451                                             const \textcolor{keywordtype}{char} *ident,}
\DoxyCodeLine{452                                             \textcolor{keywordtype}{bool} ofd\_wq\_mode,}
\DoxyCodeLine{453                                             \textcolor{keywordtype}{bool} add\_sink);}
\DoxyCodeLine{454 struct log\_target *log\_target\_create\_systemd(\textcolor{keywordtype}{bool} raw);}
\DoxyCodeLine{455 struct log\_target *log\_target\_create\_emscripten(\textcolor{keywordtype}{void});}
\DoxyCodeLine{456 \textcolor{keywordtype}{void} log\_target\_systemd\_set\_raw(struct log\_target *target, \textcolor{keywordtype}{bool} raw);}
\DoxyCodeLine{457 \textcolor{keywordtype}{int} log\_target\_file\_reopen(struct log\_target *tgt);}
\DoxyCodeLine{458 \textcolor{keywordtype}{int} log\_target\_file\_switch\_to\_stream(struct log\_target *tgt);}
\DoxyCodeLine{459 \textcolor{keywordtype}{int} log\_target\_file\_switch\_to\_wqueue(struct log\_target *tgt);}
\DoxyCodeLine{460 \textcolor{keywordtype}{int} log\_target\_file\_get\_nonblock(const struct log\_target *target);}
\DoxyCodeLine{461 \textcolor{keywordtype}{int} log\_target\_file\_set\_nonblock(struct log\_target *target, \textcolor{keywordtype}{int} on);}
\DoxyCodeLine{462 \textcolor{keywordtype}{int} log\_targets\_reopen(\textcolor{keywordtype}{void});}
\DoxyCodeLine{463 }
\DoxyCodeLine{464 \textcolor{keywordtype}{void} log\_add\_target(struct log\_target *target);}
\DoxyCodeLine{465 \textcolor{keywordtype}{void} log\_del\_target(struct log\_target *target);}
\DoxyCodeLine{466 }
\DoxyCodeLine{467 struct log\_target *log\_target\_find(enum log\_target\_type type, const \textcolor{keywordtype}{char} *fname);}
\DoxyCodeLine{468 }
\DoxyCodeLine{469 \textcolor{keywordtype}{void} log\_enable\_multithread(\textcolor{keywordtype}{void});}
\DoxyCodeLine{470 }
\DoxyCodeLine{471 \textcolor{keywordtype}{void} log\_tgt\_mutex\_lock\_impl(\textcolor{keywordtype}{void});}
\DoxyCodeLine{472 \textcolor{keywordtype}{void} log\_tgt\_mutex\_unlock\_impl(\textcolor{keywordtype}{void});}
\DoxyCodeLine{473 \textcolor{preprocessor}{\#define LOG\_MTX\_DEBUG 0}}
\DoxyCodeLine{474 \textcolor{preprocessor}{\#if LOG\_MTX\_DEBUG}}
\DoxyCodeLine{475 \textcolor{preprocessor}{        \#include <pthread.h>}}
\DoxyCodeLine{476 \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{477 \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{478 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{479 \textcolor{preprocessor}{        \#define log\_tgt\_mutex\_lock() log\_tgt\_mutex\_lock\_impl()}}
\DoxyCodeLine{480 \textcolor{preprocessor}{        \#define log\_tgt\_mutex\_unlock() log\_tgt\_mutex\_unlock\_impl()}}
\DoxyCodeLine{481 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{482 }

\end{DoxyCode}
