/** * Creates a new instance of {@code AbstractYAMLBasedConfiguration}. */ protected AbstractYAMLBasedConfiguration() { initLogger(new ConfigurationLogger(getClass())); }
/** * Creates a new instance of {@code ConfigurationLogger} that uses a logger * whose name is derived from the provided class. * * @param logCls the class whose name is to be used for logging (must not be * <b>null</b>) * @throws IllegalArgumentException if the logger class is <b>null</b> */ public ConfigurationLogger(final Class<?> logCls) { this(createLoggerForClass(logCls)); }
/** * Creates a new instance of {@code ConfigurationLogger} that uses the * specified logger name. * * @param loggerName the logger name (must not be <b>null</b>) * @throws IllegalArgumentException if the logger name is <b>null</b> */ public ConfigurationLogger(final String loggerName) { this(createLoggerForName(loggerName)); }
if (getLogger().isDebugEnabled()) getLogger().debug("Could not locate file " + fileName + " at " + basePath + ": " + e.getMessage());
/** * Logs the specified exception on warn level. * * @param msg the message to be logged * @param ex the exception to be logged */ public void warn(final String msg, final Throwable ex) { getLog().warn(msg, ex); }
@Override public void onEvent(final ConfigurationErrorEvent event) { getLogger().warn("Internal error", event.getCause()); } });
/** * Initializes the logger. Checks for null parameters. * * @param log the new logger */ private void initLogger(final ConfigurationLogger log) { this.log = (log != null) ? log : ConfigurationLogger.newDummyLogger(); }
/** * Evaluates the expression. * @param var The expression. * @return The String result of the expression. */ @Override public String lookup(final String var) { if (substitutor == null) { return var; } String result = substitutor.replace(var); try { final Expression exp = engine.createExpression(result); final Object exprResult = exp.evaluate(createContext()); result = (exprResult != null) ? String.valueOf(exprResult) : null; } catch (final Exception e) { final ConfigurationLogger l = getLogger(); if (l != null) { l.debug("Error encountered evaluating " + result + ": " + e); } } return result; }
if (getLogger().isDebugEnabled()) getLogger().debug(String.format("Could not determine URL for " + "basePath = %s, fileName = %s: %s", basePath, fileName, e));
/** * Logs the specified message on error level. * * @param msg the message to be logged */ public void error(final String msg) { getLog().error(msg); }
log.warn("Failed to create InputSource for " + resolved, e); return null;
/** * Initializes the logger. Supports <b>null</b> input. This method can be * called by derived classes in order to enable logging. * * @param log the logger * @since 2.0 */ protected final void initLogger(final ConfigurationLogger log) { this.log = (log != null) ? log : ConfigurationLogger.newDummyLogger(); }
this.getLogger().debug("Unable to load the configuration: " + e); throw new ConfigurationException("Unable to load the configuration", e);
/** * Creates a new instance of {@code XMLConfiguration}. */ public XMLConfiguration() { super(); initLogger(new ConfigurationLogger(XMLConfiguration.class)); }
if (getLogger().isDebugEnabled()) getLogger().debug("No configurations defined for " + this); it.next().getTransformedRoot()); if (getLogger().isDebugEnabled()) getLogger().debug(os.toString());
/** * Returns a flag whether logging on debug level is enabled. * * @return <b>true</b> if debug logging is enabled, <b>false</b> otherwise */ public boolean isDebugEnabled() { return getLog().isDebugEnabled(); }
getLogger().warn( "Ignoring invalid date property " + buffer);
/** * Creates a new instance of {@code AbstractYAMLBasedConfiguration} as a * copy of the specified configuration. * * @param c the configuration to be copied */ protected AbstractYAMLBasedConfiguration( final HierarchicalConfiguration<ImmutableNode> c) { super(c); initLogger(new ConfigurationLogger(getClass())); }
/** * Returns the current configuration. This configuration was initialized at * the beginning of an operation and stored in a thread-local variable. Some * methods of this class call this method directly without requesting a lock * before. To deal with this, we always request an additional read lock. * * @return the current configuration */ private CombinedConfiguration getCurrentConfig() { CombinedConfiguration config; String key; beginRead(false); try { config = CURRENT_CONFIG.get().getCurrentConfiguration(); key = CURRENT_CONFIG.get().getKey(); } finally { endRead(); } if (getLogger().isDebugEnabled()) { getLogger().debug("Returning config for " + key + ": " + config); } return config; }