Make MySQL query logging optional

* lib/databases/mysql: Wrap query log configuration in a check for a
ENABLE_QUERY_LOGGING variable.

* stackrc: Add the DATABASE_QUERY_LOGGING variable defaulted to True.

Change-Id: Iddf8538ad0a1e36e2c6944dc70315984026c8245
This commit is contained in:
Jeremy Stanley 2014-01-25 01:10:31 +00:00
parent 9edac54d55
commit c4f47345a5
2 changed files with 20 additions and 12 deletions

View File

@ -87,6 +87,9 @@ function configure_database_mysql {
default-storage-engine = InnoDB" $MY_CONF
fi
if [[ "$DATABASE_QUERY_LOGGING" == "True" ]]; then
echo_summary "Enabling MySQL query logging"
# Turn on slow query log
sudo sed -i '/log.slow.queries/d' $MY_CONF
sudo sed -i -e "/^\[mysqld\]/ a \
@ -102,6 +105,8 @@ long-query-time = 0" $MY_CONF
sudo sed -i -e "/^\[mysqld\]/ a \
log-queries-not-using-indexes" $MY_CONF
fi
restart_service $MYSQL
}

View File

@ -59,6 +59,9 @@ elif [[ -f $RC_DIR/.localrc.auto ]]; then
source $RC_DIR/.localrc.auto
fi
# This can be used to turn database query logging on and off
# (currently only implemented for MySQL backend)
DATABASE_QUERY_LOGGING=$(trueorfalse True $DATABASE_QUERY_LOGGING)
# Repositories
# ------------