mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2026-11-05 11:55:05 +00:00
210 lines
19 KiB
HTML
210 lines
19 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.18.0"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>libaaruformat: include/log.h Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<script type="text/javascript" src="codefolding.js"></script>
|
|
<script type="text/javascript" src="clipboard.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript" src="cookie.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">libaaruformat<span id="projectnumber"> 1.0</span>
|
|
</div>
|
|
<div id="projectbrief">Aaru Data Preservation Suite - Format Library</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.18.0 -->
|
|
<script type="text/javascript">
|
|
let searchBox = new SearchBox("searchBox", "search/",'.html');
|
|
</script>
|
|
<script type="text/javascript">
|
|
document.addEventListener('DOMContentLoaded', codefold.init);
|
|
</script>
|
|
<script type="application/json" id="doxygen-config">
|
|
{
|
|
"relPath": "",
|
|
"generateTreeView": true,
|
|
"searchEngine": true,
|
|
"serverBasedSearch": false,
|
|
"disableIndex": false,
|
|
"dynamicMenus": true,
|
|
"fullSidebar": false
|
|
}
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<div id="main-nav-mobile">
|
|
<div class="sm sm-dox"><input id="main-menu-state" type="checkbox"/>
|
|
<label class="main-menu-btn" for="main-menu-state">
|
|
<span class="main-menu-btn-icon"></span> Toggle main menu visibility</label>
|
|
<span id="searchBoxPos1"></span>
|
|
</div>
|
|
</div><!-- main-nav-mobile -->
|
|
<div id="main-nav">
|
|
<ul class="sm sm-dox" id="main-menu">
|
|
<li id="searchBoxPos2">
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<span id="MSearchSelect" class="search-icon"><span class="search-icon-dropdown"></span></span>
|
|
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><div id="MSearchCloseImg" class="close-icon"></div></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div><!-- main-nav -->
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
document.addEventListener('DOMContentLoaded',() => { initNavTree('log_8h_source.html','',''); });
|
|
</script>
|
|
<div id="container">
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle"><div class="title">log.h</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="log_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/*</span></div>
|
|
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="comment"> * This file is part of the Aaru Data Preservation Suite.</span></div>
|
|
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="comment"> * Copyright (c) 2019-2026 Natalia Portillo.</span></div>
|
|
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span><span class="comment"> *</span></div>
|
|
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="comment"> * This library is free software; you can redistribute it and/or modify</span></div>
|
|
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="comment"> * it under the terms of the GNU Lesser General Public License as</span></div>
|
|
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="comment"> * published by the Free Software Foundation; either version 2.1 of the</span></div>
|
|
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="comment"> * License, or (at your option) any later version.</span></div>
|
|
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="comment"> *</span></div>
|
|
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="comment"> * This library is distributed in the hope that it will be useful, but</span></div>
|
|
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
|
|
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span></div>
|
|
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="comment"> * Lesser General Public License for more details.</span></div>
|
|
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="comment"> *</span></div>
|
|
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span><span class="comment"> * You should have received a copy of the GNU Lesser General Public</span></div>
|
|
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="comment"> * License along with this library; if not, see <http://www.gnu.org/licenses/>.</span></div>
|
|
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span><span class="comment"> */</span></div>
|
|
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> </div>
|
|
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span><span class="preprocessor">#ifndef LIBAARUFORMAT_LOG_H</span></div>
|
|
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="preprocessor">#define LIBAARUFORMAT_LOG_H</span></div>
|
|
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> </div>
|
|
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="comment">/*</span></div>
|
|
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span><span class="comment"> * Internal debug logging.</span></div>
|
|
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span><span class="comment"> *</span></div>
|
|
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="comment"> * TRACE and FATAL compile to nothing unless ENABLE_TRACE / ENABLE_FATAL are defined</span></div>
|
|
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span><span class="comment"> * (CMake: -DAARU_ENABLE_LOGGING=ON). When enabled, output goes to stderr unless the</span></div>
|
|
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span><span class="comment"> * AARUFORMAT_LOG_FILE environment variable names a file to append to, and the</span></div>
|
|
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span><span class="comment"> * AARUFORMAT_LOG_LEVEL environment variable (trace, fatal, none) filters it at runtime.</span></div>
|
|
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="comment"> *</span></div>
|
|
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="comment"> * Never log key material.</span></div>
|
|
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span><span class="comment"> */</span></div>
|
|
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
|
|
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="preprocessor">#include <inttypes.h></span> <span class="comment">// PRIu64 and friends, used throughout log format strings</span></div>
|
|
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="preprocessor">#include <stdarg.h></span></div>
|
|
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor">#include <stdio.h></span></div>
|
|
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> </div>
|
|
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"><a class="line" href="log_8h.html#a3a7b26b894cfc6d4fec8ecda755fb771"> 37</a></span><span class="preprocessor">#define AARU_LOG_FATAL 0</span></div>
|
|
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="log_8h.html#a7472b2fe08f70c5d34243efd84b929b4"> 38</a></span><span class="preprocessor">#define AARU_LOG_TRACE 1</span></div>
|
|
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> </div>
|
|
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="preprocessor">#if defined(__GNUC__) || defined(__clang__)</span></div>
|
|
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span><span class="preprocessor">#define AARU_LOG_PRINTF_ATTR __attribute__((format(printf, 5, 6)))</span></div>
|
|
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="preprocessor">#if !defined(_WIN32) && !defined(__CYGWIN__)</span></div>
|
|
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span><span class="preprocessor">#define AARU_LOG_VISIBILITY_ATTR __attribute__((visibility("hidden")))</span></div>
|
|
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span><span class="preprocessor">#else</span></div>
|
|
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span><span class="preprocessor">#define AARU_LOG_VISIBILITY_ATTR</span></div>
|
|
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span><span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="preprocessor">#else</span></div>
|
|
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"><a class="line" href="log_8h.html#a89f1a14ff17f826506e4090b35ab5973"> 48</a></span><span class="preprocessor">#define AARU_LOG_PRINTF_ATTR</span></div>
|
|
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"><a class="line" href="log_8h.html#a8e29ff5d915aacea2d774cd6cf27cb30"> 49</a></span><span class="preprocessor">#define AARU_LOG_VISIBILITY_ATTR</span></div>
|
|
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span><span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> </div>
|
|
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span><span class="preprocessor">#ifdef __cplusplus</span></div>
|
|
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {</div>
|
|
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span><span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> </div>
|
|
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span><span class="keywordtype">void</span> <a class="code hl_function" href="log_8h.html#abd6a023787b7fe2bdf9caada238a73bc">aaru_log_write</a>(<span class="keywordtype">int</span> level, <span class="keyword">const</span> <span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> line, <span class="keyword">const</span> <span class="keywordtype">char</span> *func, <span class="keyword">const</span> <span class="keywordtype">char</span> *fmt,</div>
|
|
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> ...) <a class="code hl_define" href="log_8h.html#a89f1a14ff17f826506e4090b35ab5973">AARU_LOG_PRINTF_ATTR</a> <a class="code hl_define" href="log_8h.html#a8e29ff5d915aacea2d774cd6cf27cb30">AARU_LOG_VISIBILITY_ATTR</a>;</div>
|
|
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> </div>
|
|
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span><span class="comment">/* Closes any log file and forgets the configuration so the environment is read again. Used by tests. */</span></div>
|
|
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span><span class="keywordtype">void</span> <a class="code hl_function" href="log_8h.html#a9485f405205d46b9040d28aca69e6a89">aaru_log_reset</a>(<span class="keywordtype">void</span>) <a class="code hl_define" href="log_8h.html#a8e29ff5d915aacea2d774cd6cf27cb30">AARU_LOG_VISIBILITY_ATTR</a>;</div>
|
|
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> </div>
|
|
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span><span class="preprocessor">#ifdef __cplusplus</span></div>
|
|
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span>}</div>
|
|
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span><span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> </div>
|
|
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span><span class="preprocessor">#ifdef ENABLE_TRACE</span></div>
|
|
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span><span class="preprocessor">#define TRACE(fmt, ...) aaru_log_write(AARU_LOG_TRACE, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)</span></div>
|
|
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span><span class="preprocessor">#else</span></div>
|
|
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"><a class="line" href="log_8h.html#a21cc0459b78d5f2d7bd737e5aae1278a"> 69</a></span><span class="preprocessor">#define TRACE(fmt, ...) ((void)0)</span></div>
|
|
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span><span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
|
|
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span><span class="preprocessor">#ifdef ENABLE_FATAL</span></div>
|
|
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span><span class="preprocessor">#define FATAL(fmt, ...) aaru_log_write(AARU_LOG_FATAL, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)</span></div>
|
|
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span><span class="preprocessor">#else</span></div>
|
|
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"><a class="line" href="log_8h.html#a053d6037d543b84ce59308ce71d15cd1"> 75</a></span><span class="preprocessor">#define FATAL(fmt, ...) ((void)0)</span></div>
|
|
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span><span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
|
|
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span><span class="preprocessor">#endif </span><span class="comment">// LIBAARUFORMAT_LOG_H</span></div>
|
|
<div class="ttc" id="alog_8h_html_a89f1a14ff17f826506e4090b35ab5973"><div class="ttname"><a href="log_8h.html#a89f1a14ff17f826506e4090b35ab5973">AARU_LOG_PRINTF_ATTR</a></div><div class="ttdeci">#define AARU_LOG_PRINTF_ATTR</div><div class="ttdef"><b>Definition</b> <a href="#l00048">log.h:48</a></div></div>
|
|
<div class="ttc" id="alog_8h_html_a8e29ff5d915aacea2d774cd6cf27cb30"><div class="ttname"><a href="log_8h.html#a8e29ff5d915aacea2d774cd6cf27cb30">AARU_LOG_VISIBILITY_ATTR</a></div><div class="ttdeci">#define AARU_LOG_VISIBILITY_ATTR</div><div class="ttdef"><b>Definition</b> <a href="#l00049">log.h:49</a></div></div>
|
|
<div class="ttc" id="alog_8h_html_a9485f405205d46b9040d28aca69e6a89"><div class="ttname"><a href="log_8h.html#a9485f405205d46b9040d28aca69e6a89">aaru_log_reset</a></div><div class="ttdeci">void aaru_log_reset(void)</div><div class="ttdef"><b>Definition</b> <a href="log_8c_source.html#l00229">log.c:229</a></div></div>
|
|
<div class="ttc" id="alog_8h_html_abd6a023787b7fe2bdf9caada238a73bc"><div class="ttname"><a href="log_8h.html#abd6a023787b7fe2bdf9caada238a73bc">aaru_log_write</a></div><div class="ttdeci">void aaru_log_write(int level, const char *file, int line, const char *func, const char *fmt,...)</div><div class="ttdoc">Writes one log line.</div><div class="ttdef"><b>Definition</b> <a href="log_8c_source.html#l00173">log.c:173</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
</div><!-- container -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="navelem"><a href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a href="log_8h.html">log.h</a></li>
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.18.0 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|