/*******************************************************************************
 * Copyright (c) 2018 Renesas Electronics Corporation. All rights reserved.
 *
 * DESCRIPTION   : Log driver header
 ******************************************************************************/

#ifndef LOG_H__
#define LOG_H__

#include <stdint.h>
#include <stdio.h>

#define LOG_NONE		(0)
#define LOG_ERROR		(1)
#define LOG_NOTICE		(2)
#define LOG_WARNING		(3)
#define LOG_INFO		(4)
#define LOG_VERBOSE		(5)

#ifndef LOG_LEVEL
 #define LOG_LEVEL		(LOG_WARNING)
#endif

#if LOG_LEVEL >= LOG_VERBOSE
# define VERBOSE(...)	local_printf("V:" __VA_ARGS__)
#else
# define VERBOSE(...)
#endif

#if LOG_LEVEL >= LOG_INFO
# define INFO(...)	local_printf("I:" __VA_ARGS__)
#else
# define INFO(...)
#endif

#if LOG_LEVEL >= LOG_WARNING
# define WARN(...)	local_printf("W:" __VA_ARGS__)
#else
# define WARN(...)
#endif

#if LOG_LEVEL >= LOG_ERROR
# define ERROR(...)	local_printf("E:" __VA_ARGS__)
#else
# define ERROR(...)
#endif

#if LOG_LEVEL >= LOG_NOTICE
# define NOTICE(...)	local_printf("N:" __VA_ARGS__)
#else
# define NOTICE(...)
#endif

#define panic(...)						\
	do {							\
		local_printf("P:%s[%d]\n", __func__, __LINE__);	\
		while(1);					\
	} while (0)

#define FORCE(...)	local_printf(__VA_ARGS__)

void local_printf(const char *fmt, ...);

#endif /* LOG_H__ */
