Plugin to add Pijul support to the Nix package manager
#ifndef NIX_PLUGIN_PIJUL_DEBUG_H
#define NIX_PLUGIN_PIJUL_DEBUG_H

#define NO_DEBUG

#if defined(NIX_VERSION) && !defined(NO_DEBUG)

#include <logging.hh>

using nix::fmt;
using nix::logger;
using nix::lvlDebug;

#define DBG_MSG(...) debug(__VA_ARGS__)

#define DBG_BEGIN try {
#define DBG_END                                                                                                                                                \
    }                                                                                                                                                          \
    catch (std::exception & e)                                                                                                                                 \
    {                                                                                                                                                          \
        DBG_MSG("caught exception at %s:%d", __FILE__, __LINE__);                                                                                              \
        throw e;                                                                                                                                               \
    }

#else

#define DBG_BEGIN
#define DBG_END
#define DBG_MSG(...)

#endif

#endif // NIX_PLUGIN_PIJUL_DEBUG_H