pipeplayer/log.h
2022-08-08 00:42:22 +00:00

43 lines
1.1 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __LOG_H__
#define __LOG_H__
#include "loglevels.h"
#include "config.h"
// Default logging level is error
#ifndef LOGGING_LEVEL
#define LOGGING_LEVEL ERROR
#endif /* Logging level */
// Colors
#if LOGGING_COLORS == 1
#define __LOGGING_ERROR_MESSAGE "[ERROR](B "
#define __LOGGING_INFO_MESSAGE "[INFO](B "
#define __LOGGING_DEBUG_MESSAGE "[DEBUG](B "
#else
#define __LOGGING_ERROR_MESSAGE "[ERROR] "
#define __LOGGING_INFO_MESSAGE "[INFO] "
#define __LOGGING_DEBUG_MESSAGE "[DEBUG] "
#endif /* Colors */
// Logging macro and include of stdio
#if LOGGING_LEVEL >= ERROR
#include <stdio.h>
#define LOG_ERROR(...) printf(__LOGGING_ERROR_MESSAGE); printf(__VA_ARGS__); puts("");
#else
#define LOG_ERROR(...)
#endif
#if LOGGING_LEVEL >= INFO
#define LOG_INFO(...) printf(__LOGGING_INFO_MESSAGE); printf(__VA_ARGS__); puts("");
#else
#define LOG_INFO(...)
#endif
#if LOGGING_LEVEL >= DEBUG
#define LOG_DEBUG(...) printf(__LOGGING_DEBUG_MESSAGE); printf(__VA_ARGS__); puts("");
#else
#define LOG_DEBUG(...)
#endif
#endif /* __LOG_H__ */