Merged 0.7.99 irssi.
[runtime.git] / apps / irssi / src / core / log.h
1 #ifndef __LOG_H
2 #define __LOG_H
3
4 #define LOG_DIR_CREATE_MODE 0700
5
6 enum {
7         LOG_ITEM_TARGET, /* channel, query, .. */
8         LOG_ITEM_WINDOW_REFNUM
9 };
10
11 typedef char *(*COLORIZE_FUNC)(const char *str);
12
13 typedef struct {
14         int type;
15         char *name;
16         char *servertag;
17 } LOG_ITEM_REC;
18
19 typedef struct {
20         char *fname; /* file name, in strftime() format */
21         char *real_fname; /* the current expanded file name */
22         int handle; /* file handle */
23         time_t opened;
24
25         int level; /* log only these levels */
26         GSList *items; /* log only on these items */
27
28         time_t last; /* when last message was written */
29         COLORIZE_FUNC colorizer;
30
31         unsigned int autoopen:1; /* automatically start logging at startup */
32         unsigned int failed:1; /* opening log failed last time */
33         unsigned int temp:1; /* don't save this to config file */
34 } LOG_REC;
35
36 extern GSList *logs;
37
38 /* Create log record - you still need to call log_update() to actually add it
39    into log list */
40 LOG_REC *log_create_rec(const char *fname, int level);
41 void log_update(LOG_REC *log);
42 void log_close(LOG_REC *log);
43 LOG_REC *log_find(const char *fname);
44
45 void log_item_add(LOG_REC *log, int type, const char *name,
46                   const char *servertag);
47 void log_item_destroy(LOG_REC *log, LOG_ITEM_REC *item);
48 LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item,
49                             const char *servertag);
50
51 void log_file_write(const char *server_tag, const char *item, int level,
52                     const char *str, int no_fallbacks);
53 void log_write_rec(LOG_REC *log, const char *str, int level);
54
55 int log_start_logging(LOG_REC *log);
56 void log_stop_logging(LOG_REC *log);
57
58 void log_init(void);
59 void log_deinit(void);
60
61 #endif