<commit_before>'use strict';

var path = require('path');
var async = require('async');
var winston = require('winston');

var SATOSHI_FACTOR = Math.pow(10, 8);

// TODO: Define this somewhere more global
var SESSION_TIMEOUT = 60 * 60 * 1000;   // an hour

var Trader = module.exports = function (db) {
  if (!db) {
    throw new Error('`db` is required');
  }

  this.db = db;
  this.rates = {};
  this.logger = new (winston.Logger)({
    transports: [new (winston.transports.Console)({level: 'info'})]
  });

  this._tradeQueue = [];
  this._sessionInfo = {};
};

Trader.prototype._findExchange = function (name) {
  var exchange;

  try {
    exchange = require('lamassu-' + name);
  } catch (err) {
    if (!err.message.match(/Cannot find module/)) {
      throw err;
    }<commit_msg>allow configuring log level<commit_after>'use strict';

var path = require('path');
var async = require('async');
var winston = require('winston');

var SATOSHI_FACTOR = Math.pow(10, 8);

// TODO: Define this somewhere more global
var SESSION_TIMEOUT = 60 * 60 * 1000;   // an hour

var Trader = module.exports = function (db) {
  if (!db) {
    throw new Error('`db` is required');
  }

  this.db = db;
  this.rates = {};
  var logLevel = process.env.LAMASSU_ENV === 'debug' ?
    'debug' :
    'info';
  this.logger = new (winston.Logger)({
    transports: [new (winston.transports.Console)({level: logLevel})]
  });

  this._tradeQueue = [];
  this._sessionInfo = {};
};

Trader.prototype._findExchange = function (name) {
  var exchange;

  try {
    exchange = require('lamassu-' + name);
  } catch (err) {
    if (!err.message.match(/Cannot find module/)) {
      throw err;
    }
{'fraction_non_alphanumeric': 0.16656716417910447, 'fraction_numerical': 0.013134328358208954, 'mean_word_length': 3.3419689119170983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1400882', 'n_tokens_mistral': 604, 'n_tokens_neox': 563, 'n_words': 147}