import org.lilie.services.eliot.utils.EliotDataSourceBeanPostProcessor
import org.lilie.services.eliot.utils.JavaMelodySpringPlugin
-
-
class EliotAppPluginGrailsPlugin {
// def xml = new XmlSlurper().parse(new File("pom.xml"))
}
}
-
}
def doWithApplicationContext = {ApplicationContext applicationContext ->
import moniteur.http.MoniteurHttpService
import org.lilie.services.eliot.GormUtils
import org.hibernate.FlushMode
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
/**
* Filtre de securite basic
String descriptionRequete = "controleur=${controllerName}, action=${actionName}, " +
"acteur=${session?.acteur?.idExterne}"
+ if (ConfigurationHolder?.config?.perf?.logsql?.actif) {
+ Rapport.SINGLETON.init(controllerName,actionName)
+ }
+
def confMoniteurs = ConfigurationHolder.config.moniteurs
if (confMoniteurs?.moniteurDatasource?.actif) {
return true
}
- if ((ConfigurationHolder.config.eliot.textes.liaison.debug)&&(controllerName == TEST_CATALOGUE)) {
+ if ((ConfigurationHolder.config.eliot.textes.liaison.debug) && (controllerName == TEST_CATALOGUE)) {
return true
}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook
+
+import org.springframework.beans.factory.config.BeanPostProcessor
+import java.lang.reflect.InvocationHandler
+import java.lang.reflect.Method
+import javax.sql.DataSource
+import java.sql.Connection
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
+import org.lilie.services.eliot.jdbcHook.jdbc.utils.DummyObject
+import org.lilie.services.eliot.jdbcHook.jdbc.EliotConnection
+import org.codehaus.groovy.grails.commons.GrailsApplication
+
+class EliotDataSourceBeanProcessor implements BeanPostProcessor, InvocationHandler {
+
+ private static final NOMDATASOURCE = 'dataSource'
+
+ private DataSource dataSource
+
+ GrailsApplication grailsApplication
+
+ String configPath = "/tmp/logperf/"
+
+ EliotDataSourceBeanProcessor() {
+ System.out.println("Log détaillé SQL actif.")
+ }
+
+ Object postProcessBeforeInitialization(Object bean, String beanName) {
+ return bean
+ }
+
+ Object postProcessAfterInitialization(Object bean, String beanName) {
+
+ if (bean instanceof DataSource && beanName == NOMDATASOURCE) {
+ dataSource = (DataSource) bean
+ Rapport.SINGLETON.configPath = configPath
+ if (grailsApplication) {
+ Rapport.SINGLETON.version = grailsApplication.metadata['app.version']
+ Rapport.SINGLETON.app = grailsApplication.metadata['app.name']
+ }
+ return (DataSource) DummyObject.creeEtImplementeInterfaceSurObjet(this, DataSource)
+ }
+
+ return bean
+
+ }
+
+ Object invoke(Object proxy, Method method, Object[] args) {
+
+ String nomMethode = method.name
+
+ Rapport.SINGLETON.logMethode(proxy, method, args)
+
+ Object resultat = dataSource.invokeMethod(nomMethode, args)
+
+ if (resultat instanceof Connection) {
+ EliotConnection connection = new EliotConnection()
+ resultat = connection.createConnection((Connection) resultat)
+ }
+
+ return resultat
+
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook
+
+import groovy.sql.Sql
+import javax.sql.DataSource
+import org.lilie.services.eliot.utils.SpringUtils
+import org.w3c.dom.Document
+import javax.xml.parsers.DocumentBuilderFactory
+import javax.xml.parsers.DocumentBuilder
+import org.w3c.dom.NodeList
+
+class Requete {
+
+ private static final EXPLAIN = "EXPLAIN "
+ private static final EXPLAIN_XML = EXPLAIN + "(FORMAT XML) "
+ private static final NL = '\n'
+
+ String jdbc = ""
+
+ String sql = ""
+
+ Map<Integer, Object> params = [:]
+
+ public void clear() {
+ sql = ""
+ params.clear()
+ }
+
+ public boolean isExplain() {
+ (sql.indexOf("EXPLAIN") != -1)
+ }
+
+ public void addParam(Integer index, Object value) {
+ params[index] = value
+ }
+
+ public String toString() {
+
+ String resultat = tokenizeSQL(sql) + NL
+
+ params.each {
+ k, v ->
+ resultat = resultat + k + "=" + v.toString() + NL
+ }
+
+ return resultat
+ }
+
+ public String explainXml() {
+
+ String xml = internalExplain(EXPLAIN_XML)
+
+ return xml
+
+ }
+
+ private String internalExplain(String explainCmd) {
+
+ String resultat = ""
+
+ DataSource datasource = (DataSource) SpringUtils.mainContext.getBean("dataSource")
+
+ Sql sqlCode = new Sql(datasource)
+ List<Object> paramsSql = []
+
+ params.sort().each {k, v ->
+ paramsSql << v
+ }
+
+ String sqlExplain = explainCmd + tokenizeSQL(sql)
+
+ try {
+
+ sqlCode.eachRow(sqlExplain, paramsSql) { def reponse ->
+ resultat = tokenizeXML(reponse[0].string)
+ }
+
+ } catch (Exception e) {
+
+ return "ERREUR : " + e.message
+ }
+ sqlCode.close()
+ return resultat
+ }
+
+ private static Document loadXMLFrom(String xml) {
+ InputStream is = new ByteArrayInputStream(xml.getBytes())
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance()
+ DocumentBuilder builder = factory.newDocumentBuilder()
+ Document doc = builder.parse(is)
+ is.close()
+ return doc
+ }
+
+ public String cost(String xml) {
+
+ Document document = loadXMLFrom(xml)
+
+ NodeList nodes = document.getElementsByTagName("Total-Cost")
+
+ if (nodes?.item(0)) {
+ return nodes.item(0).textContent
+ } else {
+ return ""
+ }
+ }
+
+
+ private String tokenizeXML(String xml) {
+
+ String resultat = ""
+ StringTokenizer st = new StringTokenizer(xml)
+
+ while (st.hasMoreTokens()) {
+ String key = st.nextToken()
+ resultat = resultat + key + " "
+ }
+
+ return resultat.trim()
+ }
+
+ private String tokenizeSQL(String sql) {
+
+ String resultat = ""
+ StringTokenizer st = new StringTokenizer(sql)
+
+ while (st.hasMoreTokens()) {
+ String key = st.nextToken()
+ resultat = resultat + key + " "
+ }
+
+ return resultat.trim()
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook.jdbc
+
+import java.lang.reflect.Method
+import java.sql.Connection
+import java.sql.PreparedStatement
+import java.sql.Statement
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
+import java.lang.reflect.InvocationHandler
+import org.lilie.services.eliot.jdbcHook.jdbc.utils.DummyObject
+
+class EliotConnection implements InvocationHandler {
+
+ private static PREPARESTATEMENT = "prepareStatement"
+ private static PREPARECALL = "prepareCall"
+
+ private Connection connection
+
+ public Connection createConnection(Connection connection1) {
+
+ connection = connection1
+
+ return (Connection) DummyObject.creeEtImplementeInterfaceSurObjet(this, Connection)
+
+ }
+
+ Object invoke(Object proxy, Method method, Object[] args) {
+
+ String nomMethode = method.name
+
+ Object resultat = connection.invokeMethod(nomMethode, args)
+
+ if (resultat instanceof PreparedStatement) {
+
+ if (PREPARESTATEMENT.equals(nomMethode) || PREPARECALL.equals(nomMethode)) {
+
+ String sql = (String) args[0]
+
+ EliotPreparedStatement statement = new EliotPreparedStatement(sql: sql)
+ resultat = statement.createStatement((PreparedStatement) resultat)
+
+ } else {
+ println "###### ==>Controler méthode"
+ }
+
+ } else {
+ if (resultat instanceof Statement) {
+
+ EliotStatement statement = new EliotStatement(params: args)
+ resultat = statement.createStatement((Statement) resultat)
+
+ } else{
+ Rapport.SINGLETON.logMethode(proxy, method, args)
+ }
+ }
+
+ return resultat
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook.jdbc
+
+import java.lang.reflect.Method
+import java.sql.PreparedStatement
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
+import java.lang.reflect.InvocationHandler
+import org.lilie.services.eliot.jdbcHook.jdbc.utils.DummyObject
+import org.lilie.services.eliot.jdbcHook.Requete
+
+class EliotPreparedStatement implements InvocationHandler {
+
+ private static final EXECUTEQUERY = "executeQuery"
+ private static final EXECUTEBATCH = "executeBatch"
+ private static final SETOBJECT = "setObject"
+ private static final SETSTRING = "setString"
+ private static final SETBOOLEAN = "setBoolean"
+ private static final SETINT = "setInt"
+ private static final SETTIMESTAMP = "setTimestamp"
+ private static final SETLONG = "setLong"
+ private static final SETNULL = "setNull"
+ private static final SETDATE = "setDate"
+
+ private PreparedStatement statement
+
+ private Requete requete = new Requete(jdbc: "PreparedStatement")
+
+ public void setSql(String value) {
+ requete.sql = value
+ }
+
+ public PreparedStatement createStatement(PreparedStatement statement1) {
+
+ statement = statement1
+
+ return (PreparedStatement) DummyObject.creeEtImplementeInterfaceSurObjet(this, PreparedStatement)
+
+ }
+
+ Object invoke(Object proxy, Method method, Object[] args) {
+
+ String nomMethode = method.name
+
+ switch (nomMethode) {
+
+ case SETLONG:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETOBJECT:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETSTRING:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETBOOLEAN:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETINT:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETTIMESTAMP:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETNULL:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case SETDATE:
+ requete.addParam((Integer) args[0], args[1])
+ break
+
+ case EXECUTEQUERY:
+ case EXECUTEBATCH:
+
+ if (args) {
+ throw new IllegalArgumentException("On ne devrait pas avoir d'argument dans ce cas")
+ } else {
+ Rapport.SINGLETON.log(requete)
+ }
+
+ break
+
+ default:
+
+ Rapport.SINGLETON.logMethode(proxy, method, args)
+
+ break
+ }
+
+ Object resultat = statement.invokeMethod(nomMethode, args)
+
+ return resultat
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook.jdbc
+
+import java.lang.reflect.Method
+import java.sql.Statement
+
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
+import java.lang.reflect.InvocationHandler
+import org.lilie.services.eliot.jdbcHook.jdbc.utils.DummyObject
+import org.lilie.services.eliot.jdbcHook.Requete
+
+class EliotStatement implements InvocationHandler {
+
+ private static final EXECUTE = "execute"
+
+ private Statement statement
+
+ private Requete requete = new Requete(jdbc: "Statement")
+
+ public Object[] params = []
+
+ public void setParams(Object[] value) {
+ this.params = value
+ }
+
+ public Statement createStatement(Statement statement1) {
+
+ statement = statement1
+
+ return (Statement) DummyObject.creeEtImplementeInterfaceSurObjet(this, Statement)
+
+ }
+
+ Object invoke(Object proxy, Method method, Object[] args) {
+
+ String nomMethode = method.name
+
+ if (nomMethode.startsWith(EXECUTE)) {
+
+ if (isFirstArgAString(args)) {
+ String sql = (String) args[0]
+ requete.sql = sql
+ Rapport.SINGLETON.log(requete)
+ } else {
+ Rapport.SINGLETON.logMethode(proxy, method, args)
+ }
+
+ } else {
+ Rapport.SINGLETON.logMethode(proxy, method, args)
+ }
+
+ Object resultat = statement.invokeMethod(nomMethode, args)
+
+ return resultat
+
+ }
+
+ private boolean isFirstArgAString(Object[] args) {
+ return args != null && args.length > 0 && args[0] instanceof String;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook.jdbc.utils
+
+import java.lang.reflect.InvocationHandler
+import java.lang.reflect.Proxy
+
+class DummyObject {
+
+ /**
+ * Rajoute une implémentation d'interface sur un objet
+ * @param _this : objet à "enrichir" avec les méthodes de l'interface. cette objet doit implémenter InvocationHandler
+ * @param interfaceJdbc : interface à ajouter
+ * @return un objet ayant le comportement de interfaceJdbc
+ */
+ public static Object creeEtImplementeInterfaceSurObjet(InvocationHandler _this, Class<?> interfaceJdbc) {
+
+ List<Class<?>> listeInterfaces = [interfaceJdbc]
+
+ Class<?>[] interfaces = (Class<?>[]) listeInterfaces.toArray()
+
+ ClassLoader classLoader = _this.getClass().getClassLoader()
+
+ return Proxy.newProxyInstance(
+ classLoader,
+ interfaces,
+ _this)
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie 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
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.jdbcHook.rapport
+
+import java.lang.reflect.Method
+import org.lilie.services.eliot.jdbcHook.Requete
+import sun.reflect.Reflection
+import com.sun.xml.internal.ws.fault.ExceptionBean
+
+class Rapport {
+
+ String configPath = "/tmp/logperf/"
+
+ String version = ""
+
+ String app = ""
+
+ boolean actif = true
+
+ private static final String PILE_VIDE = "pile vide"
+ private static final String APPEL_INTROUVABLE = "appel introuvable"
+ private static final String ELIOT = 'eliot'
+ private static final String PACKAGELOGGER = "jdbcHook"
+ private static final String LINESEP = '\n'
+
+ public static SINGLETON = new Rapport()
+
+ Map<Long, FileOutputStream> fichiers = [:]
+ Map<Long, String> logPath = [:]
+
+ public void init(String controllerName, String actionName) {
+
+ long threadId = Thread.currentThread().id
+
+ FileOutputStream fichier = fichiers[threadId]
+
+ if (fichier) {
+ fichier.flush()
+ fichier.close()
+ fichiers.remove(threadId)
+ }
+
+ if (actionName != 'null') {
+ logPath[threadId] = "${controllerName}/${actionName}/"
+ } else {
+ if (controllerName != 'null') {
+ logPath[threadId] = "${controllerName}/"
+ } else {
+ logPath[threadId] = "log_thread${threadId}/"
+ }
+ }
+
+ }
+
+ boolean isLogEnabled() {
+ actif
+ }
+
+ public void logMethode(Object proxy, Method method, Object[] args) {
+
+ if (isLogEnabled()) {
+ // TOIMP : définir méthode de logging pour les méthodes
+
+ String nomMethode = method.name
+
+ println("Invoke sur ${proxy.h.class.canonicalName}.${nomMethode}")
+
+ args.eachWithIndex {Object param, Integer index ->
+ println " param #$index : " + param.toString()
+ }
+
+ }
+
+ }
+
+ public void log(Requete eliotRequete) {
+
+ if (eliotRequete.isExplain()) {
+ return
+ }
+
+ List<Object> args = []
+ eliotRequete.params.each {
+ k, v ->
+ args << v
+ }
+
+ String cost
+ try {
+ String explain = eliotRequete.explainXml()
+ cost = eliotRequete.cost(explain)
+ } catch (Exception e) {
+ cost = e.message
+ }
+
+ log(eliotRequete.sql,
+ args.toArray(),
+ cost,
+ eliotRequete.jdbc)
+
+ }
+
+ private void titre() {
+ construireMessage(
+ TITRESQL,
+ TITREARGS,
+ TITRECLASSE,
+ TITREAPPEL,
+ TITRELIGNE,
+ TITREANALYSE,
+ TITREJDBC,
+ TITREVERSION,
+ TITREAPP,
+ TITREDATE,
+ TITRENATURE
+ )
+ }
+
+ private void log(String sql, Object[] params, String explain, String jdbc) {
+
+ Long currentThreadId = Thread.currentThread().id
+
+ FileOutputStream fichier = fichiers[currentThreadId]
+
+ if (!fichier) {
+
+ String cheminFichier = nomfichier(currentThreadId)
+
+ File file = new File(path())
+ file.mkdirs()
+
+ fichier = new FileOutputStream(cheminFichier)
+
+ fichiers[currentThreadId] = fichier
+ titre()
+ }
+
+ String paramsSql = logParametres(params)
+
+ logStacktrace(sql, paramsSql, explain, jdbc)
+
+ }
+
+ private String logParametres(Object[] params) {
+
+ String paramsSql = ""
+
+ params.each {
+ paramsSql = paramsSql + '"' + it.toString() + '";'
+ }
+
+ if (params) {
+ paramsSql = paramsSql.substring(0, paramsSql.length() - 1)
+ }
+
+ paramsSql
+ }
+
+ private String path() {
+ String actionPath = logPath[Thread.currentThread().id]
+ if (actionPath) {
+ return configPath + actionPath
+ } else {
+ return configPath
+ }
+ }
+
+ private String nomfichier(Long id) {
+ return path() + "log_" + id + "_" + System.currentTimeMillis().toString() + ".csv"
+ }
+
+ private String natureAppelant() {
+ String resultat = "INC"
+// Throwable pile = new Throwable()
+ StackTraceElement[] elements = Thread.currentThread().stackTrace
+
+
+ int nombreElement = elements.length
+
+ for (int i = 0; i < nombreElement; i++) {
+
+ StackTraceElement element = elements[i]
+ String cls = element.className
+
+ if (cls == "groovy.sql.Sql") {
+ resultat = "GSQL"
+ break
+ }
+
+ if (cls.indexOf("HibernateCriteriaBuilder")!=-1){
+ resultat="CRIT"
+ break
+ }
+
+ String methodName = element.methodName
+
+ if (cls.indexOf("addDynamicFinderSupport")!=-1){
+ resultat="FIND"
+ break
+ }
+
+ if (cls.indexOf("HibernateTemplate")!=-1 && methodName=="get"){
+ resultat="GET"
+ break
+ }
+
+ if (cls=="org.hibernate.engine.query.HQLQueryPlan"){
+ resultat="HQL"
+ break
+ }
+
+ if (cls.indexOf("SQLQueryImpl")!=-1){
+ resultat="HSQL"
+ break
+ }
+
+ }
+
+ return resultat
+
+ }
+
+ private void logStacktrace(String msg, String args, String explain, String jdbc) {
+
+ Throwable pile = new Throwable()
+ StackTraceElement[] elements = pile.stackTrace
+
+ int nombreElement = elements.length
+
+ if (nombreElement == 0) {
+
+ construireMessage(
+ msg,
+ args,
+ PILE_VIDE,
+ PILE_VIDE,
+ "",
+ "",
+ jdbc,
+ version,
+ app,
+ new Date().toString(),
+ natureAppelant()
+ )
+
+ return
+ }
+
+ boolean ligneEliot = false
+
+
+ for (int i = 0; i < nombreElement; i++) {
+
+ StackTraceElement element = elements[i]
+ String cls = element.className
+
+ if (cls.indexOf(PACKAGELOGGER) == -1) {
+ if (cls.indexOf(ELIOT) != -1) {
+
+ ligneEliot = true
+
+ construireMessage(
+ msg,
+ args,
+ cls,
+ element.methodName +
+ "(..)",
+ element.lineNumber.toString(),
+ explain,
+ jdbc,
+ version,
+ app,
+ new Date().toString(),
+ natureAppelant()
+ )
+ break
+ }
+ }
+ }
+
+ if (!ligneEliot) {
+
+ construireMessage(
+ msg,
+ args,
+ APPEL_INTROUVABLE,
+ APPEL_INTROUVABLE,
+ "",
+ "",
+ jdbc,
+ version,
+ app,
+ new Date().toString(),
+ natureAppelant()
+ )
+
+ }
+
+ }
+
+ private void construireMessage(String message,
+ String args,
+ String classe,
+ String methode,
+ String ligne,
+ String analyze,
+ String jdbc,
+ String codeVersion,
+ String app,
+ String date,
+ String nature
+ ) {
+
+ if (!actif) {
+ return
+ }
+
+ String texte = noNL(
+ OUVERTURELOG +
+ OUVERTUREMESSAGE +
+ tokenizeSQL(message) +
+ FERMETUREMESSAGE +
+ OUVERTUREARGS +
+ args +
+ FERMETUREARGS +
+ OUVERTURECLASSE +
+ classe +
+ FERMETURECLASSE +
+ OUVERTUREAPPEL +
+ methode +
+ FERMETUREMAPPEL +
+ OUVERTURELIGNE +
+ ligne +
+ FERMETURELIGNE +
+ OUVERTUREANALYSE +
+ analyze +
+ FERMETUREANALYSE +
+ OUVERTURENATURE +
+ nature +
+ FERMETURENATURE +
+ OUVERTUREJDBC +
+ jdbc +
+ FERMETUREJDBC +
+ OUVERTUREVERSION +
+ codeVersion +
+ FERMETUREVERSION +
+ OUVERTUREAPP +
+ app +
+ FERMETUREAPP +
+ OUVERTUREDATE +
+ date +
+ FERMETUREDATE +
+ FERMETURELOG
+
+ ) + LINESEP
+
+ print(texte)
+ }
+
+ private void print(String texte) {
+
+ Long currentThreadId = Thread.currentThread().id
+
+ FileOutputStream fichier = fichiers[currentThreadId]
+
+ fichier.write(texte.bytes)
+
+ fichier.flush()
+
+ }
+
+ private String tokenizeSQL(String sql) {
+
+ String resultat = ""
+ StringTokenizer st = new StringTokenizer(sql)
+
+ while (st.hasMoreTokens()) {
+ String key = st.nextToken()
+ resultat = resultat + key + " "
+ }
+
+ return resultat.trim()
+ }
+
+ private String noNL(String ligne) {
+ String resultat = ligne.replace('\n', ' ')
+ return resultat
+ }
+
+ private static final OUVERTURELOG = ''
+
+ private static final OUVERTUREMESSAGE = ''
+ private static final FERMETUREMESSAGE = '~'
+ private static final TITRESQL = 'sql'
+
+ private static final OUVERTUREARGS = ''
+ private static final FERMETUREARGS = '~'
+ private static final TITREARGS = 'arguments'
+
+ private static final OUVERTUREAPPEL = ''
+ private static final FERMETUREMAPPEL = '~'
+ private static final TITREAPPEL = 'methode'
+
+ private static final OUVERTURECLASSE = ''
+ private static final FERMETURECLASSE = '~'
+ private static final TITRECLASSE = 'classe'
+
+ private static final OUVERTURELIGNE = ''
+ private static final FERMETURELIGNE = '~'
+ private static final TITRELIGNE = 'n° ligne'
+
+ private static final OUVERTUREANALYSE = ''
+ private static final FERMETUREANALYSE = '~'
+ private static final TITREANALYSE = 'explain'
+
+ private static final OUVERTUREJDBC = ''
+ private static final FERMETUREJDBC = '~'
+ private static final TITREJDBC = 'appel JDBC'
+
+ private static final OUVERTURENATURE = ''
+ private static final FERMETURENATURE = '~'
+ private static final TITRENATURE = 'Nature appelant'
+
+ private static final OUVERTUREVERSION = ''
+ private static final FERMETUREVERSION = '~'
+ private static final TITREVERSION = 'version'
+
+ private static final OUVERTUREAPP = ''
+ private static final FERMETUREAPP = '~'
+ private static final TITREAPP = 'application'
+
+ private static final OUVERTUREDATE = ''
+ private static final FERMETUREDATE = ''
+ private static final TITREDATE = 'date'
+
+ private static final FERMETURELOG = ''
+
+}
+++ /dev/null
-/*
- * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
- * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
- *
- * Lilie is free software. You can redistribute it and/or modify since
- * you respect the terms of either (at least one of the both license) :
- * - under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- * - the CeCILL-C as published by CeCILL-C; either version 1 of the
- * License, or any later version
- *
- * There are special exceptions to the terms and conditions of the
- * licenses as they are applied to this software. View the full text of
- * the exception in file LICENSE.txt in the directory of this software
- * distribution.
- *
- * Lilie 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
- * Licenses for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the CeCILL-C along with Lilie. If not, see :
- * <http://www.gnu.org/licenses/> and
- * <http://www.cecill.info/licences.fr.html>.
- */
-
-
-
-package org.lilie.services.eliot.utils.perfsql
-
-import org.apache.log4j.spi.LoggingEvent
-import org.apache.log4j.Layout
-import org.apache.log4j.ConsoleAppender
-
-/**
- * Permet de retrouver les méthodes eliot groovy qui lancent les requete sql
- * @author othe
- */
-class EliotSqlFileAppender extends ConsoleAppender {
-
- private static final String BINDING = 'binding'
- private static final String RETURNING = 'returning'
- private static final String EXEC_SQL = 'about to open ResultSet'
- private static final String SQL = "org.hibernate.SQL"
-
- boolean detail
-
- Requete requete = new Requete()
-
- public void append(LoggingEvent event) {
-
- if (!checkEntryConditions()) {
- return
- }
-
- String message = event.message.toString()
- if (detail) {
- boolean codeSQL = (event.categoryName == SQL)
-
- if ((message.indexOf(BINDING) == -1) && (message.indexOf(RETURNING) == -1) && codeSQL) {
- requete.sql = message
- }
-
- if (message.indexOf(BINDING) != -1) {
- ajoutParametre(message, event.categoryName)
- }
-
- if (message.indexOf(EXEC_SQL) != -1) {
- logStacktrace()
- requete.clear()
- }
- } else {
- boolean codeSQL = (event.categoryName == SQL)
-
- if ((message.indexOf(BINDING) == -1) && (message.indexOf(RETURNING) == -1) && codeSQL) {
- requete.sql = message
- logStacktrace()
- requete.clear()
- }
-
- }
-
- subAppend(event)
- }
-
- private void ajoutParametre(String msg, String type) {
-
- try {
-
- StringTokenizer st = new StringTokenizer(msg)
-
- List<String> tokens = []
-
- while (st.hasMoreTokens()) {
- String key = st.nextToken()
- tokens << key
- }
-
- if (type == 'org.hibernate.type.TimestampType') {
-
- if (tokens[1] == 'null') {
- Param param = new Param(
- valeur: tokens[1],
- type: type
- )
- requete.params[Integer.valueOf(tokens[4])] = param
-
- } else {
- Param param = new Param(
- valeur: tokens[1] + ' ' + tokens[2],
- type: type
- )
- requete.params[Integer.valueOf(tokens[5])] = param
- }
-
- } else {
-
- // binding 'mantis - Exercice' to parameter: 19
-
- Integer posParameter = 0
-
- tokens.eachWithIndex { String chaine, Integer index ->
- if (chaine == 'parameter:') {
- posParameter = index
- }
- }
-
- Integer posTo = 0
-
- tokens.eachWithIndex { String chaine, Integer index ->
- if (chaine == 'to') {
- posTo = index
- }
- }
-
- String valeurConcat = tokens[1]
-
- for (int i = 2; i < posTo; i++) {
- valeurConcat = valeurConcat + tokens[i]
- }
-
- Param param = new Param(
- valeur: valeurConcat,
- type: type
- )
-
- requete.params[Integer.valueOf(tokens[posParameter + 1])] = param
- }
-
- } catch (Exception e) {
- print "**** ERREUR PARSER : " + msg + ", " + type
- }
-
- }
-
- private static final OUVERTURELOG = '<TR>'
- private static final FERMETURELOG = '</TR>'
-
- private static final OUVERTUREMESSAGE = '<TD>'
- private static final FERMETUREMESSAGE = '</TD>'
-
- private static final OUVERTUREAPPEL = '<TD>'
- private static final FERMETUREMAPPEL = '</TD>'
-
- private static final OUVERTURELIGNE = '<TD>'
- private static final FERMETURELIGNE = '</TD>'
-
- private static final OUVERTUREANALYSE = '<TD>'
- private static final FERMETUREANALYSE = '</TD>'
-
-
- private static final PILE_VIDE = "pile vide"
- private static final APPEL_INTROUVABLE = "appel introuvable"
- private static final ELIOT_FILE_APPENDER = "EliotSqlFileAppender"
- private static final ELIOT = 'eliot'
-
- /**
- * Log pile d'appel eliot
- */
- private void logStacktrace() {
-
- String msg = requete.sql
-
- Throwable pile = new Throwable()
- StackTraceElement[] elements = pile.stackTrace
-
- int nombreElement = elements.length
-
- if (nombreElement == 0) {
- if (detail) {
- construireMessage(msg, PILE_VIDE, "", requete.explain())
- } else {
- construireMessage(msg, PILE_VIDE, "", "")
- }
- return
- }
-
- boolean ligneEliot = false
-
- for (int i = 0; i < nombreElement; i++) {
-
- StackTraceElement element = elements[i]
- String cls = element.className
-
- if (cls.indexOf(ELIOT_FILE_APPENDER) == -1) {
- if (cls.indexOf(ELIOT) != -1) {
-
- ligneEliot = true
- if (detail) {
- construireMessage(
- msg,
- cls +
- "." +
- element.methodName +
- "(..)",
- element.lineNumber.toString(),
- requete.explain()
- )
- } else {
-
- construireMessage(
- msg,
- cls +
- "." +
- element.methodName +
- "(..)",
- element.lineNumber.toString(),
- ""
- )
-
- }
-
- break
- }
- }
- }
-
- if (!ligneEliot) {
- if (detail) {
- construireMessage(msg, APPEL_INTROUVABLE, "", requete.explain())
- } else {
- construireMessage(msg, APPEL_INTROUVABLE, "", "")
- }
- }
-
- }
-
- private void construireMessage(String message, String methode, String ligne, String analyze) {
- String texte
- if (detail) {
- texte = noNL(
- OUVERTURELOG +
- OUVERTUREMESSAGE +
- tokenizeSQL(message) +
- FERMETUREMESSAGE +
- OUVERTUREANALYSE +
- analyze +
- FERMETUREANALYSE +
- OUVERTUREAPPEL +
- methode +
- FERMETUREMAPPEL +
- OUVERTURELIGNE +
- ligne +
- FERMETURELIGNE +
- FERMETURELOG
-
- ) + Layout.LINE_SEP
- } else {
- texte = noNL(
- OUVERTURELOG +
- OUVERTUREMESSAGE +
- tokenizeSQL(message) +
- FERMETUREMESSAGE +
- OUVERTUREAPPEL +
- methode +
- FERMETUREMAPPEL +
- OUVERTURELIGNE +
- ligne +
- FERMETURELIGNE +
- FERMETURELOG
-
- ) + Layout.LINE_SEP
-
- }
-
- print(texte)
- }
-
- private void print(String texte) {
- this.qw.write(texte.toCharArray())
- }
-
- private String tokenizeSQL(String sql) {
-
- String resultat = ""
- StringTokenizer st = new StringTokenizer(sql)
-
- while (st.hasMoreTokens()) {
- String key = st.nextToken()
- if (isKeyWord(key)) {
- resultat = resultat + "<b>" + key + "</b> "
- } else {
- resultat = resultat + key + " "
- }
- }
-
- return resultat.trim()
- }
-
- private Boolean isKeyWord(String word) {
-
- String internal = word.toUpperCase()
-
- boolean resultat = false
-
- SQLKEYWORDS.each {
- if (it == internal) {
- resultat = true
- }
- }
-
- return resultat
-
- }
-
- private String noNL(String ligne) {
- String resultat = ligne.replace('\n', ' ')
- return resultat
- }
-
- private static final SQLKEYWORDS = ['SELECT', 'UPDATE', 'INSERT', 'DELETE', 'FROM', 'WHERE', 'INNER', 'LEFT', 'JOIN', 'RIGHT', 'OR', 'AND', 'WITH', 'AS', 'ON', 'IS', 'NULL', 'CASE', 'WHEN', 'EXISTS']
-
-}
+++ /dev/null
-package org.lilie.services.eliot.utils.perfsql
-
-import java.text.SimpleDateFormat
-
-class Param {
- String valeur
- String type
-
- public def value() {
- switch (type) {
- case "org.hibernate.type.LongType":
-
- if (valeur == 'null') {
- return null
- }
-
- return Long.valueOf(noQuote(valeur))
-
- break
- case "org.hibernate.type.BooleanType":
-
- if (valeur == 'null') {
- return null
- }
-
- return Boolean.valueOf(noQuote(valeur))
-
- break
-
- case "org.hibernate.type.TimestampType":
-
- if (valeur == 'null') {
- return null
- }
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
- return sdf.parse(noQuote(valeur)).toTimestamp()
-
- break
-
- case "org.hibernate.type.StringType":
-
- if (valeur == 'null') {
- return null
- }
-
- return valeur
- break
-
- default:
- // TOREFACT : à supprimer lorsque tous les types seront gérés
- println type
- return valeur
-
- }
- }
-
- private String noQuote(String texte) {
- String noQuote = texte.substring(1)
- return noQuote.substring(0, noQuote.length() - 1)
- }
-
- public String toString() {
- valeur + " (" + type + ')'
- }
-}
+++ /dev/null
-package org.lilie.services.eliot.utils.perfsql
-
-import groovy.sql.Sql
-import javax.sql.DataSource
-import org.lilie.services.eliot.utils.SpringUtils
-
-class Requete {
-
- String sql = ""
-
- Integer nbParams = 0
-
- Map<Integer, Param> params = [:]
-
- public void clear() {
- sql = ""
- params.clear()
- nbParams = 0
- }
-
- private static final NL = '\n'
-
- public String toString() {
-
- String resultat = tokenizeSQL(sql) + NL
-
- params.each {
- k, v ->
- resultat = resultat + k + "=" + v.toString() + NL
- }
-
- return resultat
- }
-
- public String explain() {
-
- String resultat = ""
-
- DataSource datasource = (DataSource) SpringUtils.mainContext.getBean("dataSource")
-
- Sql sqlCode = new Sql(datasource)
- List<Object> paramsSql = []
-
- params.sort().each {k, v ->
- paramsSql << v.value()
- }
-
- String sqlExplain = "EXPLAIN " + tokenizeSQL(sql)
-
- if (paramsSql.size()!=nbParams){
- return "Erreur nombre paramètre : ${paramsSql.size()}, $nbParams"
- }
-
- try {
-
- sqlCode.eachRow(sqlExplain, paramsSql) {
-
- String ligne = it
- ligne = ligne.substring(DEBUTEXPLAIN.length())
- ligne = ligne.substring(0, ligne.length() - 1)
- resultat = resultat + '<p>' + ligne + '</p>'
- }
- } catch (Exception e) {
-
- return "ERREUR : " + e.message
- }
- sqlCode.close()
- return resultat
-
- }
-
- private static final DEBUTEXPLAIN = "[QUERY PLAN:"
-
- private String tokenizeSQL(String sql) {
-
- String resultat = ""
- StringTokenizer st = new StringTokenizer(sql)
-
- while (st.hasMoreTokens()) {
- String key = st.nextToken()
- if (key.indexOf('?') != -1) {
- nbParams++
- }
- resultat = resultat + key + " "
- }
-
- return resultat.trim()
- }
-
-
-}
import org.apache.log4j.FileAppender
import org.lilie.services.eliot.url.UrlServeurResolutionMode
import org.lilie.services.eliot.environnement.EnvironnementUtil
-import org.lilie.services.eliot.utils.perfsql.EliotSqlFileAppender
/**
* Chargement des configurations externalisées
// DEVELOPPEMENT: file applicatif debug + fichier requetes sql
development {
-
- // lorsque le log sql est actif, permet de demander le mode détaillé html
- detailSqlActif = false
-
appenders {
appender new FileAppender(
name: "applicatif_dev",
file: "/tmp/${appName}.log",
layout: pattern(conversionPattern: '%d [%t] %p %m%n')
)
-
- if (detailSqlActif) {
- // la propriété détail permet de rajouter le plan d'execution
- appender new EliotSqlFileAppender(
- name: "sqlRequetes",
- target: stdout,
- detail: false,
- layout: pattern(conversionPattern: '%C %d [%t] %p %m%n')
- )
-
- } else {
-
- appender new FileAppender(
- name: "sqlRequetes",
- file: "/tmp/${appName}-sqlRequetes.log",
- layout: pattern(conversionPattern: '%d [%t] %p %m%n')
- )
-
- }
-
+ appender new FileAppender(
+ name: "sqlRequetes",
+ file: "/tmp/${appName}-sqlRequetes.log",
+ layout: pattern(conversionPattern: '%d [%t] %p %m%n')
+ )
}
root {
import org.lilie.services.eliot.environnement.EnvironnementUtil
import org.apache.log4j.DailyRollingFileAppender
import org.apache.log4j.FileAppender
-import org.lilie.services.eliot.utils.perfsql.EliotSqlFileAppender
// Fréquence de sauvegarde de l'état du front-office (1 sauvegarde toutes les xxx ms)
// Remarque 1: la sauvegarde n'est déclenchée qu'en cas de modification
// DEVELOPPEMENT: file applicatif debug + fichier requetes sql
development {
-
- // lorsque le log sql est actif, permet de demander le mode détaillé html
- detailSqlActif = true
-
appenders {
appender new FileAppender(
name: "applicatif_dev",
file: "/tmp/${appName}.log",
- layout: pattern(conversionPattern: '%C %d [%t] %p %m%n')
+ layout: pattern(conversionPattern: '%d [%t] %p %m%n')
+ )
+ appender new FileAppender(
+ name: "sqlRequetes",
+ file: "/tmp/${appName}-sqlRequetes.log",
+ layout: pattern(conversionPattern: '%d [%t] %p %m%n')
)
-
- if (detailSqlActif) {
- // la propriété détail permet de rajouter le plan d'execution
- appender new EliotSqlFileAppender(
- name: "sqlRequetes",
- target: stdout,
- detail: true,
- layout: pattern(conversionPattern: '%C %d [%t] %p %m%n')
- )
-
- } else {
-
- appender new FileAppender(
- name: "sqlRequetes",
- file: "/tmp/${appName}-sqlRequetes.log",
- layout: pattern(conversionPattern: '%d [%t] %p %m%n')
- )
-
- }
-
}
root {
if (dataSource.loggingSql) {
- def sqlRequetes = ['org.hibernate.SQL', "org.hibernate.jdbc"]
+ def sqlRequetes = ['org.hibernate.SQL']
def sqlParams = ['org.hibernate.type']
+/*
debug additivity: false,
stdout: classesEliot + sqlRequetes,
applicatif_dev: classesEliot,
sqlRequetes: sqlRequetes
+*/
trace additivity: false,
sqlRequetes: sqlParams,
- stdout: sqlParams + sqlRequetes
+ stdout: sqlParams
debug stdout: 'org.hibernate.transaction',
+ 'org.hibernate.jdbc',
'org.hibernate.cache'
} else {
}
// Démarrage du job de publipostage après déploiement en ms (0 = arrêt du job)
-eliot.textes.triggerImpression.startDelay = 60 * 1000
+eliot.textes.triggerImpression.startDelay = 0
// Délais de répétition du job de publipostage en ms (0 = arrêt du job)
eliot.textes.triggerImpression.repeatInterval = 5 * 1000
javamelody {
// permet d'activer le serveur javamelody pour analyse de l'activité de l'application
// le serveur java melody sera alors accessible à l'url 'monitoring'
- actif = true
+ actif = false
// liste des compteurs à surveiller
compteurs = 'http,sql,error,log,spring'
// paramétrage pour spring
//eliot.mode.maintenance = false
+
+environments {
+
+ production {
+ perf.logsql.actif = false
+ }
+
+ development {
+// permet de faire du log sur disque des requetes sql jdbc
+ perf.logsql.actif = false
+
+// chemin des fichiers de log
+ perf.logsql.path = "/tmp/chemincsv/"
+ }
+
+ test {
+
+ // permet de faire du log sur disque des requetes sql jdbc
+ perf.logsql.actif = false
+
+ // chemin des fichiers de log
+ perf.logsql.path = "/tmp/chemincsv/"
+
+ }
+
+}
\ No newline at end of file
import grails.util.Environment
import org.lilie.services.eliot.mockcatalogue.DocService
import org.lilie.services.eliot.applications.textes.catalogue.DefaultCatalogueCommunicationService
+import org.codehaus.groovy.grails.commons.ConfigurationHolder
+import org.lilie.services.eliot.jdbcHook.EliotDataSourceBeanProcessor
// Place your Spring DSL code here
// Example bean definition: Grails in Action, page 402
lilieHttpService = ref('lilieHttpService')
}
}
- demandeTraitementService(org.lilie.services.eliot.demon.impl.DefaultDemandeTraitementService) {
+ demandeTraitementService(org.lilie.services.eliot.demon.impl.DefaultDemandeTraitementService) {
dataSource = ref("dataSource")
}
+ if (ConfigurationHolder?.config?.perf?.logsql?.actif) {
+
+ eliotDataSourceBeanProcessor(EliotDataSourceBeanProcessor) {
+
+ grailsApplication = ref('grailsApplication')
+
+ if (ConfigurationHolder?.config?.perf?.logsql?.path) {
+ configPath = "${ConfigurationHolder?.config?.perf?.logsql?.path}"
+ }
+
+ }
+
+ }
+
+
}
\ No newline at end of file
package org.lilie.services.eliot
import org.lilie.services.eliot.webservice.WebserviceService
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
+import org.codehaus.groovy.grails.commons.ConfigurationHolder
/**
* @author jtra
}
def execute() {
- if (log.debugEnabled) {log.debug "Vérifie la connexion à eliot-webservices"}
+
+ if (log.debugEnabled) {
+ log.debug "Vérifie la connexion à eliot-webservices"
+ }
+
+ if (ConfigurationHolder?.config?.perf?.logsql?.actif) {
+ Rapport.SINGLETON.logPath[Thread.currentThread().id] = "VerifieWebServiceJob/"
+ }
+
webserviceService.verifieDisponibilite()
}
}
import org.codehaus.groovy.grails.commons.ConfigurationHolder
import org.lilie.services.eliot.textes.impression.TextesImpressionDiffereeService
+import org.lilie.services.eliot.jdbcHook.rapport.Rapport
/**
* @author bper
}
def execute() {
+ if (ConfigurationHolder?.config?.perf?.logsql?.actif) {
+ Rapport.SINGLETON.logPath[Thread.currentThread().id] = "TextesImpressionJob/"
+ }
textesImpressionDiffereeService.traiteAllDemande()
}