#ifndef LOG_H
#define LOG_H
#include "../public/nsapi.h"
#include <ucx/string.h>
#include <ucx/utils.h>
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char *file;
char *level;
int log_stdout;
int log_stderr;
} LogConfig;
typedef struct {
FILE *file;
uint32_t ref;
} LogFile;
typedef struct {
sstr_t file;
sstr_t format;
LogFile *log;
} AccessLog;
typedef void (*log_writefunc)(
void *cookie,
char *msg,
size_t length);
typedef struct {
log_writefunc write;
void *cookie;
} LogDup;
int init_log_file(LogConfig *cfg);
void log_uninitialized_writeln(
char *str,
size_t len);
void log_file_writeln(
char *str,
size_t len);
sstr_t log_get_prefix(
int level);
void log_add_logdup(LogDup *dup);
void log_remove_logdup(LogDup *dup);
LogFile* get_access_log_file(
sstr_t file);
#ifdef __cplusplus
}
#endif
#endif