protected void logStartSummary()

in core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java [2629:2782]


    protected void logStartSummary() {
        // supervising route controller should do their own startup log summary
        boolean supervised = getRouteController().isSupervising();
        if (!supervised && startupSummaryLevel != StartupSummaryLevel.Oneline && startupSummaryLevel != StartupSummaryLevel.Off
                && LOG.isInfoEnabled()) {
            int started = 0;
            int total = 0;
            int kamelets = 0;
            int templates = 0;
            int rests = 0;
            int disabled = 0;
            boolean registerKamelets = false;
            boolean registerTemplates = true;
            ManagementStrategy ms = getManagementStrategy();
            if (ms != null && ms.getManagementAgent() != null) {
                registerKamelets = ms.getManagementAgent().getRegisterRoutesCreateByKamelet();
                registerTemplates = ms.getManagementAgent().getRegisterRoutesCreateByTemplate();
            }
            List<String> lines = new ArrayList<>();
            List<String> configs = new ArrayList<>();
            routeStartupOrder.sort(Comparator.comparingInt(RouteStartupOrder::getStartupOrder));
            for (RouteStartupOrder order : routeStartupOrder) {
                total++;
                String id = order.getRoute().getRouteId();
                String status = getRouteStatus(id).name();
                if (order.getRoute().isCreatedByKamelet()) {
                    kamelets++;
                } else if (order.getRoute().isCreatedByRouteTemplate()) {
                    templates++;
                } else if (order.getRoute().isCreatedByRestDsl()) {
                    rests++;
                }
                boolean skip = (!registerKamelets && order.getRoute().isCreatedByKamelet())
                        || (!registerTemplates && order.getRoute().isCreatedByRouteTemplate());
                if (!skip && ServiceStatus.Started.name().equals(status)) {
                    started++;
                }

                // use basic endpoint uri to not log verbose details or potential sensitive data
                String uri = order.getRoute().getEndpoint().getEndpointBaseUri();
                uri = URISupport.sanitizeUri(uri);
                String loc = order.getRoute().getSourceLocationShort();
                if (startupSummaryLevel == StartupSummaryLevel.Verbose && loc != null) {
                    lines.add(String.format("    %s %s (%s) (source: %s)", status, id, uri, loc));
                } else {
                    if (!skip) {
                        lines.add(String.format("    %s %s (%s)", status, id, uri));
                    }
                }
                String cid = order.getRoute().getConfigurationId();
                if (cid != null) {
                    configs.add(String.format("    %s (%s)", id, cid));
                }
            }
            for (Route route : routes) {
                if (!route.isAutoStartup()) {
                    total++;
                    disabled++;
                    String id = route.getRouteId();
                    String status = getRouteStatus(id).name();
                    if (ServiceStatus.Stopped.name().equals(status)) {
                        status = "Disabled";
                    }
                    if (route.isCreatedByKamelet()) {
                        kamelets++;
                    } else if (route.isCreatedByRouteTemplate()) {
                        templates++;
                    } else if (route.isCreatedByRestDsl()) {
                        rests++;
                    }
                    boolean skip = (!registerKamelets && route.isCreatedByKamelet())
                            || (!registerTemplates && route.isCreatedByRouteTemplate());
                    // use basic endpoint uri to not log verbose details or potential sensitive data
                    String uri = route.getEndpoint().getEndpointBaseUri();
                    uri = URISupport.sanitizeUri(uri);
                    String loc = route.getSourceLocationShort();
                    if (startupSummaryLevel == StartupSummaryLevel.Verbose && loc != null) {
                        lines.add(String.format("    %s %s (%s) (source: %s)", status, id, uri, loc));
                    } else {
                        if (!skip) {
                            lines.add(String.format("    %s %s (%s)", status, id, uri));
                        }
                    }

                    String cid = route.getConfigurationId();
                    if (cid != null) {
                        configs.add(String.format("    %s (%s)", id, cid));
                    }
                }
            }
            int newTotal = total;
            if (!registerKamelets) {
                newTotal -= kamelets;
            }
            if (!registerTemplates) {
                newTotal -= templates;
            }
            StringJoiner sj = new StringJoiner(" ");
            sj.add("total:" + newTotal);
            if (total != started) {
                sj.add("started:" + started);
            }
            if (kamelets > 0) {
                sj.add("kamelets:" + kamelets);
            }
            if (templates > 0) {
                sj.add("templates:" + templates);
            }
            if (rests > 0) {
                sj.add("rest-dsl:" + rests);
            }
            if (disabled > 0) {
                sj.add("disabled:" + disabled);
            }
            LOG.info("Routes startup ({})", sj);
            // if we are default/verbose then log each route line
            if (startupSummaryLevel == StartupSummaryLevel.Default || startupSummaryLevel == StartupSummaryLevel.Verbose) {
                for (String line : lines) {
                    LOG.info(line);
                }
                if (startupSummaryLevel == StartupSummaryLevel.Verbose && !configs.isEmpty()) {
                    LOG.info("Routes configuration:");
                    for (String line : configs) {
                        LOG.info(line);
                    }
                }
            }
        }

        if (startupSummaryLevel != StartupSummaryLevel.Off && LOG.isInfoEnabled()) {
            long taken = stopWatch.taken();
            long max = buildTaken + initTaken + taken;
            String total = TimeUtils.printDuration(max, true);
            String start = TimeUtils.printDuration(taken, true);
            String init = TimeUtils.printDuration(initTaken, true);
            String built = TimeUtils.printDuration(buildTaken, true);
            String boot = null;
            Clock bc = getClock().get(ContextEvents.BOOT);
            if (bc != null) {
                // calculate boot time as time before camel is starting
                long delta = bc.elapsed() - max;
                if (delta > 0) {
                    boot = TimeUtils.printDuration(delta, true);
                }
            }
            String msg = String.format("Apache Camel %s (%s) started in %s (build:%s init:%s start:%s", getVersion(),
                    camelContextExtension.getName(), total, built, init, start);
            if (boot != null) {
                msg += " boot:" + boot;
            }
            msg += ")";
            LOG.info(msg);
        }
    }