<commit_before><?php

namespace PhpTabs\Component;

/**
 * Log storage
 * 
 * Internal use for debugging during implementations 
 */
abstract class Log
{
  /** @var array config options */
  private static $data = array();

  /**
   * Adds a log event
   * 
   * @param string $message Text message to log
   * @param string $type optional type of log NOTICE | WARNING | ERROR
   * @return void
   */
  public static function add($message, $type = 'NOTICE')
  {
    if(Config::get('verbose'))
    {
      echo PHP_EOL . "[$type] $message";
    }

    self::$data[] = array('type' => $type, 'message' => $message);
  }

  /**
   * Counts log messages
   * 
   * @param string $type Used to filter count
   * @return integer Number of messages
   */
  public static function countLogs($type = null)
  {
    $count = 0;

    foreach(self::$data as $log)
    {
      if(null === $type || $type == $log['type'])
      {
        $count++;
      }
    }

    return $count;
  }

  /**
   * Gets last $count log messages
   * 
   * @param integer $count Number of messages to get
   * @param string $type Used to filter messages
   * @return array A list of messages
   */
  public static function tail($count = 50, $type = null)
  {
    $messages = array();
    $ptrLogs = self::countLogs($type) - 1;

    for($i = $ptrLogs; $i >= 0; $i--)
    {
      if(null === $type || $type == self::$data[$i]['type'])
      {
        array_push($messages, self::$data[$i]);

        if(count($messages) == $count)
        {
          return $messages;
        }
      }
    }

    return $messages;
  }
}<commit_msg>Add a clear method for Log component<commit_after><?php

namespace PhpTabs\Component;

/**
 * Log storage
 * 
 * Internal use for debugging during implementations 
 */
abstract class Log
{
  /** @var array config options */
  private static $data = array();

  /**
   * Adds a log event
   * 
   * @param string $message Text message to log
   * @param string $type optional type of log NOTICE | WARNING | ERROR
   * @return void
   */
  public static function add($message, $type = 'NOTICE')
  {
    if(Config::get('verbose'))
    {
      echo PHP_EOL . "[$type] $message";
    }

    self::$data[] = array('type' => $type, 'message' => $message);
  }

  /**
   * Counts log messages
   * 
   * @param string $type Used to filter count
   * @return integer Number of messages
   */
  public static function countLogs($type = null)
  {
    $count = 0;

    foreach(self::$data as $log)
    {
      if(null === $type || $type == $log['type'])
      {
        $count++;
      }
    }

    return $count;
  }

  /**
   * Gets last $count log messages
   * 
   * @param integer $count Number of messages to get
   * @param string $type Used to filter messages
   * @return array A list of messages
   */
  public static function tail($count = 50, $type = null)
  {
    $messages = array();

    $ptrLogs = self::countLogs($type) - 1;

    for($i = $ptrLogs; $i >= 0; $i--)
    {
      if(null === $type || $type == self::$data[$i]['type'])
      {
        array_push($messages, self::$data[$i]);

        if(count($messages) == $count)
        {
          return $messages;
        }
      }
    }

    return $messages;
  }

  /**
   * Delete all logged messages
   * 
   * @return void
   */
  public static function clear()
  {
    self::$data = array();
  }
}
{'fraction_non_alphanumeric': 0.15370866845397677, 'fraction_numerical': 0.002978850163836759, 'mean_word_length': 2.279296875, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5774471', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1061, 'n_words': 314}