Added SILC Thread Queue API
[crypto.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 char *(*COLORIZE_FUNC)(const char *str);
10
11 typedef struct _LOG_REC LOG_REC;
12 typedef struct _LOG_ITEM_REC LOG_ITEM_REC;
13
14 struct _LOG_ITEM_REC {
15         int type;
16         char *name;
17         char *servertag;
18 };
19
20 struct _LOG_REC {
21         char *fname; /* file name, in strftime() format */
22         char *real_fname; /* the current expanded file name */
23         int handle; /* file handle */
24         time_t opened;
25
26         int level; /* log only these levels */
27         GSList *items; /* log only on these items */
28
29         time_t last; /* when last message was written */
30         COLORIZE_FUNC colorizer;
31
32         unsigned int autoopen:1; /* automatically start logging at startup */
33         unsigned int failed:1; /* opening log failed last time */
34         unsigned int temp:1; /* don't save this to config file */
35 };
36
37 extern GSList *logs;
38
39 /* Create log record - you still need to call log_update() to actually add it
40    into log list */
41 LOG_REC *log_create_rec(const char *fname, int level);
42 void log_update(LOG_REC *log);
43 void log_close(LOG_REC *log);
44 LOG_REC *log_find(const char *fname);
45
46 void log_item_add(LOG_REC *log, int type, const char *name,
47                   const char *servertag);
48 void log_item_destroy(LOG_REC *log, LOG_ITEM_REC *item);
49 LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item,
50                             const char *servertag);
51
52 void log_file_write(const char *server_tag, const char *item, int level,
53                     const char *str, int no_fallbacks);
54 void log_write_rec(LOG_REC *log, const char *str, int level);
55
56 int log_start_logging(LOG_REC *log);
57 void log_stop_logging(LOG_REC *log);
58
59 void log_init(void);
60 void log_deinit(void);
61
62 #endif