blob: 079e5af8586cc8a6669e9752b7a6b921dddb0f18 [file] [log] [blame]
<!--
Documentation/_templates/layout.html
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. The
ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Logging &mdash; NuttX latest documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/tabs.css" type="text/css" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="OS Data Structures" href="structures.html" />
<link rel="prev" title="Board IOCTL" href="13_boardctl.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> NuttX
<img src="../../_static/NuttX.png" class="logo" alt="Logo"/>
</a>
<!-- this version selector is quite ugly, should be probably replaced by something
more modern -->
<div class="version-selector">
<select onchange="javascript:location.href = this.value;">
<option value="../../../latest" selected="selected">latest</option>
<option value="../../../10.0.0" >10.0.0</option>
<option value="../../../10.0.1" >10.0.1</option>
<option value="../../../10.1.0" >10.1.0</option>
<option value="../../../10.2.0" >10.2.0</option>
<option value="../../../10.3.0" >10.3.0</option>
<option value="../../../11.0.0" >11.0.0</option>
<option value="../../../12.0.0" >12.0.0</option>
<option value="../../../12.1.0" >12.1.0</option>
<option value="../../../12.2.0" >12.2.0</option>
<option value="../../../12.2.1" >12.2.1</option>
<option value="../../../12.3.0" >12.3.0</option>
<option value="../../../12.4.0" >12.4.0</option>
<option value="../../../12.5.0" >12.5.0</option>
<option value="../../../12.5.1" >12.5.1</option>
<option value="../../../12.6.0" >12.6.0</option>
<option value="../../../12.7.0" >12.7.0</option>
<option value="../../../12.8.0" >12.8.0</option>
<option value="../../../12.9.0" >12.9.0</option>
<option value="../../../12.10.0" >12.10.0</option>
<option value="../../../12.11.0" >12.11.0</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributing/index.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../platforms/index.html">Supported Platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../components/index.html">OS Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../applications/index.html">Applications</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Userspace API</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="01_task_control.html">Task Control Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="02_task_scheduling.html">Task Scheduling Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="03_task_control.html">Task Control Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="04_message_queue.html">Named Message Queue Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="05_counting_semaphore.html">Counting Semaphore Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="06_clocks_timers.html">Clocks and Timers</a></li>
<li class="toctree-l3"><a class="reference internal" href="07_signals.html">Signal Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="08_pthread.html">Pthread Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="09_env_vars.html">Environment Variables</a></li>
<li class="toctree-l3"><a class="reference internal" href="10_filesystem.html">File System Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="11_network.html">Network Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="12_shared_memory.html">Shared Memory Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="13_boardctl.html">Board IOCTL</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Logging</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#priority-levels">Priority Levels</a></li>
<li class="toctree-l4"><a class="reference internal" href="#priority-mask">Priority mask</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="structures.html">OS Data Structures</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../os/index.html">Architecture APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../guides/index.html">Guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">NuttX</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">API Reference</a> &raquo;</li>
<li><a href="index.html">Userspace API</a> &raquo;</li>
<li>Logging</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/reference/user/13_logging.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="logging">
<h1>Logging<a class="headerlink" href="#logging" title="Permalink to this headline"></a></h1>
<p>NuttX provides the SYSLOG for application and OS logging, which can be
configured in various ways to select how these messages are displayed
(see details <a class="reference internal" href="../../components/drivers/special/syslog.html"><span class="doc">here</span></a>).</p>
<p>Applications can emit logging messages using the standard <a class="reference internal" href="#c.syslog" title="syslog"><code class="xref c c-func docutils literal notranslate"><span class="pre">syslog()</span></code></a>
interface.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The standard <code class="xref c c-func docutils literal notranslate"><span class="pre">openlog()</span></code> and <code class="xref c c-func docutils literal notranslate"><span class="pre">closelog()</span></code>
are not currently supported.</p>
</div>
<dl class="c function">
<dt id="c.syslog">
<span class="pre">void</span> <code class="sig-name descname"><span class="pre">syslog</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">priority</span></em>, <em class="property"><span class="pre">const</span></em> <span class="pre">char</span> <span class="pre">*</span><em><span class="pre">fmt</span></em>, <span class="pre">...</span><span class="sig-paren">)</span><a class="headerlink" href="#c.syslog" title="Permalink to this definition"></a><br /></dt>
<dd><p>This interface allows to send messages to SYSLOG using standard
<code class="xref c c-func docutils literal notranslate"><span class="pre">printf()</span></code> formatting.</p>
<p>Each message sent to SYSLOG is assigned a priority. Depending
on system configuration this message may or not appear in the
output.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>priority</strong> – A priority given by <code class="docutils literal notranslate"><span class="pre">LOG_*</span></code> family of
definitions.</p></li>
<li><p><strong>fmt</strong> – The format string</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="c function">
<dt id="c.vsyslog">
<span class="pre">void</span> <code class="sig-name descname"><span class="pre">vsyslog</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">priority</span></em>, <em class="property"><span class="pre">const</span></em> <span class="pre">char</span> <span class="pre">*</span><em><span class="pre">fmt</span></em>, <span class="pre">va_list</span> <em><span class="pre">ap</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.vsyslog" title="Permalink to this definition"></a><br /></dt>
<dd><p>Performs the same task as <a class="reference internal" href="#c.syslog" title="syslog"><code class="xref c c-func docutils literal notranslate"><span class="pre">syslog()</span></code></a> with the
difference that it takes a set of arguments which have been obtained
using the <code class="file docutils literal notranslate"><span class="pre">include/stdarg.h</span></code> variable argument list macros.</p>
</dd></dl>
<dl class="c function">
<dt id="c.setlogmask">
<span class="pre">int</span> <code class="sig-name descname"><span class="pre">setlogmask</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">mask</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.setlogmask" title="Permalink to this definition"></a><br /></dt>
<dd><p>Sets the logging mask which controls which messages appear on SYSLOG
output. <a class="reference internal" href="#c.setlogmask" title="setlogmask"><code class="xref c c-func docutils literal notranslate"><span class="pre">setlogmask()</span></code></a> is not a thread-safe, re-entrant function.
Concurrent use will have undefined behavior.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mask</strong> – The new mask to set.
See <a class="reference internal" href="#c.LOG_MASK" title="LOG_MASK"><code class="xref c c-macro docutils literal notranslate"><span class="pre">LOG_MASK</span></code></a> and <a class="reference internal" href="#c.LOG_UPTO" title="LOG_UPTO"><code class="xref c c-macro docutils literal notranslate"><span class="pre">LOG_UPTO</span></code></a>.
Per OpenGroup.org “If the maskpri argument is 0, the current log mask
is not modified.” In this implementation, the value zero is permitted
in order to disable all syslog levels.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The previous mask.</p>
</dd>
</dl>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Per POSIX the syslog mask should be a per-process value but in
NuttX, the scope of the mask is dependent on the nature of the build:</p>
<ul class="simple">
<li><p>Flat Build: There is one, global SYSLOG mask that controls all output.</p></li>
<li><p>Protected Build: There are two SYSLOG masks. One within the kernel
that controls only kernel output. And one in user-space that controls
only user SYSLOG output.</p></li>
<li><p>Kernel Build: The kernel build is compliant with the POSIX requirement:
There will be one mask for each user process, controlling the SYSLOG
output only form that process. There will be a separate mask
accessible only in the kernel code to control kernel SYSLOG output.</p></li>
</ul>
</div>
</dd></dl>
<div class="section" id="priority-levels">
<h2>Priority Levels<a class="headerlink" href="#priority-levels" title="Permalink to this headline"></a></h2>
<p>The following levels are defined:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 32%" />
<col style="width: 68%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Priority (macro)</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_EMERG</span></code></p></td>
<td><p>System is unusable</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_ALERT</span></code></p></td>
<td><p>Action must be taken immediately</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_CRIT</span></code></p></td>
<td><p>Critical conditions</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_ERR</span></code></p></td>
<td><p>Error conditions</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_WARNING</span></code></p></td>
<td><p>Warning conditions</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_NOTICE</span></code></p></td>
<td><p>Normal, but significant, condition</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_INFO</span></code></p></td>
<td><p>Informational message</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">LOG_DEBUG</span></code></p></td>
<td><p>Debug-level message</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="priority-mask">
<h2>Priority mask<a class="headerlink" href="#priority-mask" title="Permalink to this headline"></a></h2>
<p>The following macros can be used with <a class="reference internal" href="#c.setlogmask" title="setlogmask"><code class="xref c c-func docutils literal notranslate"><span class="pre">setlogmask()</span></code></a>:</p>
<dl class="c macro">
<dt id="c.LOG_MASK">
<code class="sig-name descname"><span class="pre">LOG_MASK</span></code><span class="sig-paren">(</span><em><span class="pre">p</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.LOG_MASK" title="Permalink to this definition"></a><br /></dt>
<dd><p>Returns the logmask corresponding priority <code class="docutils literal notranslate"><span class="pre">p</span></code></p>
</dd></dl>
<dl class="c macro">
<dt id="c.LOG_UPTO">
<code class="sig-name descname"><span class="pre">LOG_UPTO</span></code><span class="sig-paren">(</span><em><span class="pre">p</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.LOG_UPTO" title="Permalink to this definition"></a><br /></dt>
<dd><p>Returns the logmask of all SYSLOG priorities
up to and including <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
</dd></dl>
<dl class="c macro">
<dt id="c.LOG_ALL">
<code class="sig-name descname"><span class="pre">LOG_ALL</span></code><a class="headerlink" href="#c.LOG_ALL" title="Permalink to this definition"></a><br /></dt>
<dd><p>Mask corresponding to all priorities enabled</p>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="structures.html" class="btn btn-neutral float-right" title="OS Data Structures" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="13_boardctl.html" class="btn btn-neutral float-left" title="Board IOCTL" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2020, The Apache Software Foundation.
</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>