comparison ui.c @ 541:44f67ec5e945

Improve logging facilities. Private chats in query windows are now logged separately. A log file directory can be set in configuration. Room log files are always of format room_%d.ext. Log file extension can be set, default is ".log".
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 11 Nov 2012 18:32:42 +0200
parents 658c188101a6
children afb4caf32bdf
comparison
equal deleted inserted replaced
540:658c188101a6 541:44f67ec5e945
116 PDC_set_title("NNChat v" NN_VERSION); 116 PDC_set_title("NNChat v" NN_VERSION);
117 #endif 117 #endif
118 118
119 memset(chatWindows, 0, sizeof(chatWindows)); 119 memset(chatWindows, 0, sizeof(chatWindows));
120 chatWindows[0] = nn_window_new(NULL); 120 chatWindows[0] = nn_window_new(NULL);
121 nn_log_open(chatWindows[0]);
121 currWin = chatWindows[0]; 122 currWin = chatWindows[0];
122 123
123 return TRUE; 124 return TRUE;
124 } 125 }
125 126
164 } 165 }
165 166
166 167
167 BOOL nnwin_open(const char *name, BOOL curwin) 168 BOOL nnwin_open(const char *name, BOOL curwin)
168 { 169 {
170 nn_window_t *res;
169 int i; 171 int i;
170 nn_window_t *res; 172
171 if (name == NULL) 173 if (name == NULL)
172 return FALSE; 174 return FALSE;
173 175
174 if ((res = nn_window_new(name)) == NULL) 176 if ((res = nn_window_new(name)) == NULL)
175 return FALSE; 177 return FALSE;
176 178
179 nn_log_open(res);
180
177 for (i = 1; i < SET_MAX_WINDOWS; i++) 181 for (i = 1; i < SET_MAX_WINDOWS; i++)
178 if (chatWindows[i] == NULL) 182 if (chatWindows[i] == NULL)
179 { 183 {
180 res->num = i; 184 res->num = i;
181 chatWindows[i] = res; 185 chatWindows[i] = res;
182 if (curwin) 186 if (curwin)
183 currWin = res; 187 currWin = res;
184 return TRUE; 188 return TRUE;
185 } 189 }
186 190
187 return FALSE; 191 return FALSE;
188 } 192 }
189 193
190 194
192 { 196 {
193 int i; 197 int i;
194 if (win == NULL) return; 198 if (win == NULL) return;
195 199
196 for (i = 1; i < SET_MAX_WINDOWS; i++) 200 for (i = 1; i < SET_MAX_WINDOWS; i++)
197 { 201 if (chatWindows[i] == win)
198 if (chatWindows[i] == win) 202 {
199 { 203 chatWindows[i] = NULL;
200 chatWindows[i] = NULL; 204 nn_log_close(win);
201 nn_window_free(win); 205 nn_window_free(win);
202 return; 206 return;
203 }
204 } 207 }
205 } 208 }
206 209
207 210
208 static BOOL nnwin_get_color(char const **s, int *col) 211 static BOOL nnwin_get_color(char const **s, int *col)