<commit_before>/* @flow weak */

import bunyan from 'bunyan'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'

const LOG_DIR = path.join(process.env.COZY_DESKTOP_DIR || os.homedir(), '.cozy-desktop')
const LOG_FILE = path.join(LOG_DIR, 'logs.txt')

fs.ensureDirSync(LOG_DIR)

export const defaultLogger = bunyan.createLogger({
  name: 'Cozy Desktop',
  level: 'debug',
  serializers: {
    err: bunyan.stdSerializers.err
  },
  streams: [
    {
      type: 'rotating-file',
      path: LOG_FILE,
      period: '1d',
      count: 7
    }
  ]
})

function logger (options) {
  return defaultLogger.child(options)
}<commit_msg>Log to stdout on DEBUG<commit_after>/* @flow weak */

import bunyan from 'bunyan'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'

const LOG_DIR = path.join(process.env.COZY_DESKTOP_DIR || os.homedir(), '.cozy-desktop')
const LOG_FILE = path.join(LOG_DIR, 'logs.txt')

fs.ensureDirSync(LOG_DIR)

export const defaultLogger = bunyan.createLogger({
  name: 'Cozy Desktop',
  level: 'debug',
  serializers: {
    err: bunyan.stdSerializers.err
  },
  streams: [
    {
      type: 'rotating-file',
      path: LOG_FILE,
      period: '1d',
      count: 7
    }
  ]
})

if (process.env.DEBUG) {
  defaultLogger.addStream({
    stream: process.stdout,
    level: 'debug'
  })
}

function logger (options) {
  return defaultLogger.child(options)
}
{'fraction_non_alphanumeric': 0.13859275053304904, 'fraction_numerical': 0.0028429282160625444, 'mean_word_length': 3.5128205128205128, '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': '6459204', 'n_tokens_mistral': 521, 'n_tokens_neox': 509, 'n_words': 121}