This is a helper function to get a logrotate configuration component for
    your local machine or an archive. It's for use in interactive sessions.
770715
def get_tree(root=None):
    
    from insights import run
    return run(LogRotateConfTree, root=root).get(LogRotateConfTree)
469017
def timed_rotating_file_handler(name, logname, filename, when='h',
                                interval=1, backupCount=0,
                                encoding=None, delay=False, utc=False):
    

    return wrap_log_handler(logging.handlers.TimedRotatingFileHandler(
        filename, when=when, interval=interval, backupCount=backupCount,
        encoding=encoding, delay=delay, utc=utc))
534434
function logClient (logClient) {
    if (defined(logClient)) {
        // validate that log client has required methods
        requireValidLogClient(logClient)
        // set default
        immutable.defaultLogClient = logClient
        // return immutable
        return ImmutableCore
    }
    // return default value
    return immutable.defaultLogClient
}
30904
def get_function(session_factory, name, handler, runtime, role,
                 log_groups,
                 project, account_name, account_id,
                 sentry_dsn,
                 pattern="Traceback"):
    
    # Lazy import to avoid runtime dependency
    from c7n.mu import (
        LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription)

    config = dict(
        name=name,
        handler=handler,
        runtime=runtime,
        memory_size=512,
        timeout=15,
        role=role,
        description='Custodian Sentry Relay',
        events=[
            CloudWatchLogSubscription(
                session_factory, log_groups, pattern)])

    archive = PythonPackageArchive('c7n_sentry')
    archive.add_contents(
        'config.json', json.dumps({
            'project': project,
            'account_name': account_name,
            'account_id': account_id,
            'sentry_dsn': sentry_dsn,
        }))
    archive.add_contents(
        'handler.py',
        'from c7n_sentry.c7nsentry import process_log_event'
    )
    archive.close()

    return LambdaFunction(config, archive)
1350738
def get_lifecycle_config(self, headers=None):
        
        response = self.connection.make_request('GET', self.name,
                query_args='lifecycle', headers=headers)
        body = response.read()
        boto.log.debug(body)
        if response.status == 200:
            lifecycle = Lifecycle(self)
            h = handler.XmlHandler(lifecycle, self)
            xml.sax.parseString(body, h)
            return lifecycle
        else:
            raise self.connection.provider.storage_response_error(
                response.status, response.reason, body)
735434
public static Session getInstance(PageContext pc, RefBoolean isNew, Log log) {
	isNew.setValue(true);
	return new SessionMemory(pc, log);
    }
143177
static URL getStorageConfigURL() throws ConfigurationException
    {
        String configUrl = System.getProperty("cassandra.config");
        if (configUrl == null)
            configUrl = DEFAULT_CONFIGURATION;

        URL url;
        try
        {
            url = new URL(configUrl);
            url.openStream().close(); // catches well-formed but bogus URLs
        }
        catch (Exception e)
        {
            ClassLoader loader = DatabaseDescriptor.class.getClassLoader();
            url = loader.getResource(configUrl);
            if (url == null)
            {
                String required = "file:" + File.separator + File.separator;
                if (!configUrl.startsWith(required))
                    throw new ConfigurationException("Expecting URI in variable: [cassandra.config].  Please prefix the file with " + required + File.separator +
                            " for local files or " + required + "<server>" + File.separator + " for remote files. Aborting. If you are executing this from an external tool, it needs to set Config.setClientMode(true) to avoid loading configuration.");
                throw new ConfigurationException("Cannot locate " + configUrl + ".  If this is a local file, please confirm you've provided " + required + File.separator + " as a URI prefix.");
            }
        }

        return url;
    }
272946
static function maxLogrotateFiles()
    {
        if ( isset( $GLOBALS['eZDebugMaxLogrotateFiles'] ) )
        {
            return $GLOBALS['eZDebugMaxLogrotateFiles'];
        }
        else if ( defined( 'EZPUBLISH_LOG_MAX_FILE_SIZE' ) )
        {
            self::setLogrotateFiles( (int)EZPUBLISH_LOG_ROTATE_FILES );
            return (int)EZPUBLISH_LOG_ROTATE_FILES;
        }
        return self::MAX_LOGROTATE_FILES;
    }
1185057
def get_export_configuration(self, config_id):
        
        sql = (
            'SELECT uid, exportConfigId, exportType, searchString, targetURL, '
            'targetUser, targetPassword, exportName, description, active '
            'FROM archive_exportConfig WHERE exportConfigId = %s')
        return first_from_generator(
                self.generators.export_configuration_generator(sql=sql, sql_args=(config_id,)))
1044327
@Deprecated
    public LogRotator getLogRotator() {
        BuildDiscarder buildDiscarder = getBuildDiscarder();
        return buildDiscarder instanceof LogRotator ? (LogRotator) buildDiscarder : null;
    }
1299911
private TranLogConfiguration createCustomTranLogConfiguration(String recoveredServerIdentity, String logDir, boolean isPeerRecoverySupported) throws URISyntaxException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "createCustomTranLogConfiguration", new java.lang.Object[] { recoveredServerIdentity, logDir, this });

        TranLogConfiguration tlc = null;
        final java.util.Properties props = new java.util.Properties();
        java.net.URI logSettingURI = new java.net.URI(logDir);
        String scheme = logSettingURI.getScheme();
        String logSetting = logSettingURI.getAuthority();
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Scheme read from URI " + scheme + ", log setting" + logSetting);
        // For the cloud and peer recovery scenarios, we'll automatically add a suffix that matches the recoveryIdentity
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Test to see if peer recovery is supported -  ", isPeerRecoverySupported);
        if (isPeerRecoverySupported) {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Work with server recovery identity -  " + recoveredServerIdentity + ", reset current logdir");

            if (recoveredServerIdentity != null) {
                logDir = "custom://com.ibm.rls.jdbc.SQLRecoveryLogFactory?datasource=Liberty" +
                         ",tablesuffix=" + recoveredServerIdentity;
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "log dir is now -  ", logDir);
            }
        }
        props.setProperty("LOG_DIRECTORY", logDir);
        tlc = new TranLogConfiguration(logSetting, props);

        if (tc.isEntryEnabled())
            Tr.exit(tc, "createCustomTranLogConfiguration", tlc);
        return tlc;
    }
315545
function getConfig(config) {
  const logger = require('@blackbaud/skyux-logger');
  const minimist = require('minimist');
  const argv = minimist(process.argv.slice(2));
  require(`./${argv.watch ? 'watch' : 'test'}.karma.conf`)(config);
  let skyPagesConfig = require('../sky-pages/sky-pages.config').getSkyPagesConfig(argv._[0]);
  let testWebpackConfig = require('../webpack/test.webpack.config');
  const path = require('path');
  const pactServers = require('../../utils/pact-servers');

  skyPagesConfig.runtime.pactConfig = {};
  skyPagesConfig.runtime.pactConfig.providers = pactServers.getAllPactServers();
  skyPagesConfig.runtime.pactConfig.pactProxyServer = pactServers.getPactProxyServer();

  if (skyPagesConfig.skyux.pacts) {
    var i = 0;
    skyPagesConfig.skyux.pacts.forEach((pact) => {
      // set pact settings not specified in config file
      pact.log = pact.log || path.resolve(process.cwd(), 'logs', `pact-${pact.provider}.log`);
      pact.dir = pact.dir || path.resolve(process.cwd(), 'pacts');
      pact.host = pactServers.getPactServer(pact.provider).host;
      pact.port = pactServers.getPactServer(pact.provider).port;
      pact.pactFileWriteMode = pact.pactFileWriteMode || 'overwrite';

      i++;
    });
  } else {
    logger.error('No pact entry in configuration!');
  }

  config.set({
    frameworks: config.frameworks.concat('pact'),
    files: config.files.concat(path.resolve(process.cwd(), 'node_modules/@pact-foundation/pact-web',
    `pact-web.js`)),
    pact: skyPagesConfig.skyux.pacts,
    plugins: config.plugins.concat('@pact-foundation/karma-pact'),
    webpack: testWebpackConfig.getWebpackConfig(skyPagesConfig, argv)

  });

}
1145825
public static ConfigurationPersistence getOrCreateConfigurationPersistence(final LogContext logContext) {
        final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME);
        final ConfigurationPersistence result;
        synchronized (LOCK) {
            Configurator configurator = root.getAttachment(Configurator.ATTACHMENT_KEY);
            if (configurator == null) {
                configurator = new ConfigurationPersistence(logContext);
                Configurator existing = root.attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator);
                if (existing != null) {
                    configurator = existing;
                }
            }
            if (configurator instanceof ConfigurationPersistence) {
                // We have the correct configurator
                result = (ConfigurationPersistence) configurator;
            } else if (configurator instanceof PropertyConfigurator) {
                // Create a new configurator delegating to the configurator found
                result = new ConfigurationPersistence((PropertyConfigurator) configurator);
                root.attach(Configurator.ATTACHMENT_KEY, result);
            } else {
                // An unknown configurator, log a warning and replace
                LoggingLogger.ROOT_LOGGER.replacingConfigurator(configurator);
                result = new ConfigurationPersistence(logContext);
                root.attach(Configurator.ATTACHMENT_KEY, result);
            }
        }
        return result;
    }
628814
function ComponentRegistry($log, $q) {

    var self;
    var instances = [];
    var pendings = { };

    return self = {
      /**
       * Used to print an error when an instance for a handle isn't found.
       */
      notFoundError: function(handle, msgContext) {
        $log.error((msgContext || "") + 'No instance found for handle', handle);
      },
      /**
       * Return all registered instances as an array.
       */
      getInstances: function() {
        return instances;
      },

      /**
       * Get a registered instance.
       * @param handle the String handle to look up for a registered instance.
       */
      get: function(handle) {
        if (!isValidID(handle)) return null;

        var i, j, instance;
        for (i = 0, j = instances.length; i < j; i++) {
          instance = instances[i];
          if (instance.$$mdHandle === handle) {
            return instance;
          }
        }
        return null;
      },

      /**
       * Register an instance.
       * @param instance the instance to register
       * @param handle the handle to identify the instance under.
       */
      register: function(instance, handle) {
        if (!handle) return angular.noop;

        instance.$$mdHandle = handle;
        instances.push(instance);
        resolveWhen();

        return deregister;

        /**
         * Remove registration for an instance
         */
        function deregister() {
          var index = instances.indexOf(instance);
          if (index !== -1) {
            instances.splice(index, 1);
          }
        }

        /**
         * Resolve any pending promises for this instance
         */
        function resolveWhen() {
          var dfd = pendings[handle];
          if (dfd) {
            dfd.forEach(function (promise) {
              promise.resolve(instance);
            });
            delete pendings[handle];
          }
        }
      },

      /**
       * Async accessor to registered component instance
       * If not available then a promise is created to notify
       * all listeners when the instance is registered.
       */
      when : function(handle) {
        if (isValidID(handle)) {
          var deferred = $q.defer();
          var instance = self.get(handle);

          if (instance)  {
            deferred.resolve(instance);
          } else {
            if (pendings[handle] === undefined) {
              pendings[handle] = [];
            }
            pendings[handle].push(deferred);
          }

          return deferred.promise;
        }
        return $q.reject("Invalid `md-component-id` value.");
      }

    };

    function isValidID(handle){
      return handle && (handle !== "");
    }

  }
269419
def _get_config(self):
    ''''''
    filename = '{}/{}'.format(self.PLUGIN_LOGDIR, CONFIG_FILENAME)
    modified_time = os.path.getmtime(filename)

    if modified_time != self.config_last_modified_time:
      config = read_pickle(filename, default=self.previous_config)
      self.previous_config = config
    else:
      config = self.previous_config

    self.config_last_modified_time = modified_time
    return config
146602
function RotatedLog(opts) {
	var self = this
	events.EventEmitter.call(this)
	this.configure = configure
	this.write = write
	this.end = end
	this.log = log
	this.close = close
	var streamOpts
	// write function state flags
	var writeToStdoutEnabled = true
	var writeStream
	if (opts) configure(opts)

	/*
	Configure rotatedlogger
	opts: optional object
	.streamOpts: optional object: options for RotatedStream
	.stdout: optional boolean, default true
	*/
	function configure(opts) {
		if (!opts) opts = {}
		var result = {
			filename: writeStream ? writeStream.filename : null,
			stdout: writeToStdoutEnabled,
			file: !!writeStream,
			streamOpts: cloner.clone(streamOpts)
		}
		if (opts) {
			if (opts.stdout != null) writeToStdoutEnabled = opts.stdout
			if (opts.streamOpts) streamOpts = opts.streamOpts
			if (opts.file != null) {
				if (opts.file) {
					if (!writeStream) writeStream = new rotatedstream.RotatedStream(streamOpts)
						.once('error', streamErrorListener)
				} else if (writeStream) close()
			}
		}

		return result
	}

	// logging with format feature and added newlines: like console.log
	function log() {
		write(util.format.apply(this, Array.prototype.slice.call(arguments)) + '\n')
	}

	function end() {
		var args = Array.prototype.slice.call(arguments)
		var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
		write(util.format.apply(this, Array.prototype.slice.call(arguments)) + '\n', doClose)

		function doClose() {
			close.apply(self, cb)
		}
	}

	// logging of utf-8 string
	function write(s) {
		var err
		var args = Array.prototype.slice.call(arguments)
		var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
		var cbCounter = 1
		if (writeToStdoutEnabled) {
			cbCounter++
			process.stdout.write(s, stdWr)
		}
		if (writeStream) {
			cbCounter++
			writeStream.write(s, wRes)
		}
		end()

		function stdWr(e) {
			if (e) {
				if (!err) err = e
				writeToStdoutEnabled = false
				write('stdout error: ' + e.message)
				self.emit('error', e)
			}
			end()
		}

		function wRes(e) {
			if (e) {
				if (!err) err = e
				writeStream = false
				write('stream error: ' + e.message)
				self.emit('error', e)
			}
			end()
		}

		function end() {
			if (!--cbCounter)
				if (cb)
					if (err) cb(err)
					else cb()
		}
	}

	function close(cb) {
		if (writeStream) {
			var v = writeStream
			writeStream = null
			v.close(isClosed)
		}

		function isClosed(err) {
			v = null
			if (!err) {
				if (cb) cb()
			} else {
				self.emit('error', err)
				cb(err)
			}
		}
	}

	function streamErrorListener(err) {
		writeToFileEnabled = false
		writeStream = null
		write('stream error:' + err.message)
		self.emit('error', err)
	}
}
1023811
function getConfig(configPath, searchPath = process.cwd(), stopDir = homedir()) {
  const useCustomPath = !!configPath
  const explorer = cosmiconfig('cca', { sync: true, stopDir })

  try {
    const searchPathAbsolute = !useCustomPath && searchPath
    const configPathAbsolute = useCustomPath && path.join(process.cwd(), configPath)
    // search from the root of the process if the user didnt specify a config file,
    // or use the custom path if a file is passed.
    const result = explorer.load(searchPathAbsolute, configPathAbsolute)

    // dont throw if the explorer didnt find a configfile,
    // instead use default config
    const config = result ? result.config : {}
    const filepath = result ? result.filepath : {}
    if (!result) Logger.log('No config file detected, using defaults.')

    return { ...config, filepath }
  } catch (error) {
    Logger.error('An error occured while parsing your config file. Using defaults...\n\n', error.message)
  }
  return {}
}