<commit_before>export enum LogLevel {
  LOG_ALL,
  LOG_ERRORS,
  LOG_WARNINGS,
}
export interface ILoggerProps {
  logLevel: LogLevel;
}

function Spinner() {
  return {
    setColor: () => {},
    setText: () => {},
    start: () => {},
    stop: () => {},
  };
}

export function getLogger(props: ILoggerProps) {
  return {
    info: message => {},
    warning: message => {},
    deprecated: message => {},
    createSpinner: () => {
      return Spinner();
    },
  };
}<commit_msg>feat(logging): Added log methods & levels<commit_after>import console = require('console');
import { yellow, cyan, red, green, magenta } from './chroma';

export enum LogPriority {
  INFO = 'info',
  DEBUG = 'debug',
  ERROR = 'error',
  WARNING = 'warning',
}

export enum LogLevel {
  ERROR = 0,
  WARN = 1,
  INFO = 2,
  VERBOSE = 3,
  DEBUG = 4,
}

const logPermissions = new Map<LogLevel, LogPriority[]>();
logPermissions.set(LogLevel.VERBOSE, [LogPriority.DEBUG, LogPriority.INFO, LogPriority.WARNING, LogPriority.ERROR]);
logPermissions.set(LogLevel.DEBUG, [LogPriority.DEBUG, LogPriority.INFO, LogPriority.WARNING, LogPriority.ERROR]);
logPermissions.set(LogLevel.INFO, [LogPriority.INFO, LogPriority.WARNING, LogPriority.ERROR]);
logPermissions.set(LogLevel.WARN, [LogPriority.WARNING, LogPriority.ERROR]);
logPermissions.set(LogLevel.ERROR, [LogPriority.ERROR]);

export interface ILoggerProps {
  logLevel: LogLevel;
  withTimestamp: boolean;
}

function Spinner() {
  return {
    setColor: () => {},
    setText: () => {},
    start: () => {},
    stop: () => {},
  };
}

function log({ props, logPriority, msg }: { props: ILoggerProps; logPriority: LogPriority; msg: String }): void {
  if (props.logLevel === LogLevel.VERBOSE || logPermissions.get(props.logLevel).includes(logPriority)) {
    const logDate = new Date();
    console.log(
      `${
        props.withTimestamp
          ? `${logDate.getFullYear()}-${logDate.getMonth()}-${logDate.getDay()}
          ${logDate.getHours()}:${logDate.getMinutes()}:${logDate.getSeconds()} - `
          : ''
      }${logPriority}: ${msg}`,
    );
  }
}

export function getLogger(props: ILoggerProps) {
  return {
    debug: msg => {
      return log({ props, msg: green(msg), logPriority: LogPriority.DEBUG });
    },
    info: msg => {
      return log({ props, msg: cyan(msg), logPriority: LogPriority.INFO });
    },
    warning: msg => {
      return log({ props, msg: yellow(msg), logPriority: LogPriority.WARNING });
    },
    error: msg => {
      return log({ props, msg: red(msg), logPriority: LogPriority.ERROR });
    },
    deprecated: msg => {
      return log({ props, msg: magenta(msg), logPriority: LogPriority.WARNING });
    },
    createSpinner: () => {
      return Spinner();
    },
  };
}
{'fraction_non_alphanumeric': 0.17101449275362318, 'fraction_numerical': 0.0018115942028985507, 'mean_word_length': 3.511437908496732, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 22, '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': '734086', 'n_tokens_mistral': 878, 'n_tokens_neox': 879, 'n_words': 188}