Changeset 7ec935e in rtems-libbsd


Ignore:
Timestamp:
Mar 23, 2018, 6:58:18 AM (15 months ago)
Author:
Christian Mauderer <christian.mauderer@…>
Branches:
eeb3fd5d9b07ac9a2e280cff60a1b762bd273a8d, 1e989998de954bef51e6c19cc3d64d39f32100aa
Children:
8993827
Parents:
d300a34
git-author:
Christian Mauderer <christian.mauderer@…> (03/23/18 06:58:18)
git-committer:
Christian Mauderer <christian.mauderer@…> (03/23/18 08:36:35)
Message:

vprintf: Add handler that mutes all output.

This adds a vprintf handler that can be used to suppress all outputs of
the libbsd.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libbsd.txt

    rd300a34 r7ec935e  
    265265function (for example in the module which calls `rtems_bsd_initialize()`) if
    266266different values are desired.  The default size is 8MiB for all domains.
     267
     268=== Redirecting or Disabling the Output ===
     269
     270A lot of system messages are printed to the stdout by default. If you want to
     271redirect them you can overwrite the default print handler. That can even be done
     272before the libbsd initialization to catch all messages. An example would look
     273like follows:
     274
     275-------------------------------------------------------------------------------
     276int my_vprintf_handler(int level, const char *fmt, va_list ap) {
     277        /* Do something with the messages. */
     278
     279        return number_of_printed_chars;
     280}
     281
     282...
     283        /* In your initialization: */
     284        rtems_bsd_vprintf_handler old;
     285        old = rtems_bsd_set_vprintf_handler(my_vprintf_handler);
     286...
     287-------------------------------------------------------------------------------
     288
     289As a special case, you can set the `rtems_bsd_vprintf_handler_mute(...)`
     290provided by libbsd to suppress all output.
    267291
    268292== Network Stack Features
  • rtemsbsd/include/rtems/bsd/bsd.h

    rd300a34 r7ec935e  
    295295int rtems_bsd_setlogpriority(const char* priority);
    296296
     297/**
     298 * @brief Set this vprintf handler to suppress all output.
     299 *
     300 * @retval Allways 0.
     301 *
     302 * @see rtems_bsd_vprintf() for the parameters.
     303 */
     304int rtems_bsd_vprintf_handler_mute(int level, const char *fmt, va_list ap);
     305
    297306/** @} */
    298307
  • rtemsbsd/rtems/rtems-kernel-vprintf.c

    rd300a34 r7ec935e  
    104104    default_vprintf_handler;
    105105
     106int
     107rtems_bsd_vprintf_handler_mute(int level, const char *fmt, va_list ap)
     108{
     109        (void) level;
     110        (void) fmt;
     111        (void) ap;
     112
     113        return 0;
     114}
     115
    106116rtems_bsd_vprintf_handler
    107117rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler new_handler)
Note: See TracChangeset for help on using the changeset viewer.