Mercurial > people > jerboaa > thermostat-1.4-setup-integration
changeset 1716:86cd8bae1a95
Make bash completion independent of configured log level.
Reviewed-by: omajid
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2015-July/014939.html
PR2566
author | Severin Gehwolf <sgehwolf@redhat.com> |
---|---|
date | Tue, 28 Jul 2015 17:14:09 +0200 |
parents | 23805e2f39be |
children | f6eb70a4744f |
files | common/core/src/main/java/com/redhat/thermostat/common/utils/LoggingUtils.java distribution/config/bash-complete-logging.properties distribution/pom.xml distribution/scripts/thermostat-completion |
diffstat | 4 files changed, 49 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/utils/LoggingUtils.java Thu Jul 23 14:24:35 2015 +0200 +++ b/common/core/src/main/java/com/redhat/thermostat/common/utils/LoggingUtils.java Tue Jul 28 17:14:09 2015 +0200 @@ -59,6 +59,8 @@ * properties file that sets an appropriate value for ".level" */ public final class LoggingUtils { + + private static final String JUL_CONFIG_PROP_FILE = "java.util.logging.config.file"; /* * Custom log level, intended for use with Thermostat's internal performance @@ -168,7 +170,10 @@ // Set basic logger configs. Note that this does NOT add handlers. // It also resets() handlers. I.e. removes any existing handlers // for the root logger. - LogManager.getLogManager().readConfiguration(fis); + // Only erase any log config if no log config property file is set + if (null == System.getProperty(JUL_CONFIG_PROP_FILE)) { + LogManager.getLogManager().readConfiguration(fis); + } } catch (SecurityException | IOException e) { throw new InvalidConfigurationException(t.localize(LocaleResources.LOGGING_PROPERTIES_ISSUE), e); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/config/bash-complete-logging.properties Tue Jul 28 17:14:09 2015 +0200 @@ -0,0 +1,39 @@ +# Copyright 2012-2015 Red Hat, Inc. +# +# This file is part of Thermostat. +# +# Thermostat is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 2, or (at your +# option) any later version. +# +# Thermostat is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Thermostat; see the file COPYING. If not see +# <http://www.gnu.org/licenses/>. +# +# Linking this code with other modules is making a combined work +# based on this code. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this code give +# you permission to link this code with independent modules to +# produce an executable, regardless of the license terms of these +# independent modules, and to copy and distribute the resulting +# executable under terms of your choice, provided that you also +# meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module +# which is not derived from or based on this code. If you modify +# this code, you may extend this exception to your version of the +# library, but you are not obligated to do so. If you do not wish +# to do so, delete this exception statement from your version. + +################################################################### +# Disables all Thermostat jul-logging. It is used by the +# bash-completion functionality. +################################################################### +com.redhat.thermostat.level=OFF
--- a/distribution/pom.xml Thu Jul 23 14:24:35 2015 +0200 +++ b/distribution/pom.xml Tue Jul 28 17:14:09 2015 +0200 @@ -176,6 +176,7 @@ <include>devsetup.input</include> <include>db.properties</include> <include>logging.properties</include> + <include>bash-complete-logging.properties</include> <include>osgi-export.properties</include> <include>commands/*.properties</include> </includes>
--- a/distribution/scripts/thermostat-completion Thu Jul 23 14:24:35 2015 +0200 +++ b/distribution/scripts/thermostat-completion Tue Jul 28 17:14:09 2015 +0200 @@ -2,14 +2,15 @@ _thermostat() { local cur prev opts base - local thermostat_install_dir + local thermostat_install_dir thermostat_logging_opts thermostat_install_dir="${thermostat.home}" + thermostat_logging_opts="-J-Djava.util.logging.config.file=${thermostat_install_dir}/etc/bash-complete-logging.properties" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" # Thermostat Options - opts="$(${thermostat_install_dir}/bin/thermostat help | cut -d " " -f 2 | tr '\n' ' ' | cut -d " " -f 3-)" + opts="$(${thermostat_install_dir}/bin/thermostat ${thermostat_logging_opts} help | cut -d " " -f 2 | tr '\n' ' ' | cut -d " " -f 3-)" COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0