<commit_before>require "thread"
require "scrolls/atomic"
require "scrolls/log"
require "scrolls/version"

module Scrolls
  extend self

  # Public: Set a context in a block for logs
  #
  # data - A hash of key/values to prepend to each log in a block
  # blk  - The block that our context wraps
  #
  # Examples:
  #
  def context(data, &blk)
    Log.with_context(data, &blk)
  end

  # Public: Get or set a global context that prefixs all logs
  #
  # data - A hash of key/values to prepend to each log
  #
  def global_context(data=nil)
    if data
      Log.global_context = data
    else
      Log.global_context
    end
  end

  def add_global_context(data)
    Log.add_global_context(data)
  end

  # Public: Log data and/or wrap a block with start/finish
  #
  # data - A hash of key/values to log
  # blk  - A block to be wrapped by log lines
  #
  # Examples:
  #
  #   Scrolls.log(test: "test")
  #   test=test
  #   => nil
  #
  #   Scrolls.log(test: "test") { puts "inner block" }
  #   at=start
  #   inner block
  #   at=finish elapsed=0.000
  #   => nil
  #
  def log(data, &blk)
    Log.log(data, &blk)
  end

  # Public: Log an exception
  #
  # data - A hash of key/values to log
  # e    - An exception to pass to the logger
  #
  # Examples:
  #
  #   begin
  #     raise Exception
  #   rescue Exception => e
  #     Scrolls.log_exception({test: "test"}, e)
  #   end
  #   test=test at=exception class=Exception message=Exception exception_id=70321999017240
  #   ...
  #
  def log_exception(data, e)
    Log.log_exception(data, e)
  end

  # Public: Setup a logging facility (default: Syslog::LOG_USER)<commit_msg>Fix up method docs.<commit_after>require "thread"
require "scrolls/atomic"
require "scrolls/log"
require "scrolls/version"

module Scrolls
  extend self

  # Public: Set a context in a block for logs
  #
  # data - A hash of key/values to prepend to each log in a block
  # blk  - The block that our context wraps
  #
  # Examples:
  #
  def context(data, &blk)
    Log.with_context(data, &blk)
  end

  # Public: Get or set a global context that prefixs all logs
  #
  # data - A hash of key/values to prepend to each log
  #
  def global_context(data=nil)
    if data
      Log.global_context = data
    else
      Log.global_context
    end
  end

  def add_global_context(data)
    Log.add_global_context(data)
  end

  # Public: Log data and/or wrap a block with start/finish
  #
  # data - A hash of key/values to log
  # blk  - A block to be wrapped by log lines
  #
  # Examples:
  #
  #   Scrolls.log(test: "test")
  #   test=test
  #   => nil
  #
  #   Scrolls.log(test: "test") { puts "inner block" }
  #   test=test at=start
  #   inner block
  #   test=test at=finish elapsed=0.000
  #   => nil
  #
  def log(data, &blk)
    Log.log(data, &blk)
  end

  # Public: Log an exception
  #
  # data - A hash of key/values to log
  # e    - An exception to pass to the logger
  #
  # Examples:
  #
  #   begin
  #     raise Exception
  #   rescue Exception => e
  #     Scrolls.log_exception({test: "test"}, e)
  #   end
  #   test=test at=exception class=Exception message=Exception exception_id=70321999017240
  #   ...
  #
  def log_exception(data, e)
    Log.log_exception(data, e)
  end

  # Public: Setup a logging facility (default: Syslog::LOG_USER)
{'fraction_non_alphanumeric': 0.10024227740763174, 'fraction_numerical': 0.010902483343428226, 'mean_word_length': 2.563106796116505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2075838', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1154, 'n_words': 360}