Search in sources :

Example 1 with SystemVariablesResolver

use of org.jkiss.dbeaver.utils.SystemVariablesResolver in project dbeaver by dbeaver.

the class DBeaverApplication method initDebugWriter.

private void initDebugWriter() {
    DBPPreferenceStore preferenceStore = DBeaverCore.getGlobalPreferenceStore();
    if (!preferenceStore.getBoolean(DBeaverPreferences.LOGS_DEBUG_ENABLED)) {
        return;
    }
    String logLocation = preferenceStore.getString(DBeaverPreferences.LOGS_DEBUG_LOCATION);
    if (CommonUtils.isEmpty(logLocation)) {
        // $NON-NLS-1$
        logLocation = new File(GeneralUtils.getMetadataFolder(), "dbeaver-debug.log").getAbsolutePath();
    }
    logLocation = GeneralUtils.replaceVariables(logLocation, new SystemVariablesResolver());
    File debugLogFile = new File(logLocation);
    if (debugLogFile.exists()) {
        if (!debugLogFile.delete()) {
            // $NON-NLS-1$
            System.err.println("Can't delete debug log file");
            return;
        }
    }
    try {
        debugWriter = new FileOutputStream(debugLogFile);
        oldSystemOut = System.out;
        oldSystemErr = System.err;
        System.setOut(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemOut)));
        System.setErr(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemErr)));
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}
Also used : SystemVariablesResolver(org.jkiss.dbeaver.utils.SystemVariablesResolver) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 2 with SystemVariablesResolver

use of org.jkiss.dbeaver.utils.SystemVariablesResolver in project dbeaver by serge-rider.

the class DBeaverApplication method initDebugWriter.

private void initDebugWriter() {
    DBPPreferenceStore preferenceStore = DBWorkbench.getPlatform().getPreferenceStore();
    if (!preferenceStore.getBoolean(DBeaverPreferences.LOGS_DEBUG_ENABLED)) {
        return;
    }
    String logLocation = preferenceStore.getString(DBeaverPreferences.LOGS_DEBUG_LOCATION);
    if (CommonUtils.isEmpty(logLocation)) {
        // $NON-NLS-1$
        logLocation = new File(GeneralUtils.getMetadataFolder(), DBConstants.DEBUG_LOG_FILE_NAME).getAbsolutePath();
    }
    logLocation = GeneralUtils.replaceVariables(logLocation, new SystemVariablesResolver());
    File debugLogFile = new File(logLocation);
    if (debugLogFile.exists()) {
        if (!debugLogFile.delete()) {
            // $NON-NLS-1$
            System.err.println("Can't delete debug log file");
            return;
        }
    }
    try {
        debugWriter = new FileOutputStream(debugLogFile);
        oldSystemOut = System.out;
        oldSystemErr = System.err;
        System.setOut(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemOut)));
        System.setErr(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemErr)));
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}
Also used : SystemVariablesResolver(org.jkiss.dbeaver.utils.SystemVariablesResolver) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 3 with SystemVariablesResolver

use of org.jkiss.dbeaver.utils.SystemVariablesResolver in project dbeaver by dbeaver.

the class DBeaverApplication method initDebugWriter.

private void initDebugWriter() {
    DBPPreferenceStore preferenceStore = DBWorkbench.getPlatform().getPreferenceStore();
    if (!preferenceStore.getBoolean(DBeaverPreferences.LOGS_DEBUG_ENABLED)) {
        return;
    }
    String logLocation = preferenceStore.getString(DBeaverPreferences.LOGS_DEBUG_LOCATION);
    if (CommonUtils.isEmpty(logLocation)) {
        // $NON-NLS-1$
        logLocation = new File(GeneralUtils.getMetadataFolder(), DBConstants.DEBUG_LOG_FILE_NAME).getAbsolutePath();
    }
    logLocation = GeneralUtils.replaceVariables(logLocation, new SystemVariablesResolver());
    File debugLogFile = new File(logLocation);
    if (debugLogFile.exists()) {
        if (!debugLogFile.delete()) {
            // $NON-NLS-1$
            System.err.println("Can't delete debug log file");
            return;
        }
    }
    try {
        debugWriter = new FileOutputStream(debugLogFile);
        oldSystemOut = System.out;
        oldSystemErr = System.err;
        System.setOut(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemOut)));
        System.setErr(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemErr)));
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}
Also used : SystemVariablesResolver(org.jkiss.dbeaver.utils.SystemVariablesResolver) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Aggregations

DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)3 SystemVariablesResolver (org.jkiss.dbeaver.utils.SystemVariablesResolver)3