]> git.proxmox.com Git - mirror_frr.git/blobdiff - doc/developer/logging.rst
Merge pull request #10391 from gromit1811/bug_9720_ecmp_inter_area_topotest_3paths
[mirror_frr.git] / doc / developer / logging.rst
index b827afd6cc5cc9eccae1341b7caa518d128f8e68..4e6fc04206e0d78c8f8415d947ed0836df07eb29 100644 (file)
@@ -123,10 +123,14 @@ Networking data types
 
    :frrfmtout:`1.2.3.4`
 
+   ``%pI4s``: :frrfmtout:`*` — print star instead of ``0.0.0.0`` (for multicast)
+
 .. frrfmt:: %pI6 (struct in6_addr *)
 
    :frrfmtout:`fe80::1234`
 
+   ``%pI6s``: :frrfmtout:`*` — print star instead of ``::`` (for multicast)
+
 .. frrfmt:: %pEA (struct ethaddr *)
 
    :frrfmtout:`01:23:45:67:89:ab`
@@ -135,6 +139,8 @@ Networking data types
 
    :frrfmtout:`1.2.3.4` / :frrfmtout:`fe80::1234`
 
+   ``%pIAs``: — print star instead of zero address (for multicast)
+
 .. frrfmt:: %pFX (struct prefix *)
 
    :frrfmtout:`1.2.3.0/24` / :frrfmtout:`fe80::1234/64`
@@ -153,11 +159,11 @@ Networking data types
    - :c:struct:`prefix_ls`
    - :c:struct:`prefix_rd`
    - :c:struct:`prefix_ptr`
-   - :c:struct:`prefix_sg` (use :frrfmt:`%pSG4`)
+   - :c:struct:`prefix_sg` (use :frrfmt:`%pPSG4`)
    - :c:union:`prefixptr` (dereference to get :c:struct:`prefix`)
    - :c:union:`prefixconstptr` (dereference to get :c:struct:`prefix`)
 
-.. frrfmt:: %pSG4 (struct prefix_sg *)
+.. frrfmt:: %pPSG4 (struct prefix_sg *)
 
    :frrfmtout:`(*,1.2.3.4)`
 
@@ -191,6 +197,10 @@ Networking data types
 
    ``%pNHs``: :frrfmtout:`1.2.3.4 if 15` — same as :c:func:`nexthop2str()`
 
+   ``%pNHcg``: :frrfmtout:`1.2.3.4` — compact gateway only
+
+   ``%pNHci``: :frrfmtout:`eth0` — compact interface only
+
 .. frrfmt:: %pBD (struct bgp_dest *)
 
    :frrfmtout:`fe80::1234/64`
@@ -209,6 +219,144 @@ Networking data types
 
    :frrfmtout:`SOCK_STREAM`
 
+Time/interval formats
+^^^^^^^^^^^^^^^^^^^^^
+
+.. frrfmt:: %pTS (struct timespec *)
+
+.. frrfmt:: %pTV (struct timeval *)
+
+.. frrfmt:: %pTT (time_t *)
+
+   Above 3 options internally result in the same code being called, support
+   the same flags and produce equal output with one exception:  ``%pTT``
+   has no sub-second precision and the formatter will never print a
+   (nonsensical) ``.000``.
+
+   Exactly one of ``I``, ``M`` or ``R`` must immediately follow after
+   ``TS``/``TV``/``TT`` to specify whether the input is an interval, monotonic
+   timestamp or realtime timestamp:
+
+   ``%pTVI``: input is an interval, not a timestamp.  Print interval.
+
+   ``%pTVIs``: input is an interval, convert to wallclock by subtracting it
+   from current time (i.e. interval has passed **s**\ ince.)
+
+   ``%pTVIu``: input is an interval, convert to wallclock by adding it to
+   current time (i.e. **u**\ ntil interval has passed.)
+
+   ``%pTVM`` - input is a timestamp on CLOCK_MONOTONIC, convert to wallclock
+   time (by grabbing current CLOCK_MONOTONIC and CLOCK_REALTIME and doing the
+   math) and print calendaric date.
+
+   ``%pTVMs`` - input is a timestamp on CLOCK_MONOTONIC, print interval
+   **s**\ ince that timestamp (elapsed.)
+
+   ``%pTVMu`` - input is a timestamp on CLOCK_MONOTONIC, print interval
+   **u**\ ntil that timestamp (deadline.)
+
+   ``%pTVR`` - input is a timestamp on CLOCK_REALTIME, print calendaric date.
+
+   ``%pTVRs`` - input is a timestamp on CLOCK_REALTIME, print interval
+   **s**\ ince that timestamp.
+
+   ``%pTVRu`` - input is a timestamp on CLOCK_REALTIME, print interval
+   **u**\ ntil that timestamp.
+
+   ``%pTVA`` - reserved for CLOCK_TAI in case a PTP implementation is
+   interfaced to FRR.  Not currently implemented.
+
+   .. note::
+
+      If ``%pTVRs`` or ``%pTVRu`` are used, this is generally an indication
+      that a CLOCK_MONOTONIC timestamp should be used instead (or added in
+      parallel.) CLOCK_REALTIME might be adjusted by NTP, PTP or similar
+      procedures, causing bogus intervals to be printed.
+
+      ``%pTVM`` on first look might be assumed to have the same problem, but
+      on closer thought the assumption is always that current system time is
+      correct.  And since a CLOCK_MONOTONIC interval is also quite safe to
+      assume to be correct, the (past) absolute timestamp to be printed from
+      this can likely be correct even if it doesn't match what CLOCK_REALTIME
+      would have indicated at that point in the past.  This logic does,
+      however, not quite work for *future* times.
+
+      Generally speaking, almost all use cases in FRR should (and do) use
+      CLOCK_MONOTONIC (through :c:func:`monotime()`.)
+
+   Flags common to printing calendar times and intervals:
+
+   ``p``: include spaces in appropriate places (depends on selected format.)
+
+   ``%p.3TV...``: specify sub-second resolution (use with ``FMT_NSTD`` to
+   suppress gcc warning.)  As noted above, ``%pTT`` will never print sub-second
+   digits since there are none.  Only some formats support printing sub-second
+   digits and the default may vary.
+
+   The following flags are available for printing calendar times/dates:
+
+   (no flag): :frrfmtout:`Sat Jan  1 00:00:00 2022` - print output from
+   ``ctime()``, in local time zone.  Since FRR does not currently use/enable
+   locale support, this is always the C locale.  (Locale support getting added
+   is unlikely for the time being and would likely break other things worse
+   than this.)
+
+   ``i``: :frrfmtout:`2022-01-01T00:00:00.123` - ISO8601 timestamp in local
+   time zone (note there is no ``Z`` or ``+00:00`` suffix.)  Defaults to
+   millisecond precision.
+
+   ``ip``: :frrfmtout:`2022-01-01 00:00:00.123` - use readable form of ISO8601
+   with space instead of ``T`` separator.
+
+   The following flags are available for printing intervals:
+
+   (no flag): :frrfmtout:`9w9d09:09:09.123` - does not match any
+   preexisting format;  added because it does not lose precision (like ``t``)
+   for longer intervals without printing huge numbers (like ``h``/``m``).
+   Defaults to millisecond precision.  The week/day fields are left off if
+   they're zero, ``p`` adds a space after the respective letter.
+
+   ``t``: :frrfmtout:`9w9d09h`, :frrfmtout:`9d09h09m`, :frrfmtout:`09:09:09` -
+   this replaces :c:func:`frrtime_to_interval()`.  ``p`` adds spaces after
+   week/day/hour letters.
+
+   ``d``: print decimal number of seconds.  Defaults to millisecond precision.
+
+   ``x`` / ``tx`` / ``dx``: Like no flag / ``t`` / ``d``, but print
+   :frrfmtout:`-` for zero or negative intervals (for use with unset timers.)
+
+   ``h``: :frrfmtout:`09:09:09`
+
+   ``hx``: :frrfmtout:`09:09:09`, :frrfmtout:`--:--:--` - this replaces
+   :c:func:`pim_time_timer_to_hhmmss()`.
+
+   ``m``: :frrfmtout:`09:09`
+
+   ``mx``: :frrfmtout:`09:09`, :frrfmtout:`--:--` - this replaces
+   :c:func:`pim_time_timer_to_mmss()`.
+
+FRR library helper formats
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. frrfmt:: %pTH (struct thread *)
+
+   Print remaining time on timer thread. Interval-printing flag characters
+   listed above for ``%pTV`` can be added, e.g. ``%pTHtx``.
+
+   ``NULL`` pointers are printed as ``-``.
+
+.. frrfmt:: %pTHD (struct thread *)
+
+   Print debugging information for given thread.  Sample output:
+
+   .. code-block:: none
+
+      {(thread *)NULL}
+      {(thread *)0x55a3b5818910 arg=0x55a3b5827c50 timer  r=7.824      mld_t_query() &mld_ifp->t_query from pimd/pim6_mld.c:1369}
+      {(thread *)0x55a3b5827230 arg=0x55a3b5827c50 read   fd=16        mld_t_recv() &mld_ifp->t_recv from pimd/pim6_mld.c:1186}
+
+   (The output is aligned to some degree.)
+
 General utility formats
 ^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -485,7 +633,7 @@ calls to :c:func:`zlog_tls_buffer_flush()` in appropriate places:
    buffer.  This function is safe to call regardless of the per-thread log
    buffer being set up / in use or not.
 
-When working with threads that do not use the :c:type:`struct thread_master`
+When working with threads that do not use the :c:struct:`thread_master`
 event loop, per-thread buffers can be managed with:
 
 .. c:function:: void zlog_tls_buffer_init(void)
@@ -527,7 +675,7 @@ that they use.
 Basic internals
 ^^^^^^^^^^^^^^^
 
-.. c:type:: struct zlog_target
+.. c:struct:: zlog_target
 
    This struct needs to be filled in by any log target and then passed to
    :c:func:`zlog_target_replace()`.  After it has been registered,
@@ -566,7 +714,7 @@ Basic internals
 
    Allocates a logging target struct.  Note that the ``oldzt`` argument may be
    ``NULL`` to allocate a "from scratch".  If ``oldzt`` is not ``NULL``, the
-   generic bits in :c:type:`struct zlog_target` are copied.  **Target specific
+   generic bits in :c:struct:`zlog_target` are copied.  **Target specific
    bits are not copied.**
 
 .. c:function:: struct zlog_target *zlog_target_replace(struct zlog_target *oldzt, struct zlog_target *newzt)