88 lines
2.7 KiB
C
88 lines
2.7 KiB
C
#ifndef VESSEL_LOG_H_
|
|
#define VESSEL_LOG_H_
|
|
|
|
#include "conf.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
|
|
#include "def.h"
|
|
#include "clrs.h"
|
|
|
|
/* Debug logs cannot be turned off as they are internal. */
|
|
|
|
#define VS_LOG_NORMAL 0x1 /* 0001 */
|
|
#define VS_LOG_INFO 0x2 /* 0010 */
|
|
#define VS_LOG_ERROR 0x4 /* 0100 */
|
|
#define VS_LOG_WARN 0x8 /* 1000 */
|
|
|
|
#define VS_LOG_ALL ((VS_LOG_NORMAL) | (VS_LOG_INFO) | (VS_LOG_ERROR) | (VS_LOG_WARN)) /* 1111 */
|
|
#define VS_LOG_NONE = 0x0 /* 0000 */
|
|
|
|
typedef volatile uint8_t vs_Logger;
|
|
|
|
#ifndef NO_LOGGING
|
|
|
|
void vs_vlog_fprint(FILE *fp, const char *head, const char *clr, const char *fmt, va_list /*args*/)
|
|
__attribute__((format(printf, 4, 0)));
|
|
void vs_log_fprint(FILE *fp, const char *head, const char *clr, const char *fmt, ...)
|
|
__attribute__((format(printf, 4, 5)));
|
|
|
|
void vs_log_normal(const vs_Logger *lg, const char *msg);
|
|
|
|
void vs_log_info(const vs_Logger *lg, const char *msg);
|
|
|
|
void vs_log_error(const vs_Logger *lg, const char *msg);
|
|
|
|
void vs_log_warn(const vs_Logger *lg, const char *msg);
|
|
|
|
#else
|
|
|
|
# define vs_vlog_fprint(fp, head, clr, fmt, list) \
|
|
(void)(fp); \
|
|
(void)(head); \
|
|
(void)(clr); \
|
|
(void)(fmt); \
|
|
(void)(list)
|
|
|
|
# define vs_log_fprint(fp, head, clr, fmt, ...) \
|
|
(void)(fp); \
|
|
(void)(head); \
|
|
(void)(clr); \
|
|
(void)(fmt);
|
|
|
|
# define vs_log_normal(lg, msg) \
|
|
(void)(lg); \
|
|
(void)(msg)
|
|
|
|
# define vs_log_info(lg, msg) \
|
|
(void)(lg); \
|
|
(void)(msg)
|
|
|
|
# define vs_log_error(lg, msg) \
|
|
(void)(lg); \
|
|
(void)(msg)
|
|
|
|
# define vs_log_warn(lg, msg) \
|
|
(void)(lg); \
|
|
(void)(msg)
|
|
|
|
#endif /* NO_LOGGING */
|
|
|
|
void vs_flog_normal(const vs_Logger *lg, const char *fmt, ...)
|
|
__attribute__((format(printf, 2, 3)));
|
|
void vs_flog_info(const vs_Logger *lg, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
|
void vs_flog_error(const vs_Logger *lg, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
|
void vs_flog_warn(const vs_Logger *lg, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
|
|
|
void vs_log_flush(void);
|
|
|
|
#ifdef DEBUG
|
|
void vs_flog_debug(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
|
void vs_log_debug(const char *msg);
|
|
#else
|
|
# define vs_flog_debug(...)
|
|
# define vs_log_debug(...)
|
|
#endif /* DEBUG */
|
|
|
|
#endif /* VESSEL_LOG_H_ */
|