<commit_before>import * as winston from 'winston'
require('winston-daily-rotate-file')

import { ElectronConsole } from './electron-console'

import { getUserDataPath } from '../../ui/lib/app-proxy'

function getLogFilePath(): string {
  return `${getUserDataPath()}\\desktop.${process.env.NODE_ENV || 'production'}.log`
}

interface ILogger {
  debug: (message: string) => void,
  info: (message: string) => void,
  error: (message: string, error?: Error) => void
}

let logger: ILogger | null = null

function create() {
  if (process.env.NODE_ENV === 'development') {
    winston.configure({
      transports: [
        new ElectronConsole(),
      ],
    })
  } else {
    winston.configure({
      transports: [
        // only log errors to the console
        new ElectronConsole({
          level: 'error',
        }),
        new winston.transports.DailyRotateFile({
          filename: getLogFilePath(),
          humanReadableUnhandledException: true,
          handleExceptions: true,
          json: false,
          datePattern: 'yyyy-MM-dd.',
          prepend: true,
          // log everything interesting (info and up)
          level: 'info',
        }),
      ],
    })
  }

  return {
    debug: function(message: string) {
      winston.debug(message)
    },
    info: function(message: string) {
      winston.info(message)
    },
    error: function(message: string, error?: Error) {
      if (error) {
        winston.error(message, { error: error })
      } else {
        winston.error(message)
      }
    },
  }
}

export function getLogger(): ILogger {
  if (!logger) {
    logger = create()
  }
  return logger
}<commit_msg>cleanup signature<commit_after>import * as winston from 'winston'
require('winston-daily-rotate-file')

import { ElectronConsole } from './electron-console'

import { getUserDataPath } from '../../ui/lib/app-proxy'

function getLogFilePath(): string {
  return `${getUserDataPath()}\\desktop.${process.env.NODE_ENV || 'production'}.log`
}

interface ILogger {
  debug: (message: string) => void,
  info: (message: string) => void,
  error: (message: string, error?: Error) => void
}

let logger: ILogger | null = null

function create() {
  if (process.env.NODE_ENV === 'development') {
    winston.configure({
      transports: [
        new ElectronConsole(),
      ],
    })
  } else {
    winston.configure({
      transports: [
        // only log errors to the console
        new ElectronConsole({
          level: 'error',
        }),
        new winston.transports.DailyRotateFile({
          filename: getLogFilePath(),
          humanReadableUnhandledException: true,
          handleExceptions: true,
          json: false,
          datePattern: 'yyyy-MM-dd.',
          prepend: true,
          // log everything interesting (info and up)
          level: 'info',
        }),
      ],
    })
  }

  return {
    debug: (message: string) => winston.debug(message),
    info: (message: string) => winston.info(message),
    error: (message: string, error?: Error) => {
      if (error) {
        winston.error(message, { error: error })
      } else {
        winston.error(message)
      }
    },
  }
}

export function getLogger(): ILogger {
  if (!logger) {
    logger = create()
  }
  return logger
}
{'fraction_non_alphanumeric': 0.14124121063894834, 'fraction_numerical': 0.0, 'mean_word_length': 2.41901776384535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '6859364', 'n_tokens_mistral': 990, 'n_tokens_neox': 974, 'n_words': 233}