<commit_before>import { LogLevel } from '../LogLevel';
import { BaseLogger, MessageDelegate } from '../Logger';
import { LogManager } from '../LogManager';

export type DelegateLoggerAction = (logger: DelegateLogger, level: LogLevel, text: string, args: any[]) => void;

export class DelegateLogger extends BaseLogger {
  constructor(private action: DelegateLoggerAction, name: string, level: LogLevel) {
    super(name, level);
  }

  log(level: LogLevel | number, textOrFn: string | MessageDelegate, ...args: any[]) {
    if (this.isEnabledFor(level)) {
      if (textOrFn instanceof Function) {
        this.action(this, level, textOrFn(), args);
      }
      else {
        this.action(this, level, textOrFn.toString(), args);
      }
    }
  }
}

export class DelegateLogManager implements LogManager {
  private action: DelegateLoggerAction;

  constructor(action: (manager: DelegateLogManager) => DelegateLoggerAction, public defaultLevel: LogLevel) {
    this.action = action(this);
  }

  getLogger(name: string, level?: LogLevel) {
    return new DelegateLogger(this.action, name, level || this.defaultLevel);
  }
}
<commit_msg>fixing bug where default level is used if LogLevel.All is passed in<commit_after>import { LogLevel } from '../LogLevel';
import { BaseLogger, MessageDelegate } from '../Logger';
import { LogManager } from '../LogManager';

export type DelegateLoggerAction = (logger: DelegateLogger, level: LogLevel, text: string, args: any[]) => void;

export class DelegateLogger extends BaseLogger {
  constructor(private action: DelegateLoggerAction, name: string, level: LogLevel) {
    super(name, level);
  }

  log(level: LogLevel | number, textOrFn: string | MessageDelegate, ...args: any[]) {
    if (this.isEnabledFor(level)) {
      if (textOrFn instanceof Function) {
        this.action(this, level, textOrFn(), args);
      }
      else {
        this.action(this, level, textOrFn.toString(), args);
      }
    }
  }
}

export class DelegateLogManager implements LogManager {
  private action: DelegateLoggerAction;

  constructor(action: (manager: DelegateLogManager) => DelegateLoggerAction, public defaultLevel: LogLevel) {
    this.action = action(this);
  }

  getLogger(name: string, level?: LogLevel) {
    return new DelegateLogger(this.action, name, level == null ? this.defaultLevel : level);
  }
}

{'fraction_non_alphanumeric': 0.12398806987643801, 'fraction_numerical': 0.0, 'mean_word_length': 4.071274298056156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6424263', 'n_tokens_mistral': 694, 'n_tokens_neox': 669, 'n_words': 191}