<commit_before>colors = require('colors')
EventEmitter2 = require('eventemitter2').EventEmitter2
tracer = require('tracer')

loggerColorFilters =
  # log : colors.black,
  trace : colors.magenta,
  debug : colors.blue,
  info : colors.green,
  warn : colors.yellow,
  error : [ colors.red, colors.bold ]

module.exports = class AppSpine extends EventEmitter2
  logger: null

  constructor: (@config = {}) ->
    @config.emitter ?= {}
    super @config.emitter
    @setupLogger()

  isDev: -> @getEnv() is 'development'

  configure: (env, fn) -> fn() if @getEnv() is env

  getEnv: ->
    process.env.NODE_ENV or 'development'

  require: (path) ->
    require(path)(@)

  setupLogger: ->
    @config.logger ?= {}
    @config.logger.format ?= "[{{title}}] {{timestamp}} ({{file}}:{{line}}): {{message}}"
    @config.logger.filters ?= loggerColorFilters
    @config.logger.dateformat ?= "HH:MM:ss"

    unless @config.logger.level?
      @config.logger.level = if @isDev() then 'log' else 'warn'

    @logger = tracer.colorConsole @config.logger<commit_msg>adds environment specific methods<commit_after>colors = require('colors')
EventEmitter2 = require('eventemitter2').EventEmitter2
tracer = require('tracer')

loggerColorFilters =
  # log : colors.black,
  trace : colors.magenta,
  debug : colors.blue,
  info : colors.green,
  warn : colors.yellow,
  error : [ colors.red, colors.bold ]

module.exports = class AppSpine extends EventEmitter2
  logger: null

  constructor: (@config = {}) ->
    @config.emitter ?= {}
    super @config.emitter
    @setupLogger()

  getEnvironment: ->
    @config.env or process.env.NODE_ENV or 'development'

  getEnv: ->
    @getEnvironment()

  isDevelopment: ->
    @getEnvironment() is 'development'

  isDev: ->
    @isDevelopment()

  isTesting: ->
    @getEnvironment() is 'testing'

  isStaging: ->
    @getEnvironment() is 'staging'

  isProduction: ->
    @getEnvironment() is 'production'

  isProd: ->
    @isProduction()

  configure: (env, fn) ->
    fn() if @getEnvironment() is env

  require: (path) ->
    require(path)(@)

  setupLogger: ->
    @config.logger ?= {}
    @config.logger.format ?= "[{{title}}] {{timestamp}} ({{file}}:{{line}}): {{message}}"
    @config.logger.filters ?= loggerColorFilters
    @config.logger.dateformat ?= "HH:MM:ss"
    @config.logger.level ?= if @isDev() then 'log' else 'warn'

    @logger = tracer.colorConsole @config.logger
{'fraction_non_alphanumeric': 0.16335814722911496, 'fraction_numerical': 0.0033085194375516956, 'mean_word_length': 3.6340996168582373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2598459', 'n_tokens_mistral': 811, 'n_tokens_neox': 781, 'n_words': 170}