alertik/log.h

40 lines
949 B
C
Raw Normal View History

2024-07-16 03:47:57 +02:00
/*
* Alertik: a tiny 'syslog' server & notification tool for Mikrotik routers.
* This is free and unencumbered software released into the public domain.
*/
#ifndef LOG_H
#define LOG_H
2024-07-17 03:53:12 +02:00
#include <errno.h>
#include <stdlib.h>
#include <string.h>
2024-07-17 03:53:12 +02:00
#include <sys/types.h>
struct log_event;
2024-07-17 03:34:38 +02:00
2024-07-16 03:47:57 +02:00
/* Uncomment/comment to enable/disable the following settings. */
// #define USE_FILE_AS_LOG /* stdout if commented. */
2024-07-17 03:34:38 +02:00
#define panic_errno(s) \
do {\
log_msg("%s: %s", (s), strerror(errno)); \
exit(EXIT_FAILURE); \
} while(0);
#define panic(...) \
do {\
log_msg(__VA_ARGS__); \
exit(EXIT_FAILURE); \
} while(0);
2024-08-03 22:14:55 +02:00
#define log_errno(s) log_msg("%s: %s", (s), strerror(errno))
2024-07-16 03:47:57 +02:00
#define LOG_FILE "log/log.txt"
extern char *get_formatted_time(time_t time, char *time_str);
extern void print_log_event(struct log_event *ev);
extern void log_msg(const char *fmt, ...);
extern void log_init(void);
#endif /* LOG_H */