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