<commit_before>defmodule Farmbot.Logger do
  @moduledoc """
  Log messages to Farmot endpoints.
  """
  use GenStage

  def format_logs do
    RingLogger.get()
    Enum.map(fn({level, {_logger, message, timestamp_tup, _meta}}) ->
      # {{year, month, day}, {hour, minute, second, _}} = timestamp_tup
      timestamp  = Timex.to_datetime(timestamp_tup) |> DateTime.to_iso8601()
      reg = ~r/\x1B\[[0-?]*[ -\/]*[@-~]/

      "[#{level} #{timestamp}] - #{Regex.replace(reg, to_string(message), "")}"
    end)
  end

  @doc "Send a debug message to log endpoints"
  defmacro debug(verbosity, message, meta \\ []) do
    quote bind_quoted: [verbosity: verbosity, message: message, meta: meta] do
      Farmbot.Logger.dispatch_log(__ENV__, :debug, verbosity, message, meta)
    end
  end

  @doc "Send an info message to log endpoints"
  defmacro info(verbosity, message, meta \\ []) do
    quote bind_quoted: [verbosity: verbosity, message: message, meta: meta] do
      Farmbot.Logger.dispatch_log(__ENV__, :info, verbosity, message, meta)
    end
  end

  @doc "Send an busy message to log endpoints"
  defmacro busy(verbosity, message, meta \\ []) do<commit_msg>Fix syntax error.<commit_after>defmodule Farmbot.Logger do
  @moduledoc """
  Log messages to Farmot endpoints.
  """
  use GenStage

  def format_logs do
    RingLogger.get()
    |> Enum.map(fn({level, {_logger, message, timestamp_tup, _meta}}) ->
      # {{year, month, day}, {hour, minute, second, _}} = timestamp_tup
      timestamp  = Timex.to_datetime(timestamp_tup) |> DateTime.to_iso8601()
      reg = ~r/\x1B\[[0-?]*[ -\/]*[@-~]/

      "[#{level} #{timestamp}] - #{Regex.replace(reg, to_string(message), "")}"
    end)
  end

  @doc "Send a debug message to log endpoints"
  defmacro debug(verbosity, message, meta \\ []) do
    quote bind_quoted: [verbosity: verbosity, message: message, meta: meta] do
      Farmbot.Logger.dispatch_log(__ENV__, :debug, verbosity, message, meta)
    end
  end

  @doc "Send an info message to log endpoints"
  defmacro info(verbosity, message, meta \\ []) do
    quote bind_quoted: [verbosity: verbosity, message: message, meta: meta] do
      Farmbot.Logger.dispatch_log(__ENV__, :info, verbosity, message, meta)
    end
  end

  @doc "Send an busy message to log endpoints"
  defmacro busy(verbosity, message, meta \\ []) do
{'fraction_non_alphanumeric': 0.14346895074946467, 'fraction_numerical': 0.005139186295503212, 'mean_word_length': 3.5893909626719056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '4864812', 'n_tokens_mistral': 797, 'n_tokens_neox': 765, 'n_words': 219}