<commit_before>#!/usr/bin/env node

'use strict';

const utils = require('../lib/utils');
const storj = require('storj-lib');
const Logger = require('kad-logger-json');
const Telemetry = require('storj-telemetry-reporter');
const config = JSON.parse(JSON.stringify(require('../lib/config/farmer')));
const bytes = require('bytes');
const processIsManaged = typeof process.send === 'function';

let spaceAllocation = bytes.parse(config.storageAllocation);
let farmerState = {
  percentUsed: '...',
  spaceUsed: '...',
  totalPeers: 0,
  lastActivity: Date.now()
};

config.keyPair = new storj.KeyPair(config.networkPrivateKey);
config.logger = new Logger(config.loggerVerbosity);
config.storageManager = new storj.StorageManager(
  new storj.EmbeddedStorageAdapter(config.storagePath),
  {
    maxCapacity: spaceAllocation
  }
);

const farmer = storj.Farmer(config);

config.logger.on('log', () => farmerState.lastActivity = Date.now());
config.logger.pipe(process.stdout);
farmer.join((err) => {
  if (err) {
    config.logger.error(err.message);
    process.exit(1);
  }
});
<commit_msg>add logging to storage manager<commit_after>#!/usr/bin/env node

'use strict';

const utils = require('../lib/utils');
const storj = require('storj-lib');
const Logger = require('kad-logger-json');
const Telemetry = require('storj-telemetry-reporter');
const config = JSON.parse(JSON.stringify(require('../lib/config/farmer')));
const bytes = require('bytes');
const processIsManaged = typeof process.send === 'function';

let spaceAllocation = bytes.parse(config.storageAllocation);
let farmerState = {
  percentUsed: '...',
  spaceUsed: '...',
  totalPeers: 0,
  lastActivity: Date.now()
};

config.keyPair = new storj.KeyPair(config.networkPrivateKey);
config.logger = new Logger(config.loggerVerbosity);
config.storageManager = new storj.StorageManager(
  new storj.EmbeddedStorageAdapter(config.storagePath),
  {
    maxCapacity: spaceAllocation,
    logger: config.logger
  }
);

const farmer = storj.Farmer(config);

config.logger.on('log', () => farmerState.lastActivity = Date.now());
config.logger.pipe(process.stdout);
farmer.join((err) => {
  if (err) {
    config.logger.error(err.message);
    process.exit(1);
  }
});

{'fraction_non_alphanumeric': 0.16696669666966696, 'fraction_numerical': 0.0018001800180018, 'mean_word_length': 5.008108108108108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '61628', 'n_tokens_mistral': 719, 'n_tokens_neox': 712, 'n_words': 132}