private Properties propsForConfig( Config config ) { Properties out = new Properties(); for ( Iterator<Map.Entry<String,ConfigValue>> ii = config.entrySet().iterator(); ii.hasNext(); ) { Map.Entry<String,ConfigValue> entry = ii.next(); try { out.put( entry.getKey(), asSimpleString( entry.getValue() ) ); } catch ( IllegalArgumentException e ) { delayedLogItems.add( new DelayedLogItem( FINE, "For property '" + entry.getKey() + "', " + e.getMessage() ) ); } } return out; }
public static void dumpToLogger( DelayedLogItem item, MLogger logger ) { logger.log( levelMap.get( item.getLevel() ), item.getText(), item.getException() ); }
public Parse propertiesFromSource( String identifier ) throws FileNotFoundException, Exception { InputStream rawStream = MultiPropertiesConfig.class.getResourceAsStream( identifier ); if ( rawStream != null ) { InputStream pis = new BufferedInputStream( rawStream ); Properties p = new Properties(); List<DelayedLogItem> messages = new LinkedList<DelayedLogItem>(); try { p.load( pis ); } finally { try { if ( pis != null ) pis.close(); } //ensures closuer of nested rawStream as well catch (IOException e) { messages.add( new DelayedLogItem( Level.WARNING, "An IOException occurred while closing InputStream from resource path '" + identifier + "'.", e ) ); } } return new Parse(p, messages); } else throw new FileNotFoundException( String.format("Resource not found at path '%s'.", identifier) ); } }
delayedLogItemsOut.add( new DelayedLogItem( Level.FINEST, String.format( "Added paths from resource path text file at '%s'", resourcePathsTextFileResourcePath ) ) ); delayedLogItemsOut.add( new DelayedLogItem( Level.FINEST, String.format( "Could not find resource path text file for path '%s'. Skipping.", resourcePathsTextFileResourcePath ) ) );
public synchronized static void refresh( MultiPropertiesConfig[] overrides, String overridesDescription ) { String[] defaults = new String[] { "/com/mchange/v2/log/default-mchange-log.properties" }; String[] preempts = new String[] { "/mchange-log.properties", "/" }; List bli = new ArrayList(); MultiPropertiesConfig tmpCONFIG = MLogConfigSource.readVmConfig( defaults, preempts, bli ); boolean firstLoad = (CONFIG == null); if ( overrides != null ) { int olen = overrides.length; MultiPropertiesConfig[] combineMe = new MultiPropertiesConfig[ olen + 1 ]; combineMe[0] = tmpCONFIG; for ( int i = 0; i < olen; ++i ) combineMe[ i + 1 ] = overrides[i]; bli.add( new DelayedLogItem( DelayedLogItem.Level.INFO, (firstLoad ? "Loaded" : "Refreshed") + " MLog library log configuration, with overrides" + (overridesDescription == null ? "." : ": " + overridesDescription) ) ); CONFIG = MConfig.combine( combineMe ); } else { if ( !firstLoad ) bli.add( new DelayedLogItem( DelayedLogItem.Level.INFO, "Refreshed MLog library log configuration, without overrides.") ); CONFIG = tmpCONFIG; } BOOTSTRAP_LOG_ITEMS = bli; }
public Parse propertiesFromSource( ClassLoader cl, String identifier ) throws FileNotFoundException, Exception { List<DelayedLogItem> dlis = new LinkedList<DelayedLogItem>(); Config config = extractConfig( cl, identifier, dlis ); PropertiesConversion pc = configToProperties( config ); for( String path : pc.unrenderable ) dlis.add( new DelayedLogItem( Level.FINE, String.format("Value at path '%s' could not be converted to a String. Skipping.", path) ) ); return new Parse( pc.properties, dlis ); }
public static MultiPropertiesConfig readVmConfig(String[] defaultResources, String[] preemptingResources, List delayedLogItemsOut) { defaultResources = ( defaultResources == null ? NO_PATHS : defaultResources ); preemptingResources = ( preemptingResources == null ? NO_PATHS : preemptingResources ); List pathsList = vmCondensedPaths( defaultResources, preemptingResources, delayedLogItemsOut ); if ( delayedLogItemsOut != null ) delayedLogItemsOut.add( new DelayedLogItem(Level.FINER, "Reading VM config for path list " + stringFromPathsList( pathsList ) ) ); return read( (String[]) pathsList.toArray(new String[pathsList.size()]), delayedLogItemsOut ); }
if (p == null) delayedLogItems.add( new DelayedLogItem( Level.WARNING, BasicMultiPropertiesConfig.class.getName() + ".extractPropsByKey(): Could not find loaded properties for resource path: " + rp) ); delayedLogItems.add( new DelayedLogItem( Level.WARNING, message) ); continue; delayedLogItems.add( new DelayedLogItem( Level.WARNING, message) ); continue;
delayedLogItems.add( new DelayedLogItem( Level.WARNING, message) ); continue; delayedLogItems.add( new DelayedLogItem( Level.WARNING, message) ); continue;
{ delayedLogItems.add( new DelayedLogItem( Level.FINE, String.format("The configuration file for resource identifier '%s' could not be found. Skipping.", rp) ) ); } catch ( Exception e ) { delayedLogItems.add( new DelayedLogItem( Level.WARNING, String.format("An Exception occurred while trying to read configuration data at resource identifier '%s'.", rp), e) ); }
rawConfig = ConfigFactory.parseFile( f ); else dlis.add( new DelayedLogItem( Level.WARNING, String.format("Specified config.file '%s' is not readable. Falling back to standard application.(conf|json|properties).}", f.getAbsolutePath()) ) ); dlis.add( new DelayedLogItem( Level.WARNING, String.format("Specified config.file '%s' does not exist. Falling back to standard application.(conf|json|properties).}", f.getAbsolutePath()) ) ); dlis.add( new DelayedLogItem( Level.WARNING, String.format("Apparent URL resource path for HOCON '%s' could not be parsed as a URL.", resourcePath), e ) ); dlis.add( new DelayedLogItem( Level.FINE, String.format("Missing or empty HOCON configuration for resource path '%s'.", resourcePath) ) ); else config = rawConfig;