List of usage examples for org.apache.commons.logging Log warn
void warn(Object message);
From source file:org.apache.openaz.xacml.std.dom.DOMUtil.java
public static boolean repairStringAttribute(Element element, String attributeName, String defaultValue, Log logger) { String attributeValue = getStringAttribute(element, attributeName); if (attributeValue == null) { if (defaultValue == null) { defaultValue = IdentifierImpl.gensym().stringValue(); }/*from ww w . ja va2 s .c o m*/ logger.warn("Setting missing " + attributeName + " attribute to " + defaultValue); element.setAttribute(attributeName, defaultValue); return true; } return false; }
From source file:org.apache.phoenix.hive.util.PhoenixStorageHandlerUtil.java
public static String getRegionLocation(HRegionLocation location, Log log) throws IOException { InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort()); if (isa.isUnresolved()) { log.warn("Failed resolve " + isa); }//from w ww . j a v a 2 s . c o m InetAddress regionAddress = isa.getAddress(); String regionLocation = null; try { regionLocation = reverseDNS(regionAddress); } catch (NamingException e) { log.warn("Cannot resolve the host name for " + regionAddress + " because of " + e); regionLocation = location.getHostname(); } return regionLocation; }
From source file:org.apache.pig.impl.plan.CompilationMessageCollector.java
private static void logMessage(String messageString, MessageType messageType, Log log) { switch (messageType) { case Info://from w w w . ja v a 2s.c om log.info(messageString); break; case Warning: log.warn(messageString); break; case Error: log.error(messageString); } }
From source file:org.apache.pig.impl.util.LogUtils.java
public static void warn(Object o, String msg, PigWarning warningEnum, Log log) { PigLogger pigLogger = PhysicalOperator.getPigLogger(); if (pigLogger != null) { pigLogger.warn(o, msg, warningEnum); } else {//from ww w . j ava2 s .c o m log.warn(msg); } }
From source file:org.apache.pig.impl.util.LogUtils.java
public static void writeLog(Throwable t, String logFileName, Log log, boolean verbose, String headerMessage, boolean displayFooter, boolean displayMessage) { String message = null;/*from w w w .j av a 2s .c o m*/ String marker = null; StringBuilder sb = new StringBuilder("="); for (int i = 0; i < 79; ++i) { sb.append("="); } sb.append("\n"); marker = sb.toString(); if (t instanceof Exception) { Exception pe = LogUtils.getPermissionException((Exception) t); if (pe != null) { log.error("You don't have permission to perform the operation. Error from the server: " + pe.getMessage()); } } PigException pigException = LogUtils.getPigException(t); if (pigException != null) { message = "ERROR " + pigException.getErrorCode() + ": " + pigException.getMessage(); } else { if ((t instanceof ParseException || t instanceof org.apache.pig.tools.pigscript.parser.TokenMgrError || t instanceof org.apache.pig.tools.parameters.TokenMgrError)) { message = "ERROR 1000: Error during parsing. " + t.getMessage(); } else if (t instanceof IOException) { message = "ERROR 2997: Encountered IOException. " + t.getMessage(); } else if (t instanceof RuntimeException) { message = "ERROR 2999: Unexpected internal error. " + t.getMessage(); } else { message = "ERROR 2998: Unhandled internal error. " + t.getMessage(); } } FileOutputStream fos = null; ByteArrayOutputStream bs = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(bs)); if (displayMessage) log.error(message); if (verbose) { log.error(bs.toString()); } if (logFileName == null || logFileName.equals("")) { //if exec is invoked programmatically then logFileName will be null log.warn("There is no log file to write to."); log.error(bs.toString()); return; } File logFile = new File(logFileName); try { fos = new FileOutputStream(logFile, true); if (headerMessage != null) { fos.write((headerMessage + "\n").getBytes("UTF-8")); sb = new StringBuilder("-"); for (int i = 1; i < headerMessage.length(); ++i) { sb.append("-"); } sb.append("\n"); fos.write(sb.toString().getBytes("UTF-8")); } if (message != null) { if (message.charAt(message.length() - 1) == '\n') { fos.write((message + "\n").getBytes("UTF-8")); } else { fos.write((message + "\n\n").getBytes("UTF-8")); } } fos.write(bs.toString().getBytes("UTF-8")); fos.write(marker.getBytes("UTF-8")); if (displayFooter) { if (verbose) { System.err.println("Details also at logfile: " + logFileName); } else { System.err.println("Details at logfile: " + logFileName); } } } catch (IOException ioe) { log.warn("Could not write to log file: " + logFileName + " :" + ioe.getMessage()); log.error(bs.toString()); } finally { try { if (fos != null) fos.close(); } catch (IOException e) { } } }
From source file:org.apache.pig.impl.util.LogUtils.java
public static void writeLog(String headerMessage, String message, String logFileName, Log log) { if (logFileName == null || logFileName.equals("")) { //if exec is invoked programmatically then logFileName will be null log.warn("There is no log file to write to."); log.error(headerMessage + "\n" + message); return;//from w ww. j av a 2 s.c o m } File logFile = new File(logFileName); FileOutputStream fos = null; try { fos = new FileOutputStream(logFile, true); if (headerMessage != null) { fos.write((headerMessage + "\n").getBytes("UTF-8")); StringBuilder sb = new StringBuilder("-"); for (int i = 1; i < headerMessage.length(); ++i) { sb.append("-"); } sb.append("\n"); fos.write(sb.toString().getBytes("UTF-8")); } if (message != null) { if (message.charAt(message.length() - 1) == '\n') { fos.write((message + "\n").getBytes("UTF-8")); } else { fos.write((message + "\n\n").getBytes("UTF-8")); } } } catch (IOException ioe) { log.warn("Could not write to log file: " + logFileName + " :" + ioe.getMessage()); log.error(message); } finally { try { fos.close(); } catch (IOException e) { } } }
From source file:org.apache.poi.util.MethodUtils.java
/** * Try to make the method accessible//from w w w . j a va 2 s . c o m * @param method The source arguments */ private static void setMethodAccessible(Object method) { try { // // XXX Default access superclass workaround // // When a public class has a default access superclass // with public methods, these methods are accessible. // Calling them from compiled code works fine. // // Unfortunately, using reflection to invoke these methods // seems to (wrongly) to prevent access even when the method // modifer is public. // // The following workaround solves the problem but will only // work from sufficiently privilages code. // // Better workarounds would be greatfully accepted. // if (method instanceof Method) { ((Method) method).setAccessible(true); } else if (method instanceof Constructor) { ((Constructor) method).setAccessible(true); } else { throw new RuntimeException("invalid parameter"); } } catch (SecurityException se) { // log but continue just in case the method.invoke works anyway Log log = LogFactory.getLog(MethodUtils.class); if (!loggedAccessibleWarning) { boolean vulnerableJVM = false; try { String specVersion = System.getProperty("java.specification.version"); if (specVersion.charAt(0) == '1' && (specVersion.charAt(2) == '0' || specVersion.charAt(2) == '1' || specVersion.charAt(2) == '2' || specVersion.charAt(2) == '3')) { vulnerableJVM = true; } } catch (SecurityException e) { // don't know - so display warning vulnerableJVM = true; } if (vulnerableJVM) { log.warn("Current Security Manager restricts use of workarounds for reflection bugs " + " in pre-1.4 JVMs."); } loggedAccessibleWarning = true; } log.debug("Cannot setAccessible on method. Therefore cannot use jvm access bug workaround.", se); } }
From source file:org.apache.tajo.engine.planner.physical.PhysicalExec.java
protected void warn(Log log, String message) { log.warn("[" + context.getTaskId() + "] " + message); }
From source file:org.apache.tajo.querymaster.DefaultTaskScheduler.java
protected void warn(Log log, String message) { log.warn(String.format("[%s] %s", stage.getId(), message)); }
From source file:org.apache.tajo.storage.orc.OrcScanner.java
/** * Check to see if this ORC file is from a future version and if so, * warn the user that we may not be able to read all of the column encodings. * @param log the logger to write any error message to * @param path the data source path for error messages * @param version the version of hive that wrote the file. *//*from w w w. j a va2 s . c o m*/ static void checkOrcVersion(Log log, Path path, List<Integer> version) { if (version.size() >= 1) { int major = version.get(0); int minor = 0; if (version.size() >= 2) { minor = version.get(1); } if (major > OrcFile.Version.CURRENT.getMajor() || (major == OrcFile.Version.CURRENT.getMajor() && minor > OrcFile.Version.CURRENT.getMinor())) { log.warn(path + " was written by a future Hive version " + versionString(version) + ". This file may not be readable by this version of Hive."); } } }