2024-04-22 00:09:51 +08:00

46 lines
1.7 KiB
C

/*********************************************************************************************************
* ------------------------------------------------------------------------------------------------------
* file description
* ------------------------------------------------------------------------------------------------------
* \file vlog.h
* \unit vlog
* \brief This is a simple log module for C language
* \author Lamdonn
* \version v1.0.0
* \license GPL-2.0
* \copyright Copyright (C) 2023 Lamdonn.
********************************************************************************************************/
#ifndef __vlog_H
#define __vlog_H
#include <stdarg.h>
/* vlog buffer size */
#define VLOG_BUFFER_SIZE (1024)
/* vlog channel */
#define VLOG_CHANNEL_0 (0x01)
#define VLOG_CHANNEL_1 (0x02)
#define VLOG_CHANNEL_2 (0x04)
#define VLOG_CHANNEL_3 (0x08)
#define VLOG_CHANNEL_4 (0x10)
#define VLOG_CHANNEL_5 (0x20)
#define VLOG_CHANNEL_6 (0x40)
#define VLOG_CHANNEL_7 (0x80)
#define VLOG_CHANNEL_ALL (0xFF)
#define VLOG_ENABALE(c) vlog_set_channel(vlog_get_channel() | (1 << (c)))
#define VLOG_DISABALE(c) vlog_set_channel(vlog_get_channel() & ~(1 << (c)))
/* callback function define */
typedef void (*vlog_func_t)(char *buf, int len);
int vlog(char channel, const char *format, ...);
void vlog_set_channel(char channel);
char vlog_get_channel(void);
int vlog_start_offline(const char *filename);
void vlog_stop_offline(void);
void vlog_set_func(vlog_func_t func);
#endif