本文整理了Java中org.apache.sis.util.logging.Logging.log()
方法的一些代码示例,展示了Logging.log()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logging.log()
方法的具体详情如下:
包路径:org.apache.sis.util.logging.Logging
类名称:Logging
方法名:log
[英]Logs the given record to the logger associated to the given class. This convenience method performs the following steps:
代码示例来源: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
/**
* 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: apache/sis
/**
* 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: apache/sis
/**
* 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: org.apache.sis.core/sis-referencing
/**
* Logs the given exception at the given level. This method pretends that the logging come from
* {@link CRS#getAuthorityFactory(String)}, which is the public facade for {@link #EPSG()}.
*/
private static void log(final Exception e, final boolean isWarning) {
String message = e.getMessage(); // Prefer the locale of system administrator.
if (message == null) {
message = e.toString();
}
final LogRecord record = new LogRecord(isWarning ? Level.WARNING : Level.CONFIG, message);
if (isWarning && !(e instanceof UnavailableFactoryException)) {
record.setThrown(e);
}
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(CRS.class, "getAuthorityFactory", record);
}
代码示例来源:origin: apache/sis
/**
* Logs the given exception at the given level. This method pretends that the logging come from
* {@link CRS#getAuthorityFactory(String)}, which is the public facade for {@link #EPSG()}.
*/
private static void log(final Exception e, final boolean isWarning) {
String message = e.getMessage(); // Prefer the locale of system administrator.
if (message == null) {
message = e.toString();
}
final LogRecord record = new LogRecord(isWarning ? Level.WARNING : Level.CONFIG, message);
if (isWarning && !(e instanceof UnavailableFactoryException)) {
record.setThrown(e);
}
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(CRS.class, "getAuthorityFactory", record);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Invoked when an exception occurred during the creation of a candidate from a code.
*/
private static void exceptionOccurred(final FactoryException exception) {
/*
* use 'getMessage()' instead of 'getLocalizedMessage()' for
* giving preference to the locale of system administrator.
*/
final LogRecord record = new LogRecord(Level.FINER, exception.getMessage());
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(IdentifiedObjectFinder.class, "find", record);
}
}
代码示例来源:origin: apache/sis
/**
* Invoked when an exception occurred during the creation of a candidate from a code.
*/
private static void exceptionOccurred(final FactoryException exception) {
/*
* use 'getMessage()' instead of 'getLocalizedMessage()' for
* giving preference to the locale of system administrator.
*/
final LogRecord record = new LogRecord(Level.FINER, exception.getMessage());
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(IdentifiedObjectFinder.class, "find", record);
}
}
代码示例来源:origin: org.apache.sis.core/sis-utility
/**
* Logs a message to the {@code "org.apache.sis.system"} logger.
*/
private static void log(final Level level, final Exception e, final short key, final Object... parameters) {
final LogRecord record = Messages.getResources(null).getLogRecord(level, key, parameters);
record.setLoggerName(Loggers.SYSTEM);
if (e != null) {
record.setThrown(e);
}
Logging.log(null, null, record); // Let Logging.log(…) infers the public caller.
}
代码示例来源:origin: apache/sis
/**
* Logs a message to the {@code "org.apache.sis.system"} logger.
*/
private static void log(final Level level, final Exception e, final short key, final Object... parameters) {
final LogRecord record = Messages.getResources(null).getLogRecord(level, key, parameters);
record.setLoggerName(Loggers.SYSTEM);
if (e != null) {
record.setThrown(e);
}
Logging.log(null, null, record); // Let Logging.log(…) infers the public caller.
}
代码示例来源:origin: org.apache.sis.core/sis-feature
/**
* Registers the library implementation of the given name (JTS or ESRI) if present; ignore otherwise.
* The given name shall be the simple name of a {@code Geometries} subclass in the same package.
* The last registered library will be the default implementation.
*/
private static void register(final String name) {
String classname = Geometries.class.getName();
classname = classname.substring(0, classname.lastIndexOf('.')+1).concat(name);
try {
implementation = (Geometries) Class.forName(classname).newInstance();
} catch (ReflectiveOperationException | LinkageError e) {
LogRecord record = Resources.forLocale(null).getLogRecord(Level.CONFIG,
Resources.Keys.OptionalLibraryNotFound_2, name, e.toString());
record.setLoggerName(Loggers.GEOMETRY);
Logging.log(Geometries.class, "register", record);
}
}
代码示例来源:origin: apache/sis
/**
* Registers the library implementation of the given name (JTS or ESRI) if present; ignore otherwise.
* The given name shall be the simple name of a {@code Geometries} subclass in the same package.
* The last registered library will be the default implementation.
*/
private static void register(final String name) {
String classname = Geometries.class.getName();
classname = classname.substring(0, classname.lastIndexOf('.')+1).concat(name);
try {
implementation = (Geometries) Class.forName(classname).newInstance();
} catch (ReflectiveOperationException | LinkageError e) {
LogRecord record = Resources.forLocale(null).getLogRecord(Level.CONFIG,
Resources.Keys.OptionalLibraryNotFound_2, name, e.toString());
record.setLoggerName(Loggers.GEOMETRY);
Logging.log(Geometries.class, "register", record);
}
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Logs a message about a grid which is about to be loaded.
*
* @param caller the provider to logs as the source class.
* the source method will be set to {@code "createMathTransform"}.
* @param file the grid file, as a {@link String} or a {@link Path}.
*/
static void log(final Class<?> caller, final Object file) {
final LogRecord record = Resources.forLocale(null).getLogRecord(Level.FINE, Resources.Keys.LoadingDatumShiftFile_1, file);
record.setLoggerName(Loggers.COORDINATE_OPERATION);
Logging.log(caller, "createMathTransform", record);
}
代码示例来源:origin: apache/sis
/**
* Logs a message about a grid which is about to be loaded.
*
* @param caller the provider to logs as the source class.
* the source method will be set to {@code "createMathTransform"}.
* @param file the grid file, as a {@link String} or a {@link Path}.
*/
static void log(final Class<?> caller, final Object file) {
final LogRecord record = Resources.forLocale(null).getLogRecord(Level.FINE, Resources.Keys.LoadingDatumShiftFile_1, file);
record.setLoggerName(Loggers.COORDINATE_OPERATION);
Logging.log(caller, "createMathTransform", record);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* If we had any warnings during the loading process, report them now.
*/
void reportWarnings() {
if (hasUnrecognized) {
final StringBuilder keywords = new StringBuilder();
for (final Map.Entry<String,Object> entry : header.entrySet()) {
if (entry.getValue() == null) {
if (keywords.length() != 0) {
keywords.append(", ");
}
keywords.append(entry.getKey());
}
}
final LogRecord record = Messages.getResources(null).getLogRecord(Level.WARNING,
Messages.Keys.UnknownKeywordInRecord_2, file, keywords.toString());
record.setLoggerName(Loggers.COORDINATE_OPERATION);
Logging.log(NTv2.class, "createMathTransform", record);
}
}
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Invoked when a factory failed to create an object.
* After invoking this method, the caller will fallback on hard-coded values.
*/
static void failure(final Object caller, final String method, final FactoryException e, final int code) {
String message = Resources.format(Resources.Keys.CanNotInstantiateGeodeticObject_1, (Constants.EPSG + ':') + code);
message = Exceptions.formatChainedMessages(null, message, e);
final LogRecord record = new LogRecord(Level.WARNING, message);
if (!(e instanceof UnavailableFactoryException) || AuthorityFactories.failure((UnavailableFactoryException) e)) {
// Append the stack trace only if the exception is the the one we expect when the factory is not available.
record.setThrown(e);
}
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(caller.getClass(), method, record);
}
}
代码示例来源:origin: org.apache.sis.core/sis-metadata
/**
* Returns the connection to the database, creating a new one if needed. This method shall
* be invoked inside a synchronized block wider than just the scope of this method in order
* to ensure that the connection is used by only one thread at time. This is also necessary
* for preventing the background thread to close the connection too early.
*
* <p>Callers shall not close the connection returned by this method.
* The connection will be closed by {@link #closeExpired()} after an arbitrary timeout.</p>
*
* @return the connection to the database.
* @throws SQLException if an error occurred while fetching the connection.
*/
final Connection connection() throws SQLException {
assert Thread.holdsLock(this);
Connection c = connection;
if (c == null) {
connection = c = dataSource.getConnection();
Logging.log(MetadataSource.class, "lookup", Initializer.connected(c.getMetaData()));
scheduleCloseTask();
}
return c;
}
代码示例来源:origin: apache/sis
/**
* Invoked when a factory failed to create an object.
* After invoking this method, the caller will fallback on hard-coded values.
*/
static void failure(final Object caller, final String method, final FactoryException e, final int code) {
String message = Resources.format(Resources.Keys.CanNotInstantiateGeodeticObject_1, (Constants.EPSG + ':') + code);
message = Exceptions.formatChainedMessages(null, message, e);
final LogRecord record = new LogRecord(Level.WARNING, message);
if (!(e instanceof UnavailableFactoryException) || AuthorityFactories.failure((UnavailableFactoryException) e)) {
// Append the stack trace only if the exception is the the one we expect when the factory is not available.
record.setThrown(e);
}
record.setLoggerName(Loggers.CRS_FACTORY);
Logging.log(caller.getClass(), method, record);
}
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Deletes this file. This method is invoked automatically when
* a {@link File} object has been garbage-collected.
*/
@Override
public void dispose() {
if (delete()) {
/*
* Logs the message at the WARNING level because execution of this code
* means that the application failed to delete itself the temporary file.
*/
Logging.log(TemporaryFile.class, "delete",
Loggings.format(Level.WARNING, Loggings.Keys.TemporaryFileGc_1, this));
}
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Compares the given CRS description with the authoritative description.
* If the comparison produces a warning, a message will be recorded to the given logger.
*
* @param crs the CRS to compare with the authoritative description.
* @param logger the logger where to report warnings, if any.
* @param classe the class to declare as the source of the warning.
* @param method the method to declare as the source of the warning.
* @throws FactoryException if an error occurred while querying the authority factory.
*/
public static void withAuthority(final CoordinateReferenceSystem crs, final String logger,
final Class<?> classe, final String method) throws FactoryException
{
final DefinitionVerifier verification = DefinitionVerifier.withAuthority(crs, null, false);
if (verification != null) {
final LogRecord record = verification.warning(true);
if (record != null) {
record.setLoggerName(logger);
Logging.log(classe, method, record);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!