Changeset f949b43 in rtems-libbsd


Ignore:
Timestamp:
Oct 10, 2018, 9:37:37 AM (8 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5cb01f277962d3127d364bf871f799b34e6b6be6, 9a4ed64d5acc20cd3488a633bd78cad7d1708081
Children:
91327bd
Parents:
1e77a45
git-author:
Sebastian Huber <sebastian.huber@…> (10/10/18 09:37:37)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/10/18 12:20:06)
Message:

Fix syslog() priority handling

Ths syslog priority is a mask not a level.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/rtems/syslog.c

    r1e77a45 rf949b43  
    88
    99/*
    10  * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2014, 2018 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    4747#include <rtems/bsd/bsd.h>
    4848
    49 static int syslog_priority = LOG_NOTICE;
     49static int syslog_mask = LOG_UPTO(LOG_NOTICE);
     50
     51static bool
     52syslog_do_log(int priority)
     53{
     54
     55        return (((LOG_MASK(LOG_PRI(priority)) & syslog_mask)) != 0);
     56}
    5057
    5158void
    5259syslog(int priority, const char *format, ...)
    5360{
    54         if (priority <= syslog_priority) {
     61
     62        if (syslog_do_log(priority)) {
    5563                va_list ap;
    5664
     
    6472vsyslog(int priority, const char *format, va_list ap)
    6573{
    66         if (priority <= syslog_priority) {
     74
     75        if (syslog_do_log(priority)) {
    6776                rtems_bsd_vprintf(priority, format, ap);
    6877        }
     
    8493setlogmask(int mask)
    8594{
    86         /* TODO */
     95
     96        /*
     97         * Ignore settings via this function since it has a process-wide scope.
     98         * System services (a DHCP client daemon for example) may set this and
     99         * assume that they run in their own environment (process).  This is
     100         * not the case in RTEMS.  The syslog mask can be set via
     101         * rtems_bsd_setlogpriority().
     102         */
     103        return (0);
    87104}
    88105
    89106int
    90 rtems_bsd_setlogpriority(const char* priority)
     107rtems_bsd_setlogpriority(const char *priority)
    91108{
    92         CODE* c = &prioritynames[0];
     109        const CODE *c;
     110
     111        c = &prioritynames[0];
    93112        while (c->c_name != NULL) {
    94113                if (strcasecmp(c->c_name, priority) == 0) {
    95                         syslog_priority = c->c_val;
    96                         return 0;
     114                        syslog_mask = LOG_UPTO(c->c_val);
     115                        return (0);
    97116                }
    98117                ++c;
    99118        }
     119
    100120        errno = ENOENT;
    101         return -1;
     121        return (-1);
    102122}
Note: See TracChangeset for help on using the changeset viewer.