2017-11-21 23:24:51 -06:00
|
|
|
#ifndef _LOG_H_
|
|
|
|
#define _LOG_H_
|
|
|
|
|
2017-12-06 16:52:33 -06:00
|
|
|
#include <stdio.h>
|
2017-12-15 16:52:26 -06:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2017-12-06 16:52:33 -06:00
|
|
|
|
2017-12-02 13:05:53 -06:00
|
|
|
#define LOG_FILENAME "/tmp/emp.log"
|
|
|
|
|
2017-12-09 15:16:56 -06:00
|
|
|
enum log_errcode {
|
|
|
|
OK = 1,
|
|
|
|
ERR_OOM, // out of memory
|
|
|
|
ERR_OOB, // out of bounds
|
2017-12-15 16:52:26 -06:00
|
|
|
ERR_BADFILE,
|
2017-12-20 17:06:03 -06:00
|
|
|
ERR_BADOPT, // bad option (e.g. from getopt)
|
2017-12-16 22:45:39 -06:00
|
|
|
ERR_GFXINIT, // couldn't initialize graphics
|
2017-12-19 21:50:50 -06:00
|
|
|
ERR_GFXOP, // we couldn't execute a specific graphic operation
|
2017-12-09 15:16:56 -06:00
|
|
|
};
|
|
|
|
|
2018-01-07 15:05:20 -06:00
|
|
|
extern FILE *log_stream();
|
|
|
|
extern int log_close();
|
2017-12-06 16:43:30 -06:00
|
|
|
extern void log_open(FILE *);
|
2017-12-26 16:44:28 -06:00
|
|
|
extern void log_write(int, const char *, ...);
|
2017-11-21 23:24:51 -06:00
|
|
|
|
2017-12-06 21:25:47 -06:00
|
|
|
/*
|
|
|
|
* Here we have a couple of convenience macros that abstracts the log
|
|
|
|
* level number.
|
|
|
|
*/
|
2017-11-21 23:24:51 -06:00
|
|
|
#define log_critical(...) log_write(0, __VA_ARGS__)
|
|
|
|
#define log_error(...) log_write(0, __VA_ARGS__)
|
|
|
|
|
|
|
|
#endif
|