1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-21 23:29:16 +00:00
erc-c/include/log.h

41 lines
1.2 KiB
C
Raw Normal View History

2017-11-22 05:24:51 +00:00
#ifndef _LOG_H_
#define _LOG_H_
2017-12-06 22:52:33 +00:00
#include <stdio.h>
2017-12-15 22:52:26 +00:00
#include <string.h>
#include <errno.h>
#include <sys/syslog.h>
2017-12-06 22:52:33 +00:00
#define LOG_FILENAME "/tmp/erc.log"
2017-12-02 19:05:53 +00:00
2017-12-09 21:16:56 +00:00
enum log_errcode {
OK = 1,
ERR_OOM, // out of memory
ERR_OOB, // out of bounds
2017-12-15 22:52:26 +00:00
ERR_BADFILE,
ERR_BADOPT, // bad option (e.g. from getopt)
2018-02-04 06:06:04 +00:00
ERR_INVALID, // invalid operation
ERR_GFXINIT, // couldn't initialize graphics
2017-12-20 03:50:50 +00:00
ERR_GFXOP, // we couldn't execute a specific graphic operation
2017-12-09 21:16:56 +00:00
};
extern FILE *log_stream();
extern int log_close();
2017-12-06 22:43:30 +00:00
extern void log_open(FILE *);
2017-12-26 22:44:28 +00:00
extern void log_write(int, const char *, ...);
2017-11-22 05:24:51 +00:00
2017-12-07 03:25:47 +00:00
/*
* Here we have a couple of convenience macros that abstracts the log
* level number.
*/
#define log_alert(...) log_write(LOG_ALERT, __VA_ARGS__)
#define log_crit(...) log_write(LOG_CRIT, __VA_ARGS__)
#define log_debug(...) log_write(LOG_DEBUG, __VA_ARGS__)
#define log_emerg(...) log_write(LOG_EMERG, __VA_ARGS__)
#define log_err(...) log_write(LOG_ERR, __VA_ARGS__)
#define log_info(...) log_write(LOG_INFO, __VA_ARGS__)
#define log_notice(...) log_write(LOG_NOTICE, __VA_ARGS__)
#define log_warning(...) log_write(LOG_WARNING, __VA_ARGS__)
2017-11-22 05:24:51 +00:00
#endif