<commit_before><?php

/**
 * Mmi Framework (https://github.com/milejko/mmi.git)
 * 
 * @link       https://github.com/milejko/mmi.git
 * @copyright  Copyright (c) 2010-2015 <NAME> (http://milejko.com)
 * @license    http://milejko.com/new-bsd.txt New BSD License
 */

namespace Mmi\Log;

use Monolog\Logger;
use Monolog\Handler;

/**
 * Klasa nakładki na Monolog
 */
class LoggerHelper {

	/**
	 * Monolog instance to hold and use
	 * @var \Monolog\Logger
	 */
	protected static $_loggerInstance;
	
	/**
	 * Konfiguracja loggera
	 * @var Config
	 */
	protected static $_config;
	
	/**
	 * Ustawia konfigurację loggera
	 * @param \Mmi\Logger\Config $config
	 */
	public static function setConfig(Config $config) {
		self::$_config = $config;
	}
	
	/**
	 * Zwraca poziom logowania
	 * @return integer
	 */
	public static function getLevel() {
		if (!self::$_config) {
			throw new Exception('Configuration not loaded');
		}
		return self::$_config->level;
	}
	
	/**
	 * Zwraca instancję helpera logowania
	 * @return \Monolog\Logger
	 */
	public static function getLogger() {
		if (self::$_loggerInstance) {
			return self::$_loggerInstance;
		}
		//konfiguruje loggera
		return self::$_loggerInstance = self::_configureLogger();
	}
	
	/**
	 * Konfiguruje loggera
	 * @return \Mmi\Logger\LoggerHelper
	 */
	private static function _configureLogger() {
		if (!self::$_config) {
			throw new Exception('Configuration not loaded');
		}
		//nowy obiekt loggera
		$logger = new Logger(self::$_config->name);
		//wybór handlera
		switch (self::$_config->handler) {
			case 'stream':
				$logger->pushHandler(new Handler\StreamHandler(self::$_config->path, self::$_config->level));
				break;
			case 'gelf':
				$logger->pushHandler(new Handler\GelfHandler(new \Gelf\Publisher(self::$_config->path)));
				break;
			case 'slack':
				$logger->pushHandler(new Handler\SlackHandler(self::$_config->token, self::$_config->path, self::$_config->name, false, '😂', self::$_config->level));
				break;
			default:
				throw new Exception('Unknown handler');
		}
		return $logger;<commit_msg>console support for loggerHelper<commit_after><?php

/**
 * Mmi Framework (https://github.com/milejko/mmi.git)
 * 
 * @link       https://github.com/milejko/mmi.git
 * @copyright  Copyright (c) 2010-2015 <NAME> (http://milejko.com)
 * @license    http://milejko.com/new-bsd.txt New BSD License
 */

namespace Mmi\Log;

use Monolog\Logger;
use Monolog\Handler;

/**
 * Klasa nakładki na Monolog
 */
class LoggerHelper {

	/**
	 * Monolog instance to hold and use
	 * @var \Monolog\Logger
	 */
	protected static $_loggerInstance;
	
	/**
	 * Konfiguracja loggera
	 * @var Config
	 */
	protected static $_config;
	
	/**
	 * Ustawia konfigurację loggera
	 * @param \Mmi\Logger\Config $config
	 */
	public static function setConfig(Config $config) {
		self::$_config = $config;
	}
	
	/**
	 * Zwraca poziom logowania
	 * @return integer
	 */
	public static function getLevel() {
		if (!self::$_config) {
			throw new Exception('Configuration not loaded');
		}
		return self::$_config->level;
	}
	
	/**
	 * Zwraca instancję helpera logowania
	 * @return \Monolog\Logger
	 */
	public static function getLogger() {
		if (self::$_loggerInstance) {
			return self::$_loggerInstance;
		}
		//konfiguruje loggera
		return self::$_loggerInstance = self::_configureLogger();
	}
	
	/**
	 * Konfiguruje loggera
	 * @return \Mmi\Logger\LoggerHelper
	 */
	private static function _configureLogger() {
		if (!self::$_config) {
			throw new Exception('Configuration not loaded');
		}
		//nowy obiekt loggera
		$logger = new Logger(self::$_config->name);
		//wybór handlera
		switch (self::$_config->handler) {
			case 'stream':
				$logger->pushHandler(new Handler\StreamHandler(self::$_config->path, self::$_config->level));
				break;
			case 'gelf':
				$logger->pushHandler(new Handler\GelfHandler(new \Gelf\Publisher(self::$_config->path)));
				break;
			case 'slack':
				$logger->pushHandler(new Handler\SlackHandler(self::$_config->token, self::$_config->path, self::$_config->name, false, '😂', self::$_config->level));
				break;
			case 'console':
				$logger->pushHandler(new Handler\PHPConsoleHandler([], null, self::$_config->level));
				break;
			default:
				throw new Exception('Unknown handler');
		}
		return $logger;
{'fraction_non_alphanumeric': 0.15520857608948962, 'fraction_numerical': 0.0037287345607084597, 'mean_word_length': 3.700985761226725, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 4, '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': '1049942', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1406, 'n_words': 311}