Search in sources :

Example 1 with ExecutionLogFactory

use of lucee.runtime.engine.ExecutionLogFactory in project Lucee by lucee.

the class Admin method doGetExecutionLog.

private void doGetExecutionLog() throws PageException {
    ExecutionLogFactory factory = config.getExecutionLogFactory();
    Struct sct = new StructImpl();
    sct.set(KeyConstants._enabled, Caster.toBoolean(config.getExecutionLogEnabled()));
    Class clazz = factory.getClazz();
    sct.set(KeyConstants._class, clazz != null ? clazz.getName() : "");
    sct.set(KeyConstants._arguments, factory.getArgumentsAsStruct());
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
}
Also used : StructImpl(lucee.runtime.type.StructImpl) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) ExecutionLogFactory(lucee.runtime.engine.ExecutionLogFactory) Struct(lucee.runtime.type.Struct)

Example 2 with ExecutionLogFactory

use of lucee.runtime.engine.ExecutionLogFactory in project Lucee by lucee.

the class XMLConfigWebFactory method loadExeLog.

private static void loadExeLog(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    boolean hasServer = configServer != null;
    Element el = getChildByName(doc.getDocumentElement(), "execution-log");
    // enabled
    Boolean bEnabled = Caster.toBoolean(getAttr(el, "enabled"), null);
    if (bEnabled == null) {
        if (hasServer)
            config.setExecutionLogEnabled(configServer.getExecutionLogEnabled());
    } else
        config.setExecutionLogEnabled(bEnabled.booleanValue());
    boolean hasChanged = false;
    String val = Caster.toString(config.getExecutionLogEnabled());
    try {
        Resource contextDir = config.getConfigDir();
        Resource exeLog = contextDir.getRealResource("exe-log");
        if (!exeLog.exists()) {
            exeLog.createNewFile();
            IOUtil.write(exeLog, val, SystemUtil.getCharset(), false);
            hasChanged = true;
        } else if (!IOUtil.toString(exeLog, SystemUtil.getCharset()).equals(val)) {
            IOUtil.write(exeLog, val, SystemUtil.getCharset(), false);
            hasChanged = true;
        }
    } catch (IOException e) {
        e.printStackTrace(config.getErrWriter());
    }
    if (hasChanged) {
        try {
            if (config.getClassDirectory().exists())
                config.getClassDirectory().remove(true);
        } catch (IOException e) {
            e.printStackTrace(config.getErrWriter());
        }
    }
    // class
    String strClass = getAttr(el, "class");
    Class clazz;
    if (!StringUtil.isEmpty(strClass)) {
        try {
            if ("console".equalsIgnoreCase(strClass))
                clazz = ConsoleExecutionLog.class;
            else {
                ClassDefinition cd = getClassDefinition(el, "", config.getIdentification());
                Class c = cd.getClazz();
                if ((c.newInstance() instanceof ExecutionLog)) {
                    clazz = c;
                } else {
                    clazz = ConsoleExecutionLog.class;
                    SystemOut.printDate(config.getErrWriter(), "class [" + strClass + "] must implement the interface " + ExecutionLog.class.getName());
                }
            }
        } catch (Exception e) {
            SystemOut.printDate(e);
            clazz = ConsoleExecutionLog.class;
        }
        if (clazz != null)
            SystemOut.printDate(config.getOutWriter(), "loaded ExecutionLog class " + clazz.getName());
        // arguments
        String strArgs = getAttr(el, "arguments");
        if (StringUtil.isEmpty(strArgs))
            strArgs = getAttr(el, "class-arguments");
        Map<String, String> args = toArguments(strArgs, true);
        config.setExecutionLogFactory(new ExecutionLogFactory(clazz, args));
    } else {
        if (hasServer)
            config.setExecutionLogFactory(configServer.getExecutionLogFactory());
        else
            config.setExecutionLogFactory(new ExecutionLogFactory(ConsoleExecutionLog.class, new HashMap<String, String>()));
    }
}
Also used : ConsoleExecutionLog(lucee.runtime.engine.ConsoleExecutionLog) Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException) ClassDefinition(lucee.runtime.db.ClassDefinition) FunctionLibException(lucee.transformer.library.function.FunctionLibException) PageException(lucee.runtime.exp.PageException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SecurityException(lucee.runtime.exp.SecurityException) TagLibException(lucee.transformer.library.tag.TagLibException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SQLException(java.sql.SQLException) IOException(java.io.IOException) BundleException(org.osgi.framework.BundleException) SAXException(org.xml.sax.SAXException) ClassException(lucee.commons.lang.ClassException) MalformedURLException(java.net.MalformedURLException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) ConsoleExecutionLog(lucee.runtime.engine.ConsoleExecutionLog) ExecutionLog(lucee.runtime.engine.ExecutionLog) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) ExecutionLogFactory(lucee.runtime.engine.ExecutionLogFactory)

Aggregations

CFXTagClass (lucee.runtime.cfx.customtag.CFXTagClass)2 CPPCFXTagClass (lucee.runtime.cfx.customtag.CPPCFXTagClass)2 JavaCFXTagClass (lucee.runtime.cfx.customtag.JavaCFXTagClass)2 ExecutionLogFactory (lucee.runtime.engine.ExecutionLogFactory)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SQLException (java.sql.SQLException)1 Resource (lucee.commons.io.res.Resource)1 ClassException (lucee.commons.lang.ClassException)1 ClassDefinition (lucee.runtime.db.ClassDefinition)1 ConsoleExecutionLog (lucee.runtime.engine.ConsoleExecutionLog)1 ExecutionLog (lucee.runtime.engine.ExecutionLog)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 ExpressionException (lucee.runtime.exp.ExpressionException)1 PageException (lucee.runtime.exp.PageException)1 SecurityException (lucee.runtime.exp.SecurityException)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1