LCOV - code coverage report
Current view: top level - util - sss_log.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 9 0.0 %
Date: 2012-11-29 Functions: 0 1 0.0 %
Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :     SSSD
       3                 :            : 
       4                 :            :     sss_log.c
       5                 :            : 
       6                 :            :     Authors:
       7                 :            :         Stephen Gallagher <sgallagh@redhat.com>
       8                 :            : 
       9                 :            :     Copyright (C) 2010 Red Hat
      10                 :            : 
      11                 :            :     This program is free software; you can redistribute it and/or modify
      12                 :            :     it under the terms of the GNU General Public License as published by
      13                 :            :     the Free Software Foundation; either version 3 of the License, or
      14                 :            :     (at your option) any later version.
      15                 :            : 
      16                 :            :     This program is distributed in the hope that it will be useful,
      17                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :     GNU General Public License for more details.
      20                 :            : 
      21                 :            :     You should have received a copy of the GNU General Public License
      22                 :            :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      23                 :            : */
      24                 :            : 
      25                 :            : #include "util/util.h"
      26                 :            : #include <syslog.h>
      27                 :            : 
      28                 :            : static int sss_to_syslog(int priority)
      29                 :            : {
      30         [ #  # ]:          0 :     switch(priority) {
      31                 :            :     case SSS_LOG_EMERG:
      32                 :            :         return LOG_EMERG;
      33                 :            :     case SSS_LOG_ALERT:
      34                 :            :         return LOG_ALERT;
      35                 :            :     case SSS_LOG_CRIT:
      36                 :            :         return LOG_CRIT;
      37                 :            :     case SSS_LOG_ERR:
      38                 :            :         return LOG_ERR;
      39                 :            :     case SSS_LOG_WARNING:
      40                 :            :         return LOG_WARNING;
      41                 :            :     case SSS_LOG_NOTICE:
      42                 :            :         return LOG_NOTICE;
      43                 :            :     case SSS_LOG_INFO:
      44                 :            :         return LOG_INFO;
      45                 :            :     case SSS_LOG_DEBUG:
      46                 :            :         return LOG_DEBUG;
      47                 :            :     default:
      48                 :            :         /* If we've been passed an invalid priority, it's
      49                 :            :          * best to assume it's an emergency.
      50                 :            :          */
      51                 :            :         return LOG_EMERG;
      52                 :            :     }
      53                 :            : }
      54                 :            : 
      55                 :          0 : void sss_log(int priority, const char *format, ...)
      56                 :            : {
      57                 :            :     va_list ap;
      58                 :            :     int syslog_priority;
      59                 :            : 
      60                 :          0 :     syslog_priority = sss_to_syslog(priority);
      61                 :            : 
      62                 :          0 :     openlog(debug_prg_name, 0, LOG_DAEMON);
      63                 :            : 
      64                 :          0 :     va_start(ap, format);
      65                 :          0 :     vsyslog(syslog_priority, format, ap);
      66                 :          0 :     va_end(ap);
      67                 :            : 
      68                 :          0 :     closelog();
      69                 :          0 : }

Generated by: LCOV version 1.9