Run a Sobel edge detection demonstration.

  See the summary description for more details.

  Arguments:
    logdir: Directory into which to write event logs.
    verbose: Boolean; whether to log any output.
339914
def run_sobel(logdir, verbose=False):
  
  if verbose:
    logger.info('--- Starting run: sobel')

  tf.compat.v1.reset_default_graph()
  tf.compat.v1.set_random_seed(0)

  image = get_image(verbose=verbose)
  kernel_radius = tf.compat.v1.placeholder(shape=(), dtype=tf.int32)

  with tf.name_scope('horizontal_kernel'):
    kernel_side_length = kernel_radius * 2 + 1
    # Drop off influence for pixels further away from the center.
    weighting_kernel = (
        1.0 - tf.abs(tf.linspace(-1.0, 1.0, num=kernel_side_length)))
    differentiation_kernel = tf.linspace(-1.0, 1.0, num=kernel_side_length)
    horizontal_kernel = tf.matmul(tf.expand_dims(weighting_kernel, 1),
                                  tf.expand_dims(differentiation_kernel, 0))

  with tf.name_scope('vertical_kernel'):
    vertical_kernel = tf.transpose(a=horizontal_kernel)

  float_image = tf.cast(image, tf.float32)
  dx = convolve(float_image, horizontal_kernel, name='convolve_dx')
  dy = convolve(float_image, vertical_kernel, name='convolve_dy')
  gradient_magnitude = tf.norm(tensor=[dx, dy], axis=0, name='gradient_magnitude')
  with tf.name_scope('normalized_gradient'):
    normalized_gradient = gradient_magnitude / tf.reduce_max(input_tensor=gradient_magnitude)
  with tf.name_scope('output_image'):
    output_image = tf.cast(255 * normalized_gradient, tf.uint8)

  summ = image_summary.op(
      'sobel', tf.stack([output_image]),
      display_name='Sobel edge detection',
      description=(u'Demonstration of [Sobel edge detection]. The step '
                   'parameter adjusts the radius of the kernel. '
                   'The kernel can be of arbitrary size, and considers '
                   u'nearby pixels with \u2113\u2082-linear falloff.\n\n'
                   # (that says ``$\ell_2$-linear falloff'')
                   'Edge detection is done on a per-channel basis, so '
                   'you can observe which edges are &ldquo;mostly red '
                   'edges,&rdquo; for instance.\n\n'
                   'For practical edge detection, a small kernel '
                   '(usually not more than more than *r*=2) is best.\n\n'
                   '[Sobel edge detection]: %s\n\n'
                   "%s"
                   % ('https://en.wikipedia.org/wiki/Sobel_operator',
                      IMAGE_CREDIT)))

  with tf.compat.v1.Session() as sess:
    sess.run(image.initializer)
    writer = tf.summary.FileWriter(os.path.join(logdir, 'sobel'))
    writer.add_graph(sess.graph)
    for step in xrange(8):
      if verbose:
        logger.info("--- sobel: step: %s" % step)
        feed_dict = {kernel_radius: step}
      run_options = tf.compat.v1.RunOptions(trace_level=tf.compat.v1.RunOptions.FULL_TRACE)
      run_metadata = config_pb2.RunMetadata()
      s = sess.run(summ, feed_dict=feed_dict,
                   options=run_options, run_metadata=run_metadata)
      writer.add_summary(s, global_step=step)
      writer.add_run_metadata(run_metadata, 'step_%04d' % step)
    writer.close()
702983
def _setup_logging(cls, args):
        '''
        '''
        assert (
            logging.CRITICAL >
            logging.ERROR >
            logging.WARNING >
            logging.INFO >
            logging.DEBUG >
            logging.NOTSET
        )
        assert (
            LOG_VERY_QUIET >
            LOG_QUIET >
            LOG_NO_VERBOSE >
            LOG_VERBOSE >
            LOG_DEBUG
        )
        assert args.verbosity

        root_logger = logging.getLogger()
        current_level = root_logger.getEffectiveLevel()
        min_level = LOG_VERY_QUIET

        if args.verbosity == LOG_QUIET:
            min_level = logging.ERROR

        if args.verbosity in (LOG_NO_VERBOSE, LOG_VERBOSE) \
                or args.warc_file \
                or args.output_file or args.append_output:
            min_level = logging.INFO

        if args.verbosity == LOG_DEBUG:
            min_level = logging.DEBUG

        if current_level > min_level:
            root_logger.setLevel(min_level)
            root_logger.debug(
                'Wpull needs the root logger level set to {0}.'
                    .format(min_level)
            )

        if current_level <= logging.INFO:
            logging.captureWarnings(True)
373254
function logReports (url, reports, verbose) {
    var passes = '';
    var failures = '';

    grunt.log.writeln(chalk.underline(chalk.cyan('\nReport for ' + url + '\n')));
    reports.audit.forEach(function (el) {
        if (el.result === 'PASS') {
            passes += logSymbols.success + ' ' + el.heading + '\n';
        }

        if (el.result === 'FAIL') {
            failures += logSymbols.error + ' ' + el.heading + '\n';
            failures += el.elements + '\n\n';
        }
    });

    grunt.log.writeln(indent(failures, ' ', 2));
    grunt.log.writeln(indent(passes  , ' ', 2));

    if (verbose) {
      grunt.log.writeln('VERBOSE OUTPUT\n', reports.audit);
    }

    return !failures.length;
  }
743845
def log(part, msg, verbose = false, &block)
      if !verbose || verbose && self.project.options[:verbose]
        self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + msg.to_s, nil, true
      end
      if block_given?
        begin
          self.project.shell.padding = self.project.shell.padding + 1
          yield
        ensure
          self.project.shell.padding = self.project.shell.padding - 1
        end
      end
    end
193920
def log(verbose=False):
    

    terminal.log.config(verbose=verbose)
    terminal.log.info('this is a info message')
    terminal.log.verbose.info('this is a verbose message')
126418
public void prettyPrintsReport(File logDir) throws Exception {
        if ((!logDir.exists()) || (!logDir.isDirectory())) {
            throw new Exception("Error: LOGDIR " + logDir.getAbsolutePath()
                    + " seems not a valid directory. ");
        }
        File html_logs_report_file = new File(logDir.getAbsolutePath()
                + File.separator + "report.html");
        prettyPrintsReport(logDir, html_logs_report_file);
    }
149263
function verbose() {
  var args = [LEVELS.VERBOSE].concat(slice.apply(arguments));
  return this.log.apply(this, args);
}
1312173
def set_root_logger_from_verbosity(verbosity=0):
    
    kwargs = {}
    if verbosity == 1:
        kwargs.update(level=logging.INFO)
    elif verbosity > 1:
        kwargs.update(level=logging.DEBUG)

    set_root_logger(**kwargs)
1281276
def main(output=None, error=None, verbose=False):
    
    runner = Runner(args=["--verbose"] if verbose is not False else None)
    runner.run(output, error)
177777
private void processLoggingEvents(List<LoggingEvent> loggingEvents) {
        // Lazy initialization of the appender. This is needed because the
        // original appenders configuration may be available only after the
        // complete
        // log4j initialization.
        while (appenders.getAllAppenders() == null) {
            if ((batcher == null) || (batcher.isPaused())) {
                try {
                    Thread.sleep(SLEEP_TIME_MS);
                } catch (InterruptedException ignore) {

                }
                continue;
            }

            org.apache.log4j.Logger asyncLogger = LoggerCache.getInstance()
                    .getOrCreateLogger(LOGGER_ASYNC_APPENDER);
            Appender originalAppender = asyncLogger
                    .getAppender(originalAppenderName);
            if (originalAppender == null) {
                try {
                    Thread.sleep(SLEEP_TIME_MS);
                } catch (InterruptedException ignore) {

                }
                continue;
            }
            appenders.addAppender(originalAppender);
        }
        // First take the overflown summary events and put it back in the queue
        for (Iterator<Entry<String, LogSummary>> iter = logSummaryMap
                .entrySet().iterator(); iter.hasNext();) {
            Entry<String, LogSummary> mapEntry = (Entry<String, LogSummary>) iter
                    .next();
            // If the space is not available, then exit immediately
            if (batcher.isSpaceAvailable()) {
                LogSummary logSummary = mapEntry.getValue();
                LoggingEvent event = logSummary.createEvent();
                // Put the event in the queue and remove the event from the summary
                if (batcher.process(event)) {
                    iter.remove();
                } else {
                    break;
                }
            } else {
                break;
            }

        }
        // Process the events from the queue and call the underlying
        // appender
        for (LoggingEvent event : loggingEvents) {
            appenders.appendLoopOnAppenders(event);

        }

    }
315362
def _allowed_to_proceed(self, verbose):
        

        def _display(msg, paths):
            if not paths:
                return

            logger.info(msg)
            with indent_log():
                for path in sorted(compact(paths)):
                    logger.info(path)

        if not verbose:
            will_remove, will_skip = compress_for_output_listing(self.paths)
        else:
            # In verbose mode, display all the files that are going to be
            # deleted.
            will_remove = list(self.paths)
            will_skip = set()

        _display('Would remove:', will_remove)
        _display('Would not remove (might be manually added):', will_skip)
        _display('Would not remove (outside of prefix):', self._refuse)
        if verbose:
            _display('Will actually move:', compress_for_rename(self.paths))

        return ask('Proceed (y/n)? ', ('y', 'n')) == 'y'
938596
def main(_):
  """"""
  utility.set_up_logging()
  if not FLAGS.logdir or not FLAGS.outdir:
    raise KeyError('You must specify logging and outdirs directories.')
  FLAGS.logdir = os.path.expanduser(FLAGS.logdir)
  FLAGS.outdir = os.path.expanduser(FLAGS.outdir)
  visualize(
      FLAGS.logdir, FLAGS.outdir, FLAGS.num_agents, FLAGS.num_episodes,
      FLAGS.checkpoint, FLAGS.env_processes)
997272
def run_all(logdir, verbose=False):
  
  waves = [sine_wave, square_wave, triangle_wave,
           bisine_wave, bisine_wahwah_wave]
  for (i, wave_constructor) in enumerate(waves):
    wave_name = wave_constructor.__name__
    run_name = 'wave:%02d,%s' % (i + 1, wave_name)
    if verbose:
      print('--- Running: %s' % run_name)
    run(logdir, run_name, wave_name, wave_constructor)
682678
def register_logger(self, logger):
        
        handler = CommandHandler(self)
        handler.setFormatter(CommandFormatter())
        logger.handlers = [handler]
        logger.propagate = False

        output = self.output
        level = logging.WARNING
        if output.is_debug():
            level = logging.DEBUG
        elif output.is_very_verbose() or output.is_verbose():
            level = logging.INFO

        logger.setLevel(level)
175001
def execute(self):
        
        from vsgen.util.logger import VSGLogger

        VSGLogger.info(self._logname, self._message)
        start = time.clock()
        VSGWriter.write(self._writables, self._parallel)
        end = time.clock()
        VSGLogger.info(self._logname, "Wrote %s files in %s seconds:", len(self._writables), end - start)
1175615
def log_events
      logger = Logging.logger[target.name]
      if (logs = value.dig('report', 'logs'))
        logs.each do |log|
          case log["level"]
          when 'err'
            logger.error(log['message'])
          when 'warn'
            logger.info(log['message'])
          when 'notice'
            logger.notice(log['message'])
          when 'info'
            logger.info(log['message'])
          else
            logger.debug(log["message"])
          end
        end
      end
    end
1174356
def init_logger(root_dir, name="train.log"):
    
    os.makedirs(root_dir, exist_ok=True)
    log_formatter = logging.Formatter("%(message)s")
    logger = logging.getLogger(name)
    file_handler = logging.FileHandler("{0}/{1}".format(root_dir, name), mode='w')
    file_handler.setFormatter(log_formatter)
    logger.addHandler(file_handler)
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(log_formatter)
    logger.addHandler(console_handler)
    logger.setLevel(logging.INFO)
    return logger