Example usage for org.apache.commons.logging Log info

List of usage examples for org.apache.commons.logging Log info

Introduction

In this page you can find the example usage for org.apache.commons.logging Log info.

Prototype

void info(Object message);

Source Link

Document

Logs a message with info log level.

Usage

From source file:com.espertech.esper.epl.lookup.SubordinateQueryPlannerUtil.java

public static void queryPlanLogOnSubq(boolean queryPlanLogging, Log queryPlanLog, SubordinateQueryPlanDesc plan,
        int subqueryNum, Annotation[] annotations) {
    QueryPlanIndexHook hook = QueryPlanIndexHookUtil.getHook(annotations);
    if (queryPlanLogging && (queryPlanLog.isInfoEnabled() || hook != null)) {
        String prefix = "Subquery " + subqueryNum + " ";
        String strategy = (plan == null || plan.getLookupStrategyFactory() == null) ? "table scan"
                : plan.getLookupStrategyFactory().toQueryPlan();
        queryPlanLog.info(prefix + "strategy " + strategy);
        if (plan != null) {
            if (plan.getIndexDescs() != null) {
                for (int i = 0; i < plan.getIndexDescs().length; i++) {
                    String indexName = plan.getIndexDescs()[i].getIndexName();
                    String indexText = indexName != null ? "index " + indexName + " " : "(implicit) ";
                    queryPlanLog.info(prefix + "shared index");
                    queryPlanLog.info(prefix + indexText);
                }/*from   w w  w .java 2 s . com*/
            }
        }
        if (hook != null) {
            IndexNameAndDescPair[] pairs = plan == null ? new IndexNameAndDescPair[0]
                    : getPairs(plan.getIndexDescs());
            String factory = plan == null ? null : plan.getLookupStrategyFactory().getClass().getSimpleName();
            hook.subquery(new QueryPlanIndexDescSubquery(pairs, subqueryNum, factory));
        }
    }
}

From source file:com.wavemaker.runtime.data.util.JDBCUtils.java

public static Object runSql(String sql[], String url, String username, String password, String driverClassName,
        Log logger, boolean isDDL) {

    Connection con = getConnection(url, username, password, driverClassName);

    try {/*from   w ww.ja va  2  s .  c o m*/
        try {
            con.setAutoCommit(true);
        } catch (SQLException ex) {
            throw new DataServiceRuntimeException(ex);
        }

        Statement s = con.createStatement();

        try {
            try {
                for (String stmt : sql) {
                    if (logger != null && logger.isInfoEnabled()) {
                        logger.info("Running " + stmt);
                    }
                    s.execute(stmt);
                }
                if (!isDDL) {
                    ResultSet r = s.getResultSet();
                    List<Object> rtn = new ArrayList<Object>();
                    while (r.next()) {
                        // getting only the first col is pretty unuseful
                        rtn.add(r.getObject(1));
                    }
                    return rtn.toArray(new Object[rtn.size()]);
                }
            } catch (Exception ex) {
                if (logger != null && logger.isErrorEnabled()) {
                    logger.error(ex.getMessage());
                }
                throw ex;
            }
        } finally {
            try {
                s.close();
            } catch (Exception ignore) {
            }
        }
    } catch (Exception ex) {
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        } else {
            throw new DataServiceRuntimeException(ex);
        }
    } finally {
        try {
            con.close();
        } catch (Exception ignore) {
        }
    }

    return null;
}

From source file:com.acciente.induction.init.RequestInterceptorInitializer.java

public static RequestInterceptor[] getRequestInterceptor(Config.RequestInterceptors oRequestInterceptorsConfig,
        ModelPool oModelPool, ClassLoader oClassLoader, ServletConfig oServletConfig)
        throws ClassNotFoundException, InvocationTargetException, ConstructorNotFoundException,
        ParameterProviderException, IllegalAccessException, InstantiationException {
    RequestInterceptor[] oRequestInterceptorArray;
    String sRequestInterceptorClassName;
    Log oLog;

    oLog = LogFactory.getLog(RequestInterceptorInitializer.class);

    oRequestInterceptorArray = new RequestInterceptor[oRequestInterceptorsConfig.getRequestInterceptorList()
            .size()];/*from   w w  w . j  av a  2s  . com*/

    for (int i = 0; i < oRequestInterceptorsConfig.getRequestInterceptorList().size(); i++) {
        Config.RequestInterceptors.RequestInterceptor oRequestInterceptorConfig;

        oRequestInterceptorConfig = (Config.RequestInterceptors.RequestInterceptor) oRequestInterceptorsConfig
                .getRequestInterceptorList().get(i);

        sRequestInterceptorClassName = oRequestInterceptorConfig.getClassName();

        oLog.info("loading user-defined request interceptor: " + sRequestInterceptorClassName);

        Class oRequestInterceptorClass = oClassLoader.loadClass(sRequestInterceptorClassName);

        // attempt to find and call the single public constructor
        oRequestInterceptorArray[i] = (RequestInterceptor) ObjectFactory.createObject(oRequestInterceptorClass,
                new Object[] { oServletConfig, oRequestInterceptorConfig, oClassLoader },
                new InitializerParameterProvider(oModelPool, "request-interceptor-init"));
    }

    return oRequestInterceptorArray;
}

From source file:kr.co.bitnine.octopus.util.StringUtils.java

/**
 * Print a log message for starting up and shutting down
 *
 * @param clazz the class of the server/*from w  ww.j a  v  a  2s . c o  m*/
 * @param args  arguments
 * @param log   the target log object
 */
public static void startupShutdownMessage(Class<?> clazz, String[] args, final Log log) {
    final String classname = clazz.getSimpleName();
    final String hostname = NetUtils.getHostname();

    final String build = VersionInfo.getUrl() + ", rev. " + VersionInfo.getRevision() + "; compiled by '"
            + VersionInfo.getUser() + "' on " + VersionInfo.getDate();
    String[] msg = new String[] { "Starting " + classname, "  host = " + hostname,
            "  args = " + Arrays.asList(args), "  version = " + VersionInfo.getVersion(),
            "  classpath = " + System.getProperty("java.class.path"), "  build = " + build,
            "  java = " + System.getProperty("java.version") };
    log.info(toStartupShutdownString("STARTUP_MSG: ", msg));

    if (SystemUtils.IS_OS_UNIX) {
        try {
            SignalLogger.INSTANCE.register(log);
        } catch (Throwable t) {
            log.warn("failed to register any UNIX signal loggers: ", t);
        }
    }
    ShutdownHookManager.get().addShutdownHook(new Runnable() {
        @Override
        public void run() {
            log.info(toStartupShutdownString("SHUTDOWN_MSG: ",
                    new String[] { "Shutting down " + classname + " at " + hostname }));
        }
    }, SHUTDOWN_HOOK_PRIORITY);
}

From source file:byps.test.TestUtils.java

public static void printBuffer(Log log, BBuffer buf) {
    log.info("buffer: \r\n" + buf.toDetailString());
}

From source file:com.ery.estorm.util.ReflectionUtils.java

/**
 * Log the current thread stacks at INFO level.
 * //from   w  w w  . j av  a2  s.c  om
 * @param log
 *            the logger that logs the stack trace
 * @param title
 *            a descriptive title for the call stacks
 * @param minInterval
 *            the minimum time from the last
 */
public static void logThreadInfo(Log log, String title, long minInterval) {
    boolean dumpStack = false;
    if (log.isInfoEnabled()) {
        synchronized (ReflectionUtils.class) {
            long now = System.currentTimeMillis();
            if (now - previousLogTime >= minInterval * 1000) {
                previousLogTime = now;
                dumpStack = true;
            }
        }
        if (dumpStack) {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            printThreadInfo(new PrintWriter(buffer), title);
            log.info(buffer.toString());
        }
    }
}

From source file:corina.logging.CorinaLog.java

private static PrintStream createPrintStream(final Log log, final boolean error) {
    return new PrintStream(new OutputStream() {
        public void write(int b) {
            byte[] barray = { (byte) b };
            write(barray, 0, 1);//  w ww  . j av a2  s  .c  o m
        }

        public void write(byte[] b, int off, int len) {
            String str = new String(b, off, len);
            // skip any trailing EOL
            if ("\r".equals(str) || "\n".equals(str) || "\r\n".equals(str))
                return;
            if (error) {
                log.error(str);
            } else {
                log.info(str);
            }
        }
    });
}

From source file:com.lenovo.tensorhusky.common.utils.ReflectionUtils.java

/**
 * Log the current thread stacks at INFO level.
 *
 * @param log         the logger that logs the stack trace
 * @param title       a descriptive title for the call stacks
 * @param minInterval the minimum time from the last
 *//*w  ww . j a va  2  s  .  c  o  m*/
public static void logThreadInfo(Log log, String title, long minInterval) {
    boolean dumpStack = false;
    if (log.isInfoEnabled()) {
        synchronized (ReflectionUtils.class) {
            long now = clock.getTime();
            if (now - previousLogTime >= minInterval * 1000) {
                previousLogTime = now;
                dumpStack = true;
            }
        }
        if (dumpStack) {
            try {
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
                log.info(buffer.toString(Charset.defaultCharset().name()));
            } catch (UnsupportedEncodingException ignored) {
            }
        }
    }
}

From source file:com.buaa.cfs.utils.ReflectionUtils.java

/**
 * Log the current thread stacks at INFO level.
 *
 * @param log         the logger that logs the stack trace
 * @param title       a descriptive title for the call stacks
 * @param minInterval the minimum time from the last
 *///from w w  w  . ja  va  2s.c o m
public static void logThreadInfo(Log log, String title, long minInterval) {
    boolean dumpStack = false;
    if (log.isInfoEnabled()) {
        synchronized (ReflectionUtils.class) {
            long now = Time.now();
            if (now - previousLogTime >= minInterval * 1000) {
                previousLogTime = now;
                dumpStack = true;
            }
        }
        if (dumpStack) {
            try {
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
                log.info(buffer.toString(Charset.defaultCharset().name()));
            } catch (UnsupportedEncodingException ignored) {
            }
        }
    }
}

From source file:com.moss.appsnap.keeper.freedesktop.FreeDesktopAppHandler.java

public static void removeFromApplicationsMenu(String fileName, File scriptLocation, FreeDesktopLayoutMap fsMap)
        throws IOException {
    final Log log = LogFactory.getLog(FreeDesktopAppHandler.class);

    String appsMenu;/*from   w  ww. java2s.  com*/
    if (fsMap.customAppsMenuPath.exists()) {
        appsMenu = read(new FileReader(fsMap.customAppsMenuPath)).toString();
    } else {
        appsMenu = read(
                new InputStreamReader(FreeDesktopAppHandler.class.getResourceAsStream("applications.menu")))
                        .toString();
    }
    final File desktopFile = new File(fsMap.dotLocalShareAppsDir, fileName + ".desktop");

    final String entry = applicationsFileEntry(desktopFile);
    final String pattern = Pattern.quote(entry);

    log.info("Searching for \n" + entry + "\n\n using \n" + pattern);
    appsMenu = appsMenu.replaceAll(pattern, "");

    write(appsMenu, fsMap.customAppsMenuPath);
}