<commit_before>import winston from "winston"

import { environment, isDevelopment } from "./environment"

export default function(service) {
  const logger = winston.createLogger({
    level: isDevelopment() ? "debug" : "info",
    format: winston.format.json(),
    defaultMeta: {
      environment,
      service: `bughouse-${service}`
    },
    transports: [
      new winston.transports.File({ filename: `log/${environment}.log` })
    ]
  })

  if (isDevelopment()) {
    process.on("uncaughtException", logger.error.bind(logger))

    logger.add(new winston.transports.Console({
      format: winston.format.simple()
    }))
  }

  return logger<commit_msg>improve uncaught exception handling<commit_after>import winston from "winston"

import { environment, isDevelopment } from "./environment"

export default function(service) {
  const logger = winston.createLogger({
    level: isDevelopment() ? "debug" : "info",
    format: winston.format.json(),
    defaultMeta: {
      environment,
      service: `bughouse-${service}`
    },
    transports: [
      new winston.transports.File({ filename: `log/${environment}.log` })
    ],
    exceptionHandlers: [
      new winston.transports.File({ filename: `log/${environment}.log` })
    ]
  })

  if (isDevelopment()) {
    logger.add(new winston.transports.Console({
      format: winston.format.simple()
    }))

    logger.exceptions.handle(new winston.transports.Console({
      format: winston.format.simple()
    }))
  }

  return logger
{'fraction_non_alphanumeric': 0.14323784143904064, 'fraction_numerical': 0.0, 'mean_word_length': 3.4176470588235293, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4893068', 'n_tokens_mistral': 471, 'n_tokens_neox': 442, 'n_words': 89}