Example usage for org.apache.commons.logging LogFactory getFactory

List of usage examples for org.apache.commons.logging LogFactory getFactory

Introduction

In this page you can find the example usage for org.apache.commons.logging LogFactory getFactory.

Prototype

@Deprecated
public static LogFactory getFactory() 

Source Link

Document

This method only exists for compatibility with unusual Commons Logging API usage like e.g.

Usage

From source file:com.sebuilder.interpreter.SeInterpreter.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println(//from w  w  w  .java 2s.com
                "Usage: [--driver=<drivername] [--driver.<configkey>=<configvalue>...] [--implicitlyWait=<ms>] [--pageLoadTimeout=<ms>] [--stepTypePackage=<package name>] <script path>...");
        System.exit(0);
    }

    Log log = LogFactory.getFactory().getInstance(SeInterpreter.class);

    WebDriverFactory wdf = DEFAULT_DRIVER_FACTORY;
    ScriptFactory sf = new ScriptFactory();
    StepTypeFactory stf = new StepTypeFactory();
    sf.setStepTypeFactory(stf);
    TestRunFactory trf = new TestRunFactory();
    sf.setTestRunFactory(trf);

    ArrayList<String> paths = new ArrayList<String>();
    HashMap<String, String> driverConfig = new HashMap<String, String>();
    for (String s : args) {
        if (s.startsWith("--")) {
            String[] kv = s.split("=", 2);
            if (kv.length < 2) {
                log.fatal("Driver configuration option \"" + s
                        + "\" is not of the form \"--driver=<name>\" or \"--driver.<key>=<value\".");
                System.exit(1);
            }
            if (s.startsWith("--implicitlyWait")) {
                trf.setImplicitlyWaitDriverTimeout(Integer.parseInt(kv[1]));
            } else if (s.startsWith("--pageLoadTimeout")) {
                trf.setPageLoadDriverTimeout(Integer.parseInt(kv[1]));
            } else if (s.startsWith("--stepTypePackage")) {
                stf.setPrimaryPackage(kv[1]);
            } else if (s.startsWith("--driver.")) {
                driverConfig.put(kv[0].substring("--driver.".length()), kv[1]);
            } else if (s.startsWith("--driver")) {
                try {
                    wdf = (WebDriverFactory) Class
                            .forName("com.sebuilder.interpreter.webdriverfactory." + kv[1]).newInstance();
                } catch (ClassNotFoundException e) {
                    log.fatal("Unknown WebDriverFactory: " + "com.sebuilder.interpreter.webdriverfactory."
                            + kv[1], e);
                } catch (InstantiationException e) {
                    log.fatal("Could not instantiate WebDriverFactory "
                            + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e);
                } catch (IllegalAccessException e) {
                    log.fatal("Could not instantiate WebDriverFactory "
                            + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e);
                }
            } else {
                paths.add(s);
            }
        } else {
            paths.add(s);
        }
    }

    if (paths.isEmpty()) {
        log.info("Configuration successful but no paths to scripts specified. Exiting.");
        System.exit(0);
    }

    HashMap<String, String> cfg = new HashMap<String, String>(driverConfig);

    for (String path : paths) {
        try {
            TestRun lastRun = null;
            for (Script script : sf.parse(new File(path))) {
                for (Map<String, String> data : script.dataRows) {
                    try {
                        lastRun = script.testRunFactory.createTestRun(script, log, wdf, driverConfig, data,
                                lastRun);
                        if (lastRun.finish()) {
                            log.info(script.name + " succeeded");
                        } else {
                            log.info(script.name + " failed");
                        }
                    } catch (Exception e) {
                        log.info(script.name + " failed", e);
                    }
                }
            }
        } catch (Exception e) {
            log.fatal("Run error.", e);
            System.exit(1);
        }
    }
}

From source file:edu.toronto.cs.xml2rdf.utils.LogUtils.java

public static void info(Class<?> klass, String message) {
    LogFactory.getFactory().getInstance(klass).info(message);
}

From source file:edu.toronto.cs.xml2rdf.utils.LogUtils.java

public static void debug(Class<?> klass, String message) {
    LogFactory.getFactory().getInstance(klass).debug(message);
}

From source file:edu.toronto.cs.xml2rdf.utils.LogUtils.java

public static void warn(Class<?> klass, String message) {
    LogFactory.getFactory().getInstance(klass).warn(message);
}

From source file:io.github.lal872k.monotifier.MyBackPack.java

public static MO[] loadMOs(User user, Engine engine) throws IOException {
    System.out.println("Retrieving MO's for user " + user.getID() + " (" + user.getName() + ").");
    // make web client
    final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);

    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");

    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);

    //webClient.setCssEnabled(false);
    // http://stackoverflow.com/questions/3600557/turning-htmlunit-warnings-off

    webClient.setIncorrectnessListener(new IncorrectnessListener() {

        @Override// w w  w  . j a  v  a  2  s  .  c o m
        public void notify(String arg0, Object arg1) {
            // TODO Auto-generated method stub

        }
    });
    webClient.setCssErrorHandler(new ErrorHandler() {

        @Override
        public void warning(CSSParseException exception) throws CSSException {
            // TODO Auto-generated method stub

        }

        @Override
        public void fatalError(CSSParseException exception) throws CSSException {
            // TODO Auto-generated method stub

        }

        @Override
        public void error(CSSParseException exception) throws CSSException {
            // TODO Auto-generated method stub

        }
    });
    webClient.setJavaScriptErrorListener(new JavaScriptErrorListener() {

        @Override
        public void scriptException(InteractivePage ip, ScriptException se) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void timeoutError(InteractivePage ip, long l, long l1) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void malformedScriptURL(InteractivePage ip, String string, MalformedURLException murle) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void loadScriptError(InteractivePage ip, URL url, Exception excptn) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
    webClient.setHTMLParserListener(new HTMLParserListener() {

        @Override
        public void error(String string, URL url, String string1, int i, int i1, String string2) {
            //
        }

        @Override
        public void warning(String string, URL url, String string1, int i, int i1, String string2) {
            //
        }
    });

    //webClient.setThrowExceptionOnFailingStatusCode(false);
    //webClient.setThrowExceptionOnScriptError(false);

    //http://stackoverflow.com/questions/19551043/process-ajax-request-in-htmlunit/26268815#26268815
    webClient.getOptions().setJavaScriptEnabled(true);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getOptions().setCssEnabled(false);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());

    // get the page
    HtmlPage page = webClient.getPage(
            "https://peddie.seniormbp.com/SeniorApps/studentParent/attendSummary.faces?selectedMenuId=true");

    // get login form
    final HtmlForm login_form = page.getFormByName("form");

    final HtmlTextInput username = login_form.getInputByName("form:userId");
    final HtmlPasswordInput password = login_form.getInputByName("form:userPassword");

    final HtmlButtonInput login_submit = login_form.getInputByName("form:signIn");

    username.setValueAttribute(user.getMyBackPackUsername());
    password.setValueAttribute(user.getDecryptedMyBackPackPassword());

    URL oldURL = page.getUrl();

    // Now submit the form by clicking the button and get back the new page.
    page = login_submit.click();

    if (oldURL.equals(page.getUrl())) {
        System.err
                .println("Password or username was invalid for " + user.getName() + "(" + user.getID() + ").");
        return new MO[0];
    }

    // click on details

    final HtmlForm switchView_form = page.getFormByName("j_id_jsp_1447653194_2");

    final HtmlSubmitInput switchView_submit = switchView_form
            .getInputByName("j_id_jsp_1447653194_2:j_id_jsp_1447653194_12");

    page = switchView_submit.click();

    // now on right page

    ArrayList<MO> mos = new ArrayList();

    // find all rows
    List<DomElement> odds = (List<DomElement>) page
            .getByXPath("//tr[@class='dataCellOdd' or @class='dataCellEven']");

    String date = "";
    String section = "";
    boolean passedSection = false;

    for (DomElement el : odds) {
        for (DomElement ele : el.getChildElements()) {
            // date is only on with rowspan
            if (ele.hasAttribute("rowspan")) {
                date = ele.getTextContent();
            }
            // section and type contain that attr
            if (ele.getAttribute("class").equals("attendTypeColumnData2")) {
                // section comes first
                if (!passedSection) {
                    section = ele.getTextContent();
                    passedSection = true;
                } else {
                    mos.add(new MO(section, date, ele.getTextContent()));
                    passedSection = false;
                }
            }
        }
    }

    engine.getHistory().addAction(new Action("Accessed MyBackPack", "Accessed the MyBackPack of "
            + user.getName() + " (" + user.getID() + ")(" + user.getEmail() + ") to update the mo count."));

    return mos.toArray(new MO[0]);

}

From source file:net.jperf.commonslog.CommonsLogStopWatchTest.java

protected void setUp() throws Exception {
    super.setUp();

    originalLogFactoryAttribute = (String) LogFactory.getFactory().getAttribute(LogFactoryImpl.LOG_PROPERTY);
    LogFactory.getFactory().setAttribute(LogFactoryImpl.LOG_PROPERTY, SimpleLog.class.getName());
}

From source file:es.tunelator.log.Logger.java

/**
 * @param threshold/*  w  w w  .j  a v a  2 s  .c o  m*/
 */
public static void setLogThreshold(String threshold) {
    LogFactory.getFactory().setAttribute(AppParameters.getProperty(AppParameters.LOG_APPENDER) + ".threshold",
            threshold);
    LogFactory.releaseAll();
}

From source file:net.sourceforge.floggy.eclipse.Activator.java

/**
   * The constructor//from w w  w.  ja  va  2 s  .c  o  m
   */
public Activator() {
    super();
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", EclipseLog.class.getName());
}

From source file:net.openhft.chronicle.logger.jcl.JclVanillaChronicleLoggerTest.java

@After
public void tearDown() {
    LogFactory.getFactory().release();
    IOTools.deleteDir(basePath(ChronicleLogConfig.TYPE_VANILLA));
}

From source file:net.openhft.chronicle.logger.jcl.JclIndexedChronicleLoggerTest.java

@After
public void tearDown() {
    LogFactory.getFactory().release();
    IOTools.deleteDir(basePath(ChronicleLogConfig.TYPE_INDEXED));
}