公司代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

/**
* Copyright (c) 2020 rxi
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MIT license. See `log.c` for details.
*/
#ifndef BSP_LOG_H
#define BSP_LOG_H
#ifndef __LOG_H_
#define __LOG_H_
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <time.h>
#include "../../BASE/Inc/BSP/bsp_UART.h"
#include <stdarg.h>
//#define OPEN_LOG 1
#define OPEN_LOG 5
typedef enum
{
LOG_TRACE = 0, LOG_DEBUG = 1, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL
} E_LOG_LEVEL;
extern char log_buf[500];
extern char LOG_LEVEL_Char;
void log_intialize(struct UARTHandler *Handler);
void log_log(const int level, const char *fun, const int line, const char *fmt,
...);
#define log(level, fmt, ...) log_log(level, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#define log_trace(...) log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
#define log_debug(...) log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
#define log_info(...) log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
#define log_warn(...) log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
#define log_error(...) log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
#define log_fatal(...) log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
#endif
#endif