Skip to content

Commit

Permalink
Quiet down logs for deployment (#8471)
Browse files Browse the repository at this point in the history
Removes highlighting blocks, extra whitespace and changes output block
about application start up to a oneliner.

Fixes #8404, 8395
Related to #8104
  • Loading branch information
pleku authored Jun 1, 2020
1 parent 17d3b94 commit 6e4b46b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,34 @@
public class DefaultDeploymentConfiguration
extends PropertyDeploymentConfiguration {

private static final String SEPARATOR = "\n=======================================================================";
private static final String HEADER = "\n=================== Vaadin DeploymentConfiguration ====================\n";
public static final String NOT_PRODUCTION_MODE_INFO = "\nVaadin is running in DEBUG MODE.\n"
+ "When deploying application for production, remember to disable debug features. See more from https://vaadin.com/docs/";

public static final String NOT_PRODUCTION_MODE_INFO = " Vaadin is running in DEBUG MODE.\n"
+ " When deploying application for production, remember to disable debug features. See more from https://vaadin.com/docs/";
public static final String NOT_PRODUCTION_MODE_WARNING = "\nWARNING: Vaadin is running in DEBUG MODE with debug features enabled, but with a prebuild frontend bundle (production ready).\n"
+ "When deploying application for production, disable debug features by enabling production mode!\n"
+ "See more from https://vaadin.com/docs/v14/flow/production/tutorial-production-mode-basic.html";

public static final String NOT_PRODUCTION_MODE_WARNING = " WARNING: Vaadin is running in DEBUG MODE with debug features enabled, but with a prebuild frontend bundle (production ready).\n"
+ " When deploying application for production, disable debug features by enabling production mode!\n"
+ " See more from https://vaadin.com/docs/v14/flow/production/tutorial-production-mode-basic.html";

public static final String WARNING_V14_BOOTSTRAP = " Using deprecated Vaadin 14 bootstrap mode.\n"
+ " Client-side views written in TypeScript are not supported. Vaadin 15+ enables client-side and server-side views.\n"
+ " See https://vaadin.com/docs/v15/flow/typescript/starting-the-app.html for more information.";
public static final String WARNING_V14_BOOTSTRAP = "Using deprecated Vaadin 14 bootstrap mode.\n"
+ "Client-side views written in TypeScript are not supported. Vaadin 15+ enables client-side and server-side views.\n"
+ "See https://vaadin.com/docs/v15/flow/typescript/starting-the-app.html for more information.";

// not a warning anymore, but keeping variable name to avoid breaking anything
public static final String WARNING_V15_BOOTSTRAP = "%n Using Vaadin 15+ bootstrap mode.%n %s%n %s";
public static final String WARNING_V15_BOOTSTRAP = "Using Vaadin 15+ bootstrap mode.%n %s%n %s";

private static final String DEPLOYMENT_WARNINGS = " Following issues were discovered with deployment configuration:";
private static final String DEPLOYMENT_WARNINGS = "Following issues were discovered with deployment configuration:";

public static final String WARNING_XSRF_PROTECTION_DISABLED = " WARNING: Cross-site request forgery protection is disabled!";
public static final String WARNING_XSRF_PROTECTION_DISABLED = "WARNING: Cross-site request forgery protection is disabled!";

public static final String WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC = " WARNING: heartbeatInterval has been set to a non integer value."
public static final String WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC = "WARNING: heartbeatInterval has been set to a non integer value."
+ "\n The default of 5min will be used.";

public static final String WARNING_PUSH_MODE_NOT_RECOGNIZED = " WARNING: pushMode has been set to an unrecognized value.\n"
+ " The permitted values are \"disabled\", \"manual\",\n"
+ " and \"automatic\". The default of \"disabled\" will be used.";
public static final String WARNING_PUSH_MODE_NOT_RECOGNIZED = "WARNING: pushMode has been set to an unrecognized value.\n"
+ "The permitted values are \"disabled\", \"manual\",\n"
+ "and \"automatic\". The default of \"disabled\" will be used.";

private static final String INDEX_NOT_FOUND = " '%s' is not found from '%s'.%n"
+ " Generating a default one in '%s%s'. "
+ " Move it to the '%s' folder if you want to customize it.";
private static final String INDEX_NOT_FOUND = "'%s' is not found from '%s'.%n"
+ "Generating a default one in '%s%s'. "
+ "Move it to the '%s' folder if you want to customize it.";

/**
* Default value for {@link #getHeartbeatInterval()} = {@value} .
Expand Down Expand Up @@ -159,18 +156,13 @@ private void logMessages() {
Logger logger = LoggerFactory.getLogger(getClass().getName());

if (!warnings.isEmpty()) {
warnings.add(0, HEADER);
warnings.add(1, DEPLOYMENT_WARNINGS);
warnings.add("\n");
warnings.add(0, DEPLOYMENT_WARNINGS);
// merging info messages to warnings for now
warnings.addAll(info);
warnings.add(SEPARATOR);
if (logger.isWarnEnabled()) {
logger.warn(String.join("\n", warnings));
}
} else if (!info.isEmpty()) {
info.add(0, HEADER);
info.add(SEPARATOR);
if (logger.isInfoEnabled()) {
logger.info(String.join("\n", info));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
*/
public class ServletDeployer implements ServletContextListener {
private static final String SKIPPING_AUTOMATIC_SERVLET_REGISTRATION_BECAUSE = "Skipping automatic servlet registration because";
private static final String SEPARATOR = "=======================================================================";

private enum VaadinServletCreation {
NO_CREATION, SERVLET_EXISTS, SERVLET_CREATED;
Expand Down Expand Up @@ -262,12 +261,11 @@ private void logServletCreation(VaadinServletCreation servletCreation,
}

/**
* Prints to sysout a notification to the user that the application is to be
* opened in the browser.
* Prints to sysout a notification to the user that the application has been deployed.
* <p>
* This method is public so that it can be called in add-ons that map
* servlet automatically but don't use this class for that.
*
*
* @param servletContext
* the deployed servlet context
* @param servletAutomaticallyCreated
Expand All @@ -282,16 +280,14 @@ public static void logAppStartupToConsole(ServletContext servletContext,
String contextPath = servletContext.getContextPath();
contextPath = contextPath.isEmpty() ? "/" : contextPath;

String url = String.format("http://localhost:8080%s", contextPath);
FrontendUtils.console(FrontendUtils.BRIGHT_BLUE, String.format(
"%n%s%n%n Vaadin application has started in DEBUG MODE and is available by opening %s in the browser.%n%n NOTE: the server HTTP port may vary - see server log output.%n%n%s%n",
SEPARATOR, url, SEPARATOR));
"Vaadin application has been deployed and started to the context path \"%s\".%n",
contextPath));
} else {
// if the user has mapped their own servlet, they will know where to
// find it
FrontendUtils.console(FrontendUtils.BRIGHT_BLUE, String.format(
"%n%s%n%nVaadin application has started in DEBUG MODE and is available in the browser.%n%n%s%n",
SEPARATOR, SEPARATOR));
"Vaadin application has been deployed and started.%n"));
}
}

Expand Down

0 comments on commit 6e4b46b

Please sign in to comment.