Sha256: f0b441f52e8d8aa0a971fac6dafdf80e66de641855fd47191fd3b0f8f8825349

Contents?: true

Size: 1002 Bytes

Versions: 7

Compression:

Stored size: 1002 Bytes

Contents

#ifndef CMARK_DEBUG_H
#define CMARK_DEBUG_H
#include <stdio.h>
#include <errno.h>
#include <string.h>

#ifdef NDEBUG
#define debug(M, ...)
#else
#define debug(M, ...) \
  fprintf(stderr, "DEBUG %s:%d: " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#endif

#define clean_errno() (errno == 0 ? "None" : strerror(errno))

#define log_err(M, ...) \
  fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \
           clean_errno(), ##__VA_ARGS__)

#define log_warn(M, ...) \
  fprintf(stderr, "[WARN] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \
           clean_errno(), ##__VA_ARGS__)

#define log_info(M, ...) fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, \
            __LINE__, ##__VA_ARGS__)

#define check(A, M, ...) \
  if(!(A)) { log_err(M, ##__VA_ARGS__); errno=0; goto error; }

#define sentinel(M, ...) \
   { log_err(M, ##__VA_ARGS__); errno=0; goto error; }

#define check_debug(A, M, ...) \
  if(!(A)) { debug(M, ##__VA_ARGS__); errno=0; goto error; }

#endif

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
commonmarker-0.2.1 ext/commonmarker/cmark/src/debug.h
commonmarker-0.2.0 ext/commonmarker/cmark/src/debug.h
commonmarker-0.1.3 ext/commonmarker/cmark/src/debug.h
commonmarker-0.1.2 ext/commonmarker/cmark/src/debug.h
commonmarker-0.1.1 ext/commonmarker/cmark/src/debug.h
commonmarker-0.1.0 ext/commonmarker/cmark/src/debug.h
commonmarker-0.0.1 ext/commonmarker/cmark/src/debug.h