MCPcopy Create free account
hub / github.com/apache/trafficserver / my_exit

Function my_exit

src/traffic_logstats/logstats.cc:2283–2394  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Little wrapper around exit, to allow us to exit gracefully

Source from the content-addressed store, hash-verified

2281///////////////////////////////////////////////////////////////////////////////
2282// Little wrapper around exit, to allow us to exit gracefully
2283void
2284my_exit(const ExitStatus &status)
2285{
2286 vector<OriginPair> vec;
2287 bool first = true;
2288 int max_origins;
2289
2290 // Special case for URLs output.
2291 if (urls) {
2292 urls->dump(cl.as_object);
2293 if (cl.as_object) {
2294 std::cout << "}" << std::endl;
2295 } else {
2296 std::cout << "]" << std::endl;
2297 }
2298 ::exit(status.level);
2299 }
2300
2301 if (cl.json) {
2302 // TODO: produce output
2303 } else {
2304 switch (status.level) {
2305 case EXIT_OK:
2306 break;
2307 case EXIT_WARNING:
2308 std::cout << "warning: " << status.notice << std::endl;
2309 break;
2310 case EXIT_CRITICAL:
2311 std::cout << "critical: " << status.notice << std::endl;
2312 ::exit(status.level);
2313 break;
2314 case EXIT_UNKNOWN:
2315 std::cout << "unknown: " << status.notice << std::endl;
2316 ::exit(status.level);
2317 break;
2318 }
2319 }
2320
2321 if (!origins.empty()) {
2322 // Sort the Origins by 'traffic'
2323 for (OriginStorage::iterator i = origins.begin(); i != origins.end(); i++) {
2324 if (use_origin(i->second)) {
2325 vec.push_back(*i);
2326 }
2327 }
2328 sort(vec.begin(), vec.end());
2329
2330 if (!cl.json) {
2331 // Produce a nice summary first
2332 format_center("Traffic summary");
2333 std::cout << std::left << std::setw(33) << "Origin Server";
2334 std::cout << std::right << std::setw(15) << "Hits";
2335 std::cout << std::right << std::setw(15) << "Misses";
2336 std::cout << std::right << std::setw(15) << "Errors" << std::endl;
2337 std::cout << std::setw(cl.line_len) << std::setfill('-') << '-' << std::setfill(' ') << std::endl;
2338
2339 max_origins = cl.max_origins > 0 ? cl.max_origins : INT_MAX;
2340 for (vector<OriginPair>::iterator i = vec.begin(); (i != vec.end()) && (max_origins > 0); ++i, --max_origins) {

Callers 1

mainFunction · 0.70

Calls 9

use_originFunction · 0.85
format_centerFunction · 0.85
format_intFunction · 0.85
print_detail_statsFunction · 0.85
dumpMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected