MCPcopy Create free account
hub / github.com/SIPp/sipp / _screen_error

Function _screen_error

src/logger.cpp:431–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429}
430
431static void _screen_error(int fatal, bool use_errno, int error, const char *fmt, va_list ap)
432{
433 static unsigned long long count = 0;
434 struct timeval currentTime;
435
436 CStat::globalStat(fatal ? CStat::E_FATAL_ERRORS : CStat::E_WARNING);
437
438 GET_TIME (&currentTime);
439
440 const std::size_t bufSize = sizeof(screen_last_error) / sizeof(screen_last_error[0]);
441 const char* const bufEnd = &screen_last_error[bufSize];
442 char* c = screen_last_error;
443 _advance(c, snprintf(c, bufEnd - c, "%s: ", CStat::formatTime(&currentTime, rfc3339)));
444 if (c < bufEnd) {
445 _advance(c, vsnprintf(c, bufEnd - c, fmt, ap));
446 }
447 if (use_errno && c < bufEnd) {
448 _advance(c, snprintf(c, bufEnd - c, ", errno = %d (%s)", error, strerror(error)));
449 }
450 total_errors++;
451
452 if (!error_lfi.fptr && print_all_responses) {
453 rotate_errorf();
454 if (error_lfi.fptr) {
455 fprintf(error_lfi.fptr, "The following events occurred:\n");
456 fflush(error_lfi.fptr);
457 } else {
458 if (c < bufEnd) {
459 _advance(c, snprintf(c, bufEnd - c, "Unable to create '%s': %s.\n",
460 screen_logfile, strerror(errno)));
461 }
462 sipp_exit(EXIT_FATAL_ERROR, 0, 0);
463 }
464 }
465
466 if (error_lfi.fptr) {
467 count += fprintf(error_lfi.fptr, "%s\n", screen_last_error);
468 fflush(error_lfi.fptr);
469 if (ringbuffer_size && count > ringbuffer_size) {
470 rotate_errorf();
471 count = 0;
472 }
473 if (max_log_size && count > max_log_size) {
474 print_all_responses = 0;
475 if (error_lfi.fptr) {
476 fflush(error_lfi.fptr);
477 fclose(error_lfi.fptr);
478 error_lfi.fptr = nullptr;
479 error_lfi.overwrite = false;
480 }
481 }
482 } else if (fatal) {
483 fprintf(stderr, "%s\n", screen_last_error);
484 fflush(stderr);
485 }
486
487 if (fatal) {
488 if (error == EADDRINUSE) {

Callers 4

ERRORFunction · 0.85
ERROR_NOFunction · 0.85
WARNINGFunction · 0.85
WARNING_NOFunction · 0.85

Calls 3

_advanceFunction · 0.85
rotate_errorfFunction · 0.85
sipp_exitFunction · 0.70

Tested by

no test coverage detected