#ifndef __ERROR_H__
#define __ERROR_H__

#ifdef __cplusplus
extern "C" {
#endif /* C++ */
#include <time.h>
#include <uvdbus/log.h>

enum {
    NETEASE_SUCCESS = 0,
    NETEASE_ERROR_FAIL = -1,
    NETEASE_ERROR_EXCEPTION = -2,
    NETEASE_ERROR_NULL_POINTER = -3,

    /* General errors 10100(0x2774) */
    NETEASE_ERROR_GENERAL = 10100,
    NETEASE_ERROR_OUT_OF_MEMORY = 10101,
    NETEASE_ERROR_OPEN_FILE = 10102,

    /*dbus error*/
    NETEASE_ERROR_DBUS_CONNECT = -100,
    NETEASE_ERROR_DBUS_REQNAME = -101,
    NETEASE_ERROR_DBUS_MATCHSIGNAL = -102,

};

#define NETEASE_TOAST
#define NETEASE_DEBUG
#define NETEASE_ERROR
#define ENABLE_LOG_EX

#ifdef ENABLE_LOG_EX
#define n_printf(format, arg...) LOG_EX(LOG_Debug, format, ##arg)
#else
#define n_printf(format, arg...) printf(format, ##arg)
#endif
// fprintf(stderr, format, ##arg)

#ifdef NETEASE_TOAST
#define n_toast(fmt, arg...) printf(fmt, ##arg)
#else
#define n_toast(fmt, arg...)                                                   \
    do {                                                                       \
    } while (0)
#endif

#ifdef NETEASE_DEBUG
#define n_debug(fmt, arg...)  do{printf(fmt, ##arg);}while(0)
#else
#define n_debug(fmt, arg...)                                                   \
    do {                                                                       \
    } while (0)
#endif

#ifdef NETEASE_ERROR
#define n_error(fmt, arg...) printf(fmt, ##arg)
#else
#define n_error(fmt, arg...)                                                   \
    do {                                                                       \
    } while (0)
#endif

long long Netease_caltime(unsigned long long *usec, int update);
char *Netease_gettime_string();
unsigned long long Netease_gettime_ms();
unsigned long long Netease_monotonic_gettime_ms();
long long Netease_monotonic_caltime(unsigned long long *usec, int update);

#ifdef __cplusplus
} /* extern "C" */
#endif /* C++ */

#endif /* __ERROR_H__ */
