本文整理了Java中org.apache.sis.util.logging.Logging
类的一些代码示例,展示了Logging
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logging
类的具体详情如下:
包路径:org.apache.sis.util.logging.Logging
类名称:Logging
[英]A set of utilities method for configuring loggings in SIS. Library implementors should fetch their loggers using the #getLogger(String) static method defined in this Loggingclass rather than the one defined in the standard Logger class, in order to give SIS a chance to redirect the logs to an other framework like Commons-logging or Log4J.
This class provides also some convenience static methods, including:
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Logs a warning for a non-critical error. The callers should have a fallback.
*/
private static void warning(final String method, final Exception e) {
Logging.recoverableException(Logging.getLogger(Modules.REFERENCING), IdentifiedObjects.class, method, e);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Logs the given record. This method pretend that the record has been logged by
* {@code EPSGFactory.install(…)} because it is the public API using this class.
*/
static void log(final LogRecord record) {
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(EPSGFactory.class, "install", record);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Logs a warning about an unexpected but non-fatal exception.
*
* @param method the source method.
* @param exception the exception to log.
*/
private static void unexpectedException(final String method, final Exception exception) {
Logging.unexpectedException(Logging.getLogger(Loggers.CRS_FACTORY), EPSGDataAccess.class, method, exception);
}
代码示例来源:origin: org.apache.sis.storage/sis-gdal
/**
* Returns the version number of the {@literal Proj.4} library.
* Returns {@code null} if Proj.4 is not installed on the current system.
*
* <div class="note"><b>Example:</b> Rel. 4.9.3, 15 August 2016</div>
*
* @return the Proj.4 release string, or {@code null} if the native library has been found.
*/
public static String version() {
try {
return PJ.getRelease();
} catch (UnsatisfiedLinkError e) {
// Thrown the first time that we try to use the library.
Logging.unexpectedException(Logging.getLogger(Modules.GDAL), Proj4.class, "version", e);
} catch (NoClassDefFoundError e) {
// Thrown on all attempts after the first one.
Logging.recoverableException(Logging.getLogger(Modules.GDAL), Proj4.class, "version", e);
}
return null;
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Writes an event to the logger.
*/
private static void log(final Level level, final String method, final String message) {
final LogRecord record = new LogRecord(level, message);
record.setSourceClassName(Synchronizer.class.getName());
record.setSourceMethodName(method);
Logging.getLogger("org.geotoolkit.sql").log(record);
}
}
代码示例来源:origin: Geomatys/geotoolkit
public GMLOrDefaultFactory() {
TemporalFactory delegate;
try {
delegate = (TemporalFactory) Class.forName("org.geotoolkit.gml.GMLTemporalFactory").newInstance();
} catch (Exception e) {
Logging.recoverableException(null, GMLOrDefaultFactory.class, "<init>", e);
delegate = new DefaultTemporalFactory();
}
this.delegate = delegate;
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Invoked when an unexpected exception occurred in the {@link #format} method.
*/
private static void unexpectedException(final RuntimeException exception) {
Logging.unexpectedException(null, IndexedResourceBundle.class, "format", exception);
}
}
代码示例来源:origin: apache/sis
/**
* Returns the version number of the {@literal Proj.4} library.
* Returns {@code null} if Proj.4 is not installed on the current system.
*
* <div class="note"><b>Example:</b> Rel. 4.9.3, 15 August 2016</div>
*
* @return the Proj.4 release string, or {@code null} if the native library has been found.
*/
public static String version() {
try {
return PJ.getRelease();
} catch (UnsatisfiedLinkError e) {
// Thrown the first time that we try to use the library.
Logging.unexpectedException(Logging.getLogger(Modules.GDAL), Proj4.class, "version", e);
} catch (NoClassDefFoundError e) {
// Thrown on all attempts after the first one.
Logging.recoverableException(Logging.getLogger(Modules.GDAL), Proj4.class, "version", e);
}
return null;
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Same as {@link DomUtilities#textAttributeValue(org.w3c.dom.Element, java.lang.String, java.lang.String, java.lang.Class) }
* but dont throw any exception.
*/
public static <T> T textAttributeValueSafe(final Element parent, final String tagName, final String attributeName, final Class<T> clazz) {
try {
return textAttributeValue(parent, tagName,attributeName, clazz);
} catch (UnconvertibleObjectException ex) {
Logging.getLogger("org.geotoolkit.util").log(Level.WARNING, null, ex);
return null;
}
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Implementation of {@link #before(String, boolean)} and {@link #after(String, boolean)}.
* The {@code before} boolean argument tells which method is invoking this one.
*/
private void setOrdering(final String type, final boolean subclasses, final boolean before) {
final Class<?> c;
try {
c = Class.forName(type);
} catch (ClassNotFoundException e) {
Logging.recoverableException(null, Organizer.class, before ? "before" : "after", e);
return;
}
setOrdering(c, subclasses, before);
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Returns the expected class for values stored under this key.
*
* @return The class of values stored under this key.
*/
public Class<?> getValueClass() {
if (valueClass == null) {
try {
valueClass = Class.forName(className);
} catch (ClassNotFoundException exception) {
Logging.unexpectedException(null, Key.class, "getValueClass", exception);
valueClass = Object.class;
}
}
return valueClass;
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Invoked when a recoverable exception occurred. Those exceptions must be minor enough
* that they can be silently ignored in most cases.
*/
static void recoverableException(final Class<? extends Static> caller, final TransformException exception) {
Logging.recoverableException(Logging.getLogger(Loggers.GEOMETRY), caller, "transform", exception);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Invoked when an unexpected exception occurred. Those exceptions must be non-fatal, i.e. the caller
* <strong>must</strong> have a reasonable fallback (otherwise it should propagate the exception).
*/
private static void unexpectedException(final String methodName, final Exception exception) {
Logging.unexpectedException(Logging.getLogger(Modules.REFERENCING), CRS.class, methodName, exception);
}
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Same as {@link DomUtilities#textAttributeValue(org.w3c.dom.Element, java.lang.String, java.lang.String, java.lang.Class, java.lang.boolean) }
* but dont throw any exception.
*/
public static <T> T textAttributeValueSafe(final Element parent, final String tagName, final String attributeName, final Class<T> clazz, final boolean recursive) {
try {
return textAttributeValue(parent, tagName,attributeName, clazz, recursive);
} catch (UnconvertibleObjectException ex) {
Logging.getLogger("org.geotoolkit.util").log(Level.WARNING, null, ex);
return null;
}
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Do the logging of the warning prepared by the above methods.
* This method declares {@code MultiAuthoritiesFactory.getAuthorityFactory(…)}
* as the source of the log since it is the nearest public API.
*/
private void log(final LogRecord record) {
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(MultiAuthoritiesFactory.class, "getAuthorityFactory", record);
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Returns a high precision and more accurate bounding box of the shape than the
* {@link #getBounds} method. This method returns an infinite rectangle if some
* points can not be transformed.
*/
@Override
public Rectangle2D getBounds2D() {
try {
return Shapes2D.transform(projection, shape.getBounds2D(), null);
} catch (TransformException exception) {
Logging.recoverableException(null, ProjectedShape.class, "getBounds2D", exception);
return XRectangle2D.INFINITY;
}
}
代码示例来源:origin: org.apache.sis.core/sis-utility
/**
* Invoked when a recoverable error occurred. This method is similar to
* {@link #unexpectedException(Logger,Class,String,Throwable) unexpectedException(…)}
* except that it does not log the stack trace and uses a lower logging level.
*
* @param logger where to log the error, or {@code null} for inferring a default value from other arguments.
* @param classe the class where the error occurred, or {@code null} for inferring a default value from other arguments.
* @param method the method name where the error occurred, or {@code null} for inferring a default value from other arguments.
* @param error the error, or {@code null} if none.
* @return {@code true} if the error has been logged, or {@code false} if the given {@code error}
* was null or if the logger does not log anything at {@link Level#FINE}.
*
* @see #unexpectedException(Logger, Class, String, Throwable)
* @see #severeException(Logger, Class, String, Throwable)
*/
public static boolean recoverableException(final Logger logger, final Class<?> classe,
final String method, final Throwable error)
{
final String classname = (classe != null) ? classe.getName() : null;
return unexpectedException(logger, classname, method, error, Level.FINE);
}
代码示例来源:origin: org.apache.sis.core/sis-utility
/**
* Logs a recoverable exception that happened (directly or indirectly) in the {@link #configuration()} method.
*/
private static void recoverableException(final String logger, final Exception e) {
Logging.recoverableException(Logging.getLogger(logger), About.class, "configuration", e);
}
}
代码示例来源:origin: apache/sis
/**
* Logs a warning about an unexpected but non-fatal exception.
*
* @param method the source method.
* @param exception the exception to log.
*/
private static void unexpectedException(final String method, final Exception exception) {
Logging.unexpectedException(Logging.getLogger(Loggers.CRS_FACTORY), EPSGDataAccess.class, method, exception);
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Same as {@link DomUtilities#textValue(org.w3c.dom.Element, java.lang.String, java.lang.Class) }
* but dont throw any exception.
*/
public static <T> T textValueSafe(final Element parent, final String tagName, final Class<T> clazz, final boolean recusive) {
try {
return textValue(parent, tagName, clazz, recusive);
} catch (UnconvertibleObjectException ex) {
Logging.getLogger("org.geotoolkit.util").log(Level.WARNING, null, ex);
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!