73 lines
2.4 KiB
C
73 lines
2.4 KiB
C
/* ************************************************************************** */
|
|
/* _____ _ */
|
|
/* libg1m/internals/log.h |_ _|__ _ _| |__ ___ _ _ */
|
|
/* | Project: libg1m | |/ _ \| | | | '_ \ / _ \ | | | */
|
|
/* | | (_) | |_| | | | | __/ |_| | */
|
|
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
|
|
/* Last updated: 2016/10/31 00:14:27 |___/ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#ifndef LIBG1M_INTERNALS_LOG_H
|
|
# define LIBG1M_INTERNALS_LOG_H
|
|
# include <stdint.h>
|
|
# include <inttypes.h>
|
|
|
|
/* Some printf types */
|
|
# ifdef _WIN64
|
|
# define PRIuSIZE "l64u"
|
|
# elif _WIN32
|
|
# define PRIuSIZE "u"
|
|
# else
|
|
# define PRIuSIZE "zu"
|
|
# endif
|
|
|
|
/* ************************************************************************** */
|
|
/* Log utility */
|
|
/* ************************************************************************** */
|
|
/* Log level */
|
|
# define ll_info 0
|
|
# define ll_warn 1
|
|
# define ll_error 2
|
|
# define ll_fatal 3
|
|
# define ll_none 4
|
|
|
|
/* Macros */
|
|
# define log(P, S, ...) fprintf(stderr, P "%s: " S "\n", __FUNCTION__, ##__VA_ARGS__)
|
|
# define logm(S, M, N) g1m_log_mem(S, M, N)
|
|
|
|
# if LOGLEVEL <= ll_info
|
|
# define log_info(S, ...) log("[libg1m info] ", S, ##__VA_ARGS__)
|
|
# define logm_info(M, N) logm("[libg1m info] ", M, N)
|
|
# else
|
|
# define log_info(S, ...)
|
|
# define logm_info(M, N)
|
|
# endif
|
|
|
|
# if LOGLEVEL <= ll_warn
|
|
# define log_warn(S, ...) log("[libg1m warn] ", S, ##__VA_ARGS__)
|
|
# define logm_warn(M, N) logm("[libg1m warn] ", M, N)
|
|
# else
|
|
# define log_warn(S, ...)
|
|
# define logm_warn(M, N)
|
|
# endif
|
|
|
|
# if LOGLEVEL <= ll_error
|
|
# define log_error(S, ...) log("[libg1m error] ", S, ##__VA_ARGS__)
|
|
# else
|
|
# define log_error(S, ...)
|
|
# endif
|
|
|
|
# if LOGLEVEL <= ll_fatal
|
|
# define log_fatal(S, ...) log("[libg1m fatal] ", S, ##__VA_ARGS__)
|
|
# else
|
|
# define log_fatal(S, ...)
|
|
# endif
|
|
|
|
/* Functions prototypes */
|
|
void g1m_log_mem(const char *prefix, void *m, size_t n);
|
|
const char *g1m_get_type_string(int main_id, int type);
|
|
const char *g1m_get_mcs_ftype_string(int code);
|
|
const char *g1m_get_eact_ltype_string(int code);
|
|
|
|
#endif /* LIBG1M_INTERNALS_LOG_H */
|