<commit_before>(function() {
  'use strict';

  angular.module('arkclient.services')
    .service('toastService', ['$mdToast', 'gettextCatalog', ToastService]);

  /**
   * ToastService
   * @constructor
   */
  function ToastService($mdToast, gettextCatalog) {
    self.TypeEnum = {
      ERROR: 0,
      SUCCESS: 1,
      WARN: 2,
      LOG: 3,
      DEBUG: 4
    }

    self.TypeName = [
      'error',
      'success',
      'warn',
      'log',
      'debug'
    ]

    self.loggingType = TypeEnum.SUCCESS;
    self.hideDelay = 5000;

    function error(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.ERROR, hideDelay, stopTranslate);
    }

    function success(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.SUCCESS, hideDelay, stopTranslate);
    }

    function warn(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.WARN, hideDelay, stopTranslate);
    }

    function log(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.LOG, hideDelay, stopTranslate);
    }

    function debug(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.DEBUG, hideDelay, stopTranslate);
    }

    self.show = function(message, type, hideDelay, stopTranslate) {
      if (type > self.loggingType) {
        return;
      }
      var typeName = null;
      if (typeof self.TypeName[type] !== 'undefined') {
        typeName = self.TypeName[type];
      }
      if (!stopTranslate) {
        message = gettextCatalog.getString(message);
      }
      var toast = $mdToast.simple()
        .hideDelay(hideDelay || self.hideDelay)
        .textContent(message);
      if (typeName) {
        toast.theme(self.TypeName[type]);
      }
      $mdToast.show(toast);
      self.log(message, typeName)
    }

    self.log = function(message, typeName) {
      console.log((typeName ? typeName.toUpperCase() + ': ' : '') + message);
    }

    return {
      error: error,
      success: success,
      warn: warn,
      log: log,
      debug: debug
    };
  }
})();<commit_msg>Implement logging and config into toastService<commit_after>(function() {
  'use strict';

  var fs = require('fs');

  angular.module('arkclient.services')
    .service('toastService', ['configService', '$mdToast', 'gettextCatalog', ToastService]);

  /**
   * ToastService
   * @constructor
   */
  function ToastService(configService, $mdToast, gettextCatalog) {
    self.TypeEnum = {
      ERROR: 0,
      SUCCESS: 1,
      WARN: 2,
      LOG: 3,
      DEBUG: 4
    }

    self.TypeName = [
      'error',
      'success',
      'warn',
      'log',
      'debug'
    ]

    self.logFile = configService.getByGroupAndKey('notice', 'logFile');
    self.loggingType = configService.getByGroupAndKey('notice', 'level');
    self.hideDelay = configService.getByGroupAndKey('notice', 'defaultHideDelay');
    self.fileStream = null;

    function error(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.ERROR, hideDelay, stopTranslate);
    }

    function success(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.SUCCESS, hideDelay, stopTranslate);
    }

    function warn(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.WARN, hideDelay, stopTranslate);
    }

    function log(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.LOG, hideDelay, stopTranslate);
    }

    function debug(message, hideDelay, stopTranslate) {
      show(message, self.TypeEnum.DEBUG, hideDelay, stopTranslate);
    }

    self.show = function(message, type, hideDelay, stopTranslate) {
      if (type > self.loggingType) {
        return;
      }
      var typeName = null;
      if (typeof self.TypeName[type] !== 'undefined') {
        typeName = self.TypeName[type];
      }
      if (!stopTranslate) {
        message = gettextCatalog.getString(message);
      }
      var toast = $mdToast.simple()
        .hideDelay(hideDelay || self.hideDelay)
        .textContent(message);
      if (typeName) {
        toast.theme(self.TypeName[type]);
      }
      $mdToast.show(toast);
      self.logToFile(message, typeName)
    }

    self.logToFile = function(message, typeName) {
      if (!self.logFile) {
        return;
      }
      self.fileStream = self.fileStream || fs.createWriteStream(self.logFile, {flags: 'a+'});
      if (!self.fileStream) {
        return;
      }
      self.fileStream.write(
        '[' + new Date().toISOString() + '] ' + (typeName ? typeName.toUpperCase() + ': ' : '') + message + '\n'
      );
    }

    return {
      error: error,
      success: success,
      warn: warn,
      log: log,
      debug: debug
    };
  }
})();
{'fraction_non_alphanumeric': 0.13647008728975943, 'fraction_numerical': 0.0029806259314456036, 'mean_word_length': 2.602760736196319, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7575906', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1463, 'n_words': 282}