2000-04-26 04:03:38 -04:00
|
|
|
#ifndef __LOG_H
|
|
|
|
#define __LOG_H
|
|
|
|
|
2001-10-31 10:18:18 -05:00
|
|
|
#define LOG_DIR_CREATE_MODE 0700
|
2001-10-22 17:26:58 -04:00
|
|
|
|
2000-10-17 19:37:21 -04:00
|
|
|
enum {
|
|
|
|
LOG_ITEM_TARGET, /* channel, query, .. */
|
|
|
|
LOG_ITEM_WINDOW_REFNUM
|
|
|
|
};
|
|
|
|
|
2001-08-13 09:51:49 -04:00
|
|
|
typedef char *(*COLORIZE_FUNC)(const char *str);
|
|
|
|
|
2000-10-17 19:37:21 -04:00
|
|
|
typedef struct {
|
|
|
|
int type;
|
|
|
|
char *name;
|
|
|
|
char *servertag;
|
|
|
|
} LOG_ITEM_REC;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
typedef struct {
|
2000-08-11 18:07:42 -04:00
|
|
|
char *fname; /* file name, in strftime() format */
|
|
|
|
char *real_fname; /* the current expanded file name */
|
2000-04-26 04:03:38 -04:00
|
|
|
int handle; /* file handle */
|
|
|
|
time_t opened;
|
|
|
|
|
|
|
|
int level; /* log only these levels */
|
2000-10-17 19:37:21 -04:00
|
|
|
GSList *items; /* log only on these items */
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
time_t last; /* when last message was written */
|
2001-08-13 09:51:49 -04:00
|
|
|
COLORIZE_FUNC colorizer;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-23 16:40:07 -05:00
|
|
|
unsigned int autoopen:1; /* automatically start logging at startup */
|
|
|
|
unsigned int failed:1; /* opening log failed last time */
|
|
|
|
unsigned int temp:1; /* don't save this to config file */
|
2000-04-26 04:03:38 -04:00
|
|
|
} LOG_REC;
|
|
|
|
|
|
|
|
extern GSList *logs;
|
|
|
|
|
|
|
|
/* Create log record - you still need to call log_update() to actually add it
|
|
|
|
into log list */
|
2000-10-17 19:37:21 -04:00
|
|
|
LOG_REC *log_create_rec(const char *fname, int level);
|
2000-04-26 04:03:38 -04:00
|
|
|
void log_update(LOG_REC *log);
|
|
|
|
void log_close(LOG_REC *log);
|
|
|
|
LOG_REC *log_find(const char *fname);
|
|
|
|
|
2000-10-17 19:37:21 -04:00
|
|
|
void log_item_add(LOG_REC *log, int type, const char *name,
|
2001-02-17 14:44:22 -05:00
|
|
|
const char *servertag);
|
2000-10-17 19:37:21 -04:00
|
|
|
void log_item_destroy(LOG_REC *log, LOG_ITEM_REC *item);
|
|
|
|
LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item,
|
2001-02-17 14:44:22 -05:00
|
|
|
const char *servertag);
|
2000-10-17 19:37:21 -04:00
|
|
|
|
2000-10-27 23:01:11 -04:00
|
|
|
void log_file_write(SERVER_REC *server, const char *item, int level,
|
|
|
|
const char *str, int no_fallbacks);
|
2001-02-17 07:08:31 -05:00
|
|
|
void log_write_rec(LOG_REC *log, const char *str, int level);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
int log_start_logging(LOG_REC *log);
|
|
|
|
void log_stop_logging(LOG_REC *log);
|
|
|
|
|
|
|
|
void log_init(void);
|
|
|
|
void log_deinit(void);
|
|
|
|
|
|
|
|
#endif
|