LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/geojson/libjson - debug.c (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 24 0.0 %
Date: 2024-05-06 16:27:07 Functions: 0 6 0.0 %

          Line data    Source code
       1             : /*
       2             :  * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
       3             :  *
       4             :  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
       5             :  * Michael Clark <michael@metaparadigm.com>
       6             :  *
       7             :  * This library is free software; you can redistribute it and/or modify
       8             :  * it under the terms of the MIT license. See COPYING for details.
       9             :  *
      10             :  */
      11             : 
      12             : #include "config.h"
      13             : 
      14             : #include <stdarg.h>
      15             : #include <stdio.h>
      16             : #include <stdlib.h>
      17             : #include <string.h>
      18             : 
      19             : #if HAVE_SYSLOG_H
      20             : #include <syslog.h>
      21             : #endif /* HAVE_SYSLOG_H */
      22             : 
      23             : #if HAVE_UNISTD_H
      24             : #include <unistd.h>
      25             : #endif /* HAVE_UNISTD_H */
      26             : 
      27             : #if HAVE_SYS_PARAM_H
      28             : #include <sys/param.h>
      29             : #endif /* HAVE_SYS_PARAM_H */
      30             : 
      31             : #include "debug.h"
      32             : 
      33             : static int _syslog = 0;
      34             : static int _debug = 0;
      35             : 
      36           0 : void mc_set_debug(int debug)
      37             : {
      38           0 :   _debug = debug;
      39           0 : }
      40           0 : int mc_get_debug(void)
      41             : {
      42           0 :   return _debug;
      43             : }
      44             : 
      45           0 : extern void mc_set_syslog(int syslog)
      46             : {
      47           0 :   _syslog = syslog;
      48           0 : }
      49             : 
      50           0 : void mc_debug(const char *msg, ...)
      51             : {
      52             :   va_list ap;
      53           0 :   if (_debug)
      54             :   {
      55           0 :     va_start(ap, msg);
      56             : #if HAVE_VSYSLOG
      57             :     if (_syslog)
      58             :     {
      59             :       vsyslog(LOG_DEBUG, msg, ap);
      60             :     }
      61             :     else
      62             : #endif
      63           0 :       vprintf(msg, ap);
      64           0 :     va_end(ap);
      65             :   }
      66           0 : }
      67             : 
      68           0 : void mc_error(const char *msg, ...)
      69             : {
      70             :   va_list ap;
      71           0 :   va_start(ap, msg);
      72             : #if HAVE_VSYSLOG
      73             :   if (_syslog)
      74             :   {
      75             :     vsyslog(LOG_ERR, msg, ap);
      76             :   }
      77             :   else
      78             : #endif
      79           0 :     vfprintf(stderr, msg, ap);
      80           0 :   va_end(ap);
      81           0 : }
      82             : 
      83           0 : void mc_info(const char *msg, ...)
      84             : {
      85             :   va_list ap;
      86           0 :   va_start(ap, msg);
      87             : #if HAVE_VSYSLOG
      88             :   if (_syslog)
      89             :   {
      90             :     vsyslog(LOG_INFO, msg, ap);
      91             :   }
      92             :   else
      93             : #endif
      94           0 :     vfprintf(stderr, msg, ap);
      95           0 :   va_end(ap);
      96           0 : }

Generated by: LCOV version 1.14