Mercurial > vim
comparison src/channel.c @ 8428:4e22d0e7bfb1 v7.4.1505
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 6 21:50:33 2016 +0100
patch 7.4.1505
Problem: When channel log is enabled get too many "looking for messages"
log entries.
Solution: Only give the message after another message.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 Mar 2016 22:00:04 +0100 |
parents | 5d2c84be23b5 |
children | fed4e19bd884 |
comparison
equal
deleted
inserted
replaced
8427:fd9a8463b059 | 8428:4e22d0e7bfb1 |
---|---|
134 else | 134 else |
135 fprintf(log_fd, "%s: ", what); | 135 fprintf(log_fd, "%s: ", what); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 static int did_log_msg = TRUE; | |
140 | |
139 void | 141 void |
140 ch_log(channel_T *ch, char *msg) | 142 ch_log(channel_T *ch, char *msg) |
141 { | 143 { |
142 if (log_fd != NULL) | 144 if (log_fd != NULL) |
143 { | 145 { |
144 ch_log_lead("", ch); | 146 ch_log_lead("", ch); |
145 fputs(msg, log_fd); | 147 fputs(msg, log_fd); |
146 fputc('\n', log_fd); | 148 fputc('\n', log_fd); |
147 fflush(log_fd); | 149 fflush(log_fd); |
150 did_log_msg = TRUE; | |
148 } | 151 } |
149 } | 152 } |
150 | 153 |
151 static void | 154 static void |
152 ch_logn(channel_T *ch, char *msg, int nr) | 155 ch_logn(channel_T *ch, char *msg, int nr) |
155 { | 158 { |
156 ch_log_lead("", ch); | 159 ch_log_lead("", ch); |
157 fprintf(log_fd, msg, nr); | 160 fprintf(log_fd, msg, nr); |
158 fputc('\n', log_fd); | 161 fputc('\n', log_fd); |
159 fflush(log_fd); | 162 fflush(log_fd); |
163 did_log_msg = TRUE; | |
160 } | 164 } |
161 } | 165 } |
162 | 166 |
163 void | 167 void |
164 ch_logs(channel_T *ch, char *msg, char *name) | 168 ch_logs(channel_T *ch, char *msg, char *name) |
167 { | 171 { |
168 ch_log_lead("", ch); | 172 ch_log_lead("", ch); |
169 fprintf(log_fd, msg, name); | 173 fprintf(log_fd, msg, name); |
170 fputc('\n', log_fd); | 174 fputc('\n', log_fd); |
171 fflush(log_fd); | 175 fflush(log_fd); |
176 did_log_msg = TRUE; | |
172 } | 177 } |
173 } | 178 } |
174 | 179 |
175 static void | 180 static void |
176 ch_logsn(channel_T *ch, char *msg, char *name, int nr) | 181 ch_logsn(channel_T *ch, char *msg, char *name, int nr) |
179 { | 184 { |
180 ch_log_lead("", ch); | 185 ch_log_lead("", ch); |
181 fprintf(log_fd, msg, name, nr); | 186 fprintf(log_fd, msg, name, nr); |
182 fputc('\n', log_fd); | 187 fputc('\n', log_fd); |
183 fflush(log_fd); | 188 fflush(log_fd); |
189 did_log_msg = TRUE; | |
184 } | 190 } |
185 } | 191 } |
186 | 192 |
187 static void | 193 static void |
188 ch_error(channel_T *ch, char *msg) | 194 ch_error(channel_T *ch, char *msg) |
191 { | 197 { |
192 ch_log_lead("ERR ", ch); | 198 ch_log_lead("ERR ", ch); |
193 fputs(msg, log_fd); | 199 fputs(msg, log_fd); |
194 fputc('\n', log_fd); | 200 fputc('\n', log_fd); |
195 fflush(log_fd); | 201 fflush(log_fd); |
202 did_log_msg = TRUE; | |
196 } | 203 } |
197 } | 204 } |
198 | 205 |
199 static void | 206 static void |
200 ch_errorn(channel_T *ch, char *msg, int nr) | 207 ch_errorn(channel_T *ch, char *msg, int nr) |
203 { | 210 { |
204 ch_log_lead("ERR ", ch); | 211 ch_log_lead("ERR ", ch); |
205 fprintf(log_fd, msg, nr); | 212 fprintf(log_fd, msg, nr); |
206 fputc('\n', log_fd); | 213 fputc('\n', log_fd); |
207 fflush(log_fd); | 214 fflush(log_fd); |
215 did_log_msg = TRUE; | |
208 } | 216 } |
209 } | 217 } |
210 | 218 |
211 static void | 219 static void |
212 ch_errors(channel_T *ch, char *msg, char *arg) | 220 ch_errors(channel_T *ch, char *msg, char *arg) |
215 { | 223 { |
216 ch_log_lead("ERR ", ch); | 224 ch_log_lead("ERR ", ch); |
217 fprintf(log_fd, msg, arg); | 225 fprintf(log_fd, msg, arg); |
218 fputc('\n', log_fd); | 226 fputc('\n', log_fd); |
219 fflush(log_fd); | 227 fflush(log_fd); |
228 did_log_msg = TRUE; | |
220 } | 229 } |
221 } | 230 } |
222 | 231 |
223 #ifdef _WIN32 | 232 #ifdef _WIN32 |
224 # undef PERROR | 233 # undef PERROR |
2350 ch_log_lead("SEND ", channel); | 2359 ch_log_lead("SEND ", channel); |
2351 fprintf(log_fd, "'"); | 2360 fprintf(log_fd, "'"); |
2352 ignored = (int)fwrite(buf, len, 1, log_fd); | 2361 ignored = (int)fwrite(buf, len, 1, log_fd); |
2353 fprintf(log_fd, "'\n"); | 2362 fprintf(log_fd, "'\n"); |
2354 fflush(log_fd); | 2363 fflush(log_fd); |
2364 did_log_msg = TRUE; | |
2355 } | 2365 } |
2356 | 2366 |
2357 if (part == PART_SOCK) | 2367 if (part == PART_SOCK) |
2358 res = sock_write(fd, (char *)buf, len); | 2368 res = sock_write(fd, (char *)buf, len); |
2359 else | 2369 else |
2539 channel_T *channel = first_channel; | 2549 channel_T *channel = first_channel; |
2540 int ret = FALSE; | 2550 int ret = FALSE; |
2541 int r; | 2551 int r; |
2542 int part = PART_SOCK; | 2552 int part = PART_SOCK; |
2543 | 2553 |
2544 ch_log(NULL, "looking for messages on channels"); | 2554 /* Only do this message when another message was given, otherwise we get |
2555 * lots of them. */ | |
2556 if (did_log_msg) | |
2557 { | |
2558 ch_log(NULL, "looking for messages on channels"); | |
2559 did_log_msg = FALSE; | |
2560 } | |
2545 while (channel != NULL) | 2561 while (channel != NULL) |
2546 { | 2562 { |
2547 if (channel->ch_refcount == 0 && !channel_still_useful(channel)) | 2563 if (channel->ch_refcount == 0 && !channel_still_useful(channel)) |
2548 { | 2564 { |
2549 /* channel is no longer useful, free it */ | 2565 /* channel is no longer useful, free it */ |