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