<commit_before>
#include "Log.hpp"
#include <stdexcept>
#include <iostream>


Log::Log()
{
  fout.open("Browser/TorBrowser/OnioNS/events.log",
            std::fstream::out | std::fstream::app);
}


void Log::notice(const std::string& str)
{
  log("notice", str);
}



void Log::warn(const std::string& str)
{
  log("warn", str);
}



void Log::error(const std::string& str)
{
  log("error", str);
  throw std::runtime_error(str);
}



void Log::log(const std::string& type, const std::string& str)
{
  fout << "[" << type << "] " << str << std::endl;
}



/*
Log::Notice& Log::Notice::operator<<(int i)
{
  std::cout << i << std::endl;
  return *this;
}


Env::Notice& Env::Notice::operator>>(std::string& str)
{
  return *this;
}*/
<commit_msg>log to cout if cannot open logfile<commit_after>
#include "Log.hpp"
#include <stdexcept>
#include <iostream>


Log::Log()
{
  fout.open("Browser/TorBrowser/OnioNS/events.log",
            std::fstream::out | std::fstream::app);

  if (fout.is_open())
  {
    notice("Successfully opened log file.");
    std::cout << "Opened log file, further output will be there." << std::endl;
  }
  else
  {
    std::cout << "Error opening file";
  }
}


void Log::notice(const std::string& str)
{
  log("notice", str);
}



void Log::warn(const std::string& str)
{
  log("warn", str);
}



void Log::error(const std::string& str)
{
  log("error", str);
  throw std::runtime_error(str);
}



void Log::log(const std::string& type, const std::string& str)
{
  if (fout.is_open())
    fout << "[" << type << "] " << str << std::endl;
  else
    std::cout << "[" << type << "] " << str << std::endl;
}



/*
Log::Notice& Log::Notice::operator<<(int i)
{
  std::cout << i << std::endl;
  return *this;
}


Env::Notice& Env::Notice::operator>>(std::string& str)
{
  return *this;
}*/

{'fraction_non_alphanumeric': 0.21799116997792495, 'fraction_numerical': 0.0, 'mean_word_length': 3.994490358126722, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 11, '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': '4684804', 'n_tokens_mistral': 708, 'n_tokens_neox': 676, 'n_words': 145}