Search in sources :

Example 1 with AppLog

use of com.haulmont.cuba.web.log.AppLog in project cuba by cuba-platform.

the class App method init.

/**
 * Called when <em>the first</em> UI of the session is initialized.
 */
protected void init(Locale requestLocale) {
    VaadinSession vSession = VaadinSession.getCurrent();
    vSession.setAttribute(App.class, this);
    vSession.setLocale(messageTools.getDefaultLocale());
    // set root error handler for all session
    vSession.setErrorHandler(event -> {
        try {
            getExceptionHandlers().handle(event);
            getAppLog().log(event);
        } catch (Throwable e) {
            log.error("Error handling exception\nOriginal exception:\n{}\nException in handlers:\n{}", ExceptionUtils.getStackTrace(event.getThrowable()), ExceptionUtils.getStackTrace(e));
        }
    });
    log.debug("Initializing application");
    appLog = new AppLog(webConfig.getAppLogMaxItemsCount(), beanLocator.get(TimeSource.NAME));
    connection = createConnection();
    exceptionHandlers = new ExceptionHandlers(this, beanLocator);
    cookies = new AppCookies();
    themeConstants = loadTheme();
    // get default locale from config
    Locale targetLocale = resolveLocale(requestLocale);
    setLocale(targetLocale);
}
Also used : VaadinSession(com.vaadin.server.VaadinSession) ExceptionHandlers(com.haulmont.cuba.web.exception.ExceptionHandlers) AppLog(com.haulmont.cuba.web.log.AppLog)

Aggregations

ExceptionHandlers (com.haulmont.cuba.web.exception.ExceptionHandlers)1 AppLog (com.haulmont.cuba.web.log.AppLog)1 VaadinSession (com.vaadin.server.VaadinSession)1