libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

extractor_logging.c (1800B)


      1 /*
      2      This file is part of libextractor.
      3      Copyright (C) 2012 Vidyut Samanta and Christian Grothoff
      4 
      5      libextractor is free software; you can redistribute it and/or modify
      6      it under the terms of the GNU General Public License as published
      7      by the Free Software Foundation; either version 3, or (at your
      8      option) any later version.
      9 
     10      libextractor is distributed in the hope that it will be useful, but
     11      WITHOUT ANY WARRANTY; without even the implied warranty of
     12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13      General Public License for more details.
     14 
     15      You should have received a copy of the GNU General Public License
     16      along with libextractor; see the file COPYING.  If not, write to the
     17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18      Boston, MA 02110-1301, USA.
     19  */
     20 /**
     21  * @file main/extractor_logging.c
     22  * @brief logging API for GNU libextractor
     23  * @author Christian Grothoff
     24  */
     25 #include "platform.h"
     26 #include "extractor_logging.h"
     27 
     28 #if DEBUG
     29 /**
     30  * Log function.
     31  *
     32  * @param file name of file with the error
     33  * @param line line number with the error
     34  * @param ... log message and arguments
     35  */
     36 void
     37 EXTRACTOR_log_ (const char *file, int line, const char *format, ...)
     38 {
     39   va_list va;
     40 
     41   fprintf (stderr,
     42            "EXTRACTOR %s:%d ",
     43            file, line);
     44   va_start (va, format);
     45   vfprintf (stderr, format, va);
     46   va_end (va);
     47   fflush (stderr);
     48 }
     49 
     50 
     51 #endif
     52 
     53 
     54 /**
     55  * Abort the program reporting an assertion failure
     56  *
     57  * @param file filename with the failure
     58  * @param line line number with the failure
     59  */
     60 void
     61 EXTRACTOR_abort_ (const char *file,
     62                   int line)
     63 {
     64 #if DEBUG
     65   EXTRACTOR_log_ (file, line, "Assertion failed.\n");
     66 #endif
     67   ABORT ();
     68 }
     69 
     70 
     71 /* end of extractor_logging.c */