#ifndef LOG_H
#define LOG_H
#include "../public/nsapi.h"
#include <cx/string.h>
#include <cx/utils.h>
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const char *file;
const char *level;
int log_stdout;
int log_stderr;
} LogConfig;
typedef struct {
FILE *file;
uint32_t ref;
} LogFile;
typedef struct {
cxmutstr file;
cxmutstr 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_logging(
void);
int init_log_file(LogConfig *cfg);
void log_uninitialized_writeln(
char *str,
size_t len);
void log_file_writeln(
char *str,
size_t len);
cxmutstr log_get_prefix(
int level);
cxmutstr log_get_prefix_str(
const char *level);
void log_add_logdup(LogDup *dup);
void log_remove_logdup(LogDup *dup);
LogFile* get_access_log_file(cxstring file);
#ifdef __cplusplus
}
#endif
#endif