List of usage examples for org.apache.commons.logging Log fatal
void fatal(Object message);
From source file:com.winvector.logistic.demo.MapReduceScore.java
public static void main(final String[] args) throws Exception { final MapReduceScore mrl = new MapReduceScore(); final int code = ToolRunner.run(null, mrl, args); if (code != 0) { final Log log = LogFactory.getLog(MapReduceScore.class); log.fatal("MapReduceScore error, return code: " + code); ToolRunner.printGenericCommandUsage(System.out); }//ww w . j a v a 2 s . c o m }
From source file:com.winvector.logistic.demo.MapReduceLogisticTrain.java
public static void main(final String[] args) throws Exception { final MapReduceLogisticTrain mrl = new MapReduceLogisticTrain(); final int code = ToolRunner.run(null, mrl, args); if (code != 0) { final Log log = LogFactory.getLog(MapReduceLogisticTrain.class); log.fatal("MapReduceLogistic error, return code: " + code); ToolRunner.printGenericCommandUsage(System.out); }/* w w w .jav a2 s . c om*/ }
From source file:com.sebuilder.interpreter.SeInterpreter.java
public static void main(String[] args) { if (args.length == 0) { System.out.println(// w ww . j a v a 2 s . c om "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:LoggingTrial.java
public static void main(String[] args) { Log log = LogFactory.getLog(LoggingTrial.class); System.out.println("The Log being used >>> " + log); Exception e = new Exception("A DUMMY EXCEPTION"); if (log.isTraceEnabled()) { log.trace("TRACE TEST"); log.trace("TRACE TEST", e); }/*w ww . j av a 2 s .c o m*/ if (log.isDebugEnabled()) { log.debug("DEBUG TEST"); log.debug("DEBUG TEST", e); } if (log.isInfoEnabled()) { log.info("INFO TEST"); log.info("INFO TEST", e); } if (log.isWarnEnabled()) { log.warn("WARN TEST"); log.warn("WARN TEST", e); } if (log.isErrorEnabled()) { log.error("ERROR TEST"); log.error("ERROR TEST", e); } if (log.isFatalEnabled()) { log.fatal("FATAL TEST"); log.fatal("FATAL TEST", e); } }
From source file:com.microsoft.tfs.sdk.samples.console.LogConfigurationSample.java
private static void logAllLevels(final Log log, final String message) { log.trace(message);/*from w ww .j av a 2 s .co m*/ log.debug(message); log.info(message); log.warn(message); log.error(message); log.fatal(message); }
From source file:com.rsmart.rfabric.logging.FormattedLogger.java
/** * Wraps {@link Log#fatal(String)}//from w ww . j av a 2s. co m * * @param pattern to format against * @param objs an array of objects used as parameters to the <code>pattern</code> */ public static final void fatal(String pattern, Object... objs) { Log log = getLog(); if (log.isFatalEnabled()) { log.fatal(getMessage(pattern, objs)); } }
From source file:com.buffalokiwi.api.APILog.java
/** * Log a message with fatal log level./*from w ww . j ava 2 s .co m*/ * @param log Log to write to * @param message log this message */ public static void fatal(final Log log, final Object... message) { if (log.isFatalEnabled()) log.fatal(concat(message)); }
From source file:net.gleamynode.netty2.SessionLog.java
public static void fatal(Log log, Session session, Object obj) { log.fatal(getMessage(session, obj)); }
From source file:com.datos.vfs.VfsLog.java
/** * fatal.//w ww .j a va 2s. c o m * @param vfslog The base component Logger to use. * @param commonslog The class specific Logger * @param message The message to log. */ public static void fatal(final Log vfslog, final Log commonslog, final String message) { if (vfslog != null) { vfslog.fatal(message); } else if (commonslog != null) { commonslog.fatal(message); } }
From source file:helpers.database.DBAdminManager.java
public static void addGroupToSystem(AdminBean bean) { final DBContext c = new DBContext(); try {/* w ww .j a v a 2 s . c o m*/ if (bean.getUser() != null && c.init()) { // initialize database final String user = bean.getUser().trim(); // get next group id c.conn.setAutoCommit(false); // we do this in a transaction c.stmt = c.conn.prepareStatement("SELECT MAX(`group`) + 1 AS id FROM groupids"); c.rst = c.stmt.executeQuery(); if (c.rst.next()) { int next_groupid = c.rst.getInt("id"); // check, if user name exists c.stmt = c.conn.prepareStatement("SELECT user_name FROM user WHERE user_name = ?"); c.stmt.setString(1, user); c.rst = c.stmt.executeQuery(); if (c.rst.next()) { // user exists, check, if group exists c.stmt = c.conn.prepareStatement("SELECT group_name FROM groupids WHERE group_name = ?"); c.stmt.setString(1, user); c.rst = c.stmt.executeQuery(); if (c.rst.next()) { // group already exists --> do nothing bean.addError("This group already exists."); } else { // group does not exists --> add it c.stmt = c.conn.prepareStatement( "INSERT INTO groupids (`group_name`, `group`, privlevel) VALUES (?,?,?)"); c.stmt.setString(1, user); c.stmt.setInt(2, next_groupid); c.stmt.setInt(3, bean.getPrivlevel()); c.stmt.executeUpdate(); c.stmt = c.conn.prepareStatement( "INSERT INTO groups (`user_name`, `group`, `defaultgroup`) VALUES (?,?,?)"); c.stmt.setString(1, user); c.stmt.setInt(2, next_groupid); c.stmt.setInt(3, next_groupid); c.stmt.executeUpdate(); bean.addInfo("Added group with id " + next_groupid + " to the system."); } } else { bean.addError("This user does not exist."); } } c.conn.commit(); // commit transaction } } catch (SQLException e) { try { c.conn.rollback(); } catch (SQLException f) { /* * TODO: first attempt to do logging when exceptions are thrown - code "stolen" from Jens' * Database backend classes */ final Log log = LogFactory.getLog(DBAdminManager.class); log.fatal("could not roll transaction back " + e.getMessage()); } bean.addError("Sorry, an error occured: " + e); } finally { c.close(); // close database connection } }