2019-04-05 16:20:30 +02:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017-2019 by Löwenware Ltd
|
|
|
|
* Please, refer LICENSE file for legal information
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file log.h
|
|
|
|
* @author Ilja Kartašov <ik@lowenware.com>
|
|
|
|
* @brief cStuff log module header file
|
|
|
|
*
|
|
|
|
* @see https://lowenware.com/cStuff/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CSTUFF_LOG_H_557ADEFE_2BE8_4B9B_A894_F08FF64008EF
|
|
|
|
#define CSTUFF_LOG_H_557ADEFE_2BE8_4B9B_A894_F08FF64008EF
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "retcode.h"
|
|
|
|
|
|
|
|
#define CSTUFF_LOG_OFF (0)
|
|
|
|
#define CSTUFF_LOG_ERROR (1<<0)
|
|
|
|
#define CSTUFF_LOG_ALERT (1<<1)
|
|
|
|
#define CSTUFF_LOG_STATE (1<<2)
|
|
|
|
#define CSTUFF_LOG_DEBUG (1<<3)
|
|
|
|
#define CSTUFF_LOG_ALL (0xFF)
|
|
|
|
|
|
|
|
struct cstuff_log
|
|
|
|
{
|
2019-04-16 14:26:37 +02:00
|
|
|
FILE * target;
|
|
|
|
uint8_t level;
|
2019-04-05 16:20:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct cstuff_log * cstuff_log_t;
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
cstuff_log_init(cstuff_log_t self, uint8_t level);
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
cstuff_log_release(cstuff_log_t self);
|
|
|
|
|
|
|
|
|
|
|
|
cstuff_retcode_t
|
|
|
|
cstuff_log_set_file(cstuff_log_t self, const char * filename);
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
cstuff_log_printf(cstuff_log_t self, uint8_t level, const char * format, ...);
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2019-04-16 14:26:37 +02:00
|
|
|
cstuff_log_vprintf( cstuff_log_t self,
|
|
|
|
uint8_t level,
|
|
|
|
const char * format,
|
|
|
|
va_list vl );
|
2019-04-05 16:20:30 +02:00
|
|
|
|
|
|
|
#endif /* !CSTUFF_LOG_H */
|