<commit_before>#prefs = require 'util/prefs'
#
# NOTE: instead of using `require' for all these we lazy-load them,
# otherwise `logger' will not be available for them since, duh, we're
# the logger and haven't loaded yet.
#
isTainted = (args...) ->
  {isTainted} = require 'lang/type'
  isTainted args...
untaint = (args...) ->
  {untaint} = require 'util/privacy'
  untaint args...
getPref = (args...) ->
  getPref = (require 'util/prefs').get
  getPref args...
Colorizer = null

loggersByName = {}

LEVELS =
  radioactive: 0
  debug:       1
  info:        2
  warn:        3
  error:       4
  fatal:       5

COLORS =
  radioactive: ['cyan', 'bold']
  debug:       ['black']
  info:        ['bold']
  warn:        ['yellow']
  error:       ['red']
  fatal:       ['red', 'bold']

levelNameForCode = (level) ->
  return level if typeof level is 'string'

  for own key, value of LEVELS
    return key if value is level

  return null

levelCodeForName = (name) ->
  return name if typeof name is 'number'
  LEVELS[name]

class Logger
  @LEVELS: LEVELS

  #
  # Level is how much attention you should pay to something.
  # The higher the level, the more attention you should pay.
  #
  @::__defineGetter__ 'level', ->
    @_level ? @_parent?._level ? levelCodeForName getPref('wesabe.logger.level') ? LEVELS.debug

  @::__defineSetter__ 'level', (level) ->
    @_level = (levelCodeForName level) ? level

  @::__defineGetter__ 'levelName', ->
    levelNameForCode @level

  #
  # Appenders append text to things, like stdout or a file.
  #
  @::__defineGetter__ 'appender', ->
    @_appender or @_parent?._appender or (text) -> dump "#{text}\n"

  @::__defineSetter__ 'appender', (appender) ->
    @_appender = appender

  #
  # Printers take objects and turn them into pretty text.
  #
  @::__defineGetter__ 'printer', ->
    @_printer or @_parent?._printer or (object) -> "#{object}"<commit_msg>Add console.log as an appender fallback before dump().<commit_after>#prefs = require 'util/prefs'
#
# NOTE: instead of using `require' for all these we lazy-load them,
# otherwise `logger' will not be available for them since, duh, we're
# the logger and haven't loaded yet.
#
isTainted = (args...) ->
  {isTainted} = require 'lang/type'
  isTainted args...
untaint = (args...) ->
  {untaint} = require 'util/privacy'
  untaint args...
getPref = (args...) ->
  getPref = (require 'util/prefs').get
  getPref args...
Colorizer = null

loggersByName = {}

LEVELS =
  radioactive: 0
  debug:       1
  info:        2
  warn:        3
  error:       4
  fatal:       5

COLORS =
  radioactive: ['cyan', 'bold']
  debug:       ['black']
  info:        ['bold']
  warn:        ['yellow']
  error:       ['red']
  fatal:       ['red', 'bold']

levelNameForCode = (level) ->
  return level if typeof level is 'string'

  for own key, value of LEVELS
    return key if value is level

  return null

levelCodeForName = (name) ->
  return name if typeof name is 'number'
  LEVELS[name]

class Logger
  @LEVELS: LEVELS

  #
  # Level is how much attention you should pay to something.
  # The higher the level, the more attention you should pay.
  #
  @::__defineGetter__ 'level', ->
    @_level ? @_parent?._level ? levelCodeForName getPref('wesabe.logger.level') ? LEVELS.debug

  @::__defineSetter__ 'level', (level) ->
    @_level = (levelCodeForName level) ? level

  @::__defineGetter__ 'levelName', ->
    levelNameForCode @level

  #
  # Appenders append text to things, like stdout or a file.
  #
  @::__defineGetter__ 'appender', ->
    @_appender or @_parent?._appender or
      (console?.log and (text) -> console.log text) or
      (text) -> dump "#{text}\n"

  @::__defineSetter__ 'appender', (appender) ->
    @_appender = appender

  #
  # Printers take objects and turn them into pretty text.
  #
  @::__defineGetter__ 'printer', ->
    @_printer or @_parent?._printer or (object) -> "#{object}"
{'fraction_non_alphanumeric': 0.1371794871794872, 'fraction_numerical': 0.003076923076923077, 'mean_word_length': 2.9245472837022133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '3099252', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1313, 'n_words': 410}