258{
259 int level;
260 int current_queue_limit, current_over_threshold_queue_limit;
261 unsigned int x, custom = 1000, warning = 200,
error = 200;
262 struct timeval start,
end;
263 int elapsed;
264 char tmppath[] = "/tmp/asterisk_logger_queue.XXXXXX";
265 int fd;
266
267 switch (cmd) {
269 e->
command =
"logger test queue over threshold";
271 "Usage: logger test queue over threshold\n"
272 "";
276 }
277
278 fd = mkstemp(tmppath);
279 if (fd < 0) {
280 ast_cli(
a->fd,
"Test: Failed, could not create temporary log file '%s'.\n", tmppath);
282 }
283
285 if (level < 0) {
286 ast_cli(
a->fd,
"Test: Failed, could not register level 'queuetest'.\n");
288 }
289 ast_cli(
a->fd,
"Test: got level %d for 'queuetest'.\n", level);
290
292 ast_cli(
a->fd,
"Test: Unable to create logger channel '%s'\n", tmppath);
294 }
295
297 ast_cli(
a->fd,
"Test: Current queue limit: %d. Setting to 10 for test.\n", current_queue_limit);
299
301 ast_cli(
a->fd,
"Test: Current over threshold queue limit: %d. Setting to 10 for test.\n", current_over_threshold_queue_limit);
303
304 ast_cli(
a->fd,
"Test: You should see SOME 'exceeded', 'resumed', 'discarded', and WARNING/ERROR "
305 "messages after the test is completed. How many is dependent on system resources.\n");
306
308 for (x = 0; x < custom; x++) {
310 }
311 for (; x < custom + warning; x++) {
313 }
314 for (; x < custom + warning +
error; x++) {
316 }
319 ast_cli(
a->fd,
"Test: %d messages in %f seconds.\n", x, (
float) elapsed / 1000);
320 ast_cli(
a->fd,
"Test: Completed. Resetting queue limit to %d and over threshold limit to %d.\n",
321 current_queue_limit, current_over_threshold_queue_limit);
324
326
329 close(fd);
330 unlink(tmppath);
331
333}
int ast_logger_get_queue_limit(void)
Get the maximum number of messages allowed in the processing queue.
int ast_logger_create_channel(const char *log_channel, const char *components)
Create a log channel.
int ast_logger_remove_channel(const char *log_channel)
Delete the specified log channel.
void ast_logger_set_queue_limit(int queue_limit)
Set the maximum number of messages allowed in the processing queue.
int ast_logger_get_over_threshold_queue_limit(void)
Get the over threshold maximum number of messages allowed in the processing queue.
void ast_logger_set_over_threshold_queue_limit(int limit)
Set the threshold for the maximum number of WARNING/ERROR messages allowed in the processing queue th...
int error(const char *format,...)