<commit_before>/**
 * Copyright (C) 2012 Typesafe, Inc. <http://www.typesafe.com>
 */

package org.pantsbuild.zinc

import java.io.File
import sbt.{ ConsoleLogger, Hash, IO, Level, Logger }
import scala.util.matching.Regex

object Util {

  //
  // Logging
  //

  /**
   * Create a new logger based on quiet, level, and color settings.
   */
  def logger(quiet: Boolean, level: Level.Value, color: Boolean, filters: Seq[Regex]): LoggerRaw = {
    if (quiet) {
      new SilentLogger
    } else {
      val out = ConsoleLogger.systemOut
      val consoleLogger = ConsoleLogger(out = out, useColor = ConsoleLogger.formatEnabled && color); consoleLogger.setLevel(level)
      new LoggerRaw() {
        def isFiltered(message: => String): Boolean = {
          filters.exists(_.findFirstIn(message).isDefined)
        }
        def trace(t: => Throwable): Unit = consoleLogger.trace(t)
        def success(message: => String): Unit = consoleLogger.success(message)
        def log(level: Level.Value, message: => String): Unit = {
          if (!isFiltered(message)) {
            consoleLogger.log(level, message)
          }
        }
        def logRaw(message: => String): Unit = {
          if (!isFiltered(message)) {
            out.print(message)
          }
        }
      }
    }
  }

  /**
   * A logger that does nothing.
   */
  class SilentLogger extends LoggerRaw {
    def trace(t: => Throwable): Unit = ()
    def success(message: => String): Unit = ()
    def log(level: Level.Value, message: => String): Unit = ()
    def logRaw(message: => String): Unit = ()<commit_msg>Make sure arg to logRaw and log are only eval'ed once.<commit_after>/**
 * Copyright (C) 2012 Typesafe, Inc. <http://www.typesafe.com>
 */

package org.pantsbuild.zinc

import java.io.File
import sbt.{ ConsoleLogger, ConsoleOut, Hash, IO, Level, Logger }
import scala.util.matching.Regex

object Util {

  //
  // Logging
  //

  /**
   * Create a new logger based on quiet, level, and color settings.
   */
  def logger(quiet: Boolean, level: Level.Value, color: Boolean, filters: Seq[Regex]): LoggerRaw = {
    if (quiet) {
      new SilentLogger
    } else {
      val out = ConsoleOut.systemOut
      val consoleLogger = ConsoleLogger(out = out, useColor = ConsoleLogger.formatEnabled && color); consoleLogger.setLevel(level)
      new LoggerRaw() {
        def isFiltered(message: => String): Boolean = {
          filters.exists(_.findFirstIn(message).isDefined)
        }
        def trace(t: => Throwable): Unit = consoleLogger.trace(t)
        def success(message: => String): Unit = consoleLogger.success(message)
        def log(level: Level.Value, msg: => String): Unit = {
          lazy val message = msg
          if (!isFiltered(message)) {
            consoleLogger.log(level, message)
          }
        }
        def logRaw(msg: => String): Unit = {
          lazy val message = msg
          if (!isFiltered(message)) {
            out.print(message)
          }
        }
      }
    }
  }

  /**
   * A logger that does nothing.
   */
  class SilentLogger extends LoggerRaw {
    def trace(t: => Throwable): Unit = ()
    def success(message: => String): Unit = ()
    def log(level: Level.Value, message: => String): Unit = ()
    def logRaw(message: => String): Unit = ()
{'fraction_non_alphanumeric': 0.1330694275274056, 'fraction_numerical': 0.00243605359317905, 'mean_word_length': 2.4688489968321012, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5988533', 'n_tokens_mistral': 995, 'n_tokens_neox': 970, 'n_words': 261}