<commit_before><?php declare(strict_types=1);
/**
 * Hummingbird Anime List Client
 *
 * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
 *
 * PHP version 7
 *
 * @package     HummingbirdAnimeClient
 * @author      <NAME> <<EMAIL>>
 * @copyright   2015 - 2017  <NAME>
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version     4.0
 * @link        https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
 */

namespace Aviat\AnimeClient\Command;

use function Aviat\AnimeClient\loadToml;

use Aura\Session\SessionFactory;
use Aviat\AnimeClient\{
	AnimeClient,
	Model,
	Util
};
use Aviat\AnimeClient\API\CacheTrait;
use Aviat\AnimeClient\API\{Kitsu, MAL};
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
use Aviat\Banker\Pool;
use Aviat\Ion\Config;
use Aviat\Ion\Di\{Container, ContainerAware};
use ConsoleKit\Command;
use ConsoleKit\Widgets\Box;
use Monolog\Handler\NullHandler;
use Monolog\Logger;

/**
 * Base class for console command setup
 */
class BaseCommand extends Command {
	use CacheTrait;
	use ContainerAware;

	/**
	 * Echo text in a box
	 *
	 * @param string $message
	 * @return void
	 */
	protected function echoBox($message)
	{
		echo "\n";
		$box = new Box($this->getConsole(), $message);
		$box->write();
		echo "\n";
	}

	/**
	 * Setup the Di container
	 *
	 * @return Container
	 */
	protected function setupContainer()
	{
		$APP_DIR = realpath(__DIR__ . '/../../app');
		$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
		$CONF_DIR = realpath("{$APP_DIR}/config/");
		require_once $APPCONF_DIR . '/base_config.php'; // $base_config

		$config = loadToml($CONF_DIR);
		$config_array = array_merge($base_config, $config);

		$di = function ($config_array) {
			$container = new Container();

			// -------------------------------------------------------------------------
			// Logging
			// -------------------------------------------------------------------------

			$app_logger = new Logger('animeclient');
			$app_logger->pushHandler(new NullHandler);
			$kitsu_request_logger = new Logger('kitsu-request');
			$kitsu_request_logger->pushHandler(new NullHandler);
			$mal_request_logger = new Logger('mal-request');
			$mal_request_logger->pushHandler(new NullHandler);
			$container->setLogger($app_logger, 'default');
			$container->setLogger($kitsu_request_logger, 'kitsu-request');
			$container->setLogger($mal_request_logger, 'mal-request');<commit_msg>Add proper logging to console commands<commit_after><?php declare(strict_types=1);
/**
 * Hummingbird Anime List Client
 *
 * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
 *
 * PHP version 7
 *
 * @package     HummingbirdAnimeClient
 * @author      <NAME> <<EMAIL>>
 * @copyright   2015 - 2017  <NAME>
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version     4.0
 * @link        https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
 */

namespace Aviat\AnimeClient\Command;

use function Aviat\AnimeClient\loadToml;

use Aura\Session\SessionFactory;
use Aviat\AnimeClient\{
	AnimeClient,
	Model,
	Util
};
use Aviat\AnimeClient\API\CacheTrait;
use Aviat\AnimeClient\API\{Kitsu, MAL};
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
use Aviat\Banker\Pool;
use Aviat\Ion\Config;
use Aviat\Ion\Di\{Container, ContainerAware};
use ConsoleKit\Command;
use ConsoleKit\Widgets\Box;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;

/**
 * Base class for console command setup
 */
class BaseCommand extends Command {
	use CacheTrait;
	use ContainerAware;

	/**
	 * Echo text in a box
	 *
	 * @param string $message
	 * @return void
	 */
	protected function echoBox($message)
	{
		echo "\n";
		$box = new Box($this->getConsole(), $message);
		$box->write();
		echo "\n";
	}

	/**
	 * Setup the Di container
	 *
	 * @return Container
	 */
	protected function setupContainer()
	{
		$APP_DIR = realpath(__DIR__ . '/../../app');
		$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
		$CONF_DIR = realpath("{$APP_DIR}/config/");
		require_once $APPCONF_DIR . '/base_config.php'; // $base_config

		$config = loadToml($CONF_DIR);
		$config_array = array_merge($base_config, $config);

		$di = function ($config_array) use ($APP_DIR) {
			$container = new Container();

			// -------------------------------------------------------------------------
			// Logging
			// -------------------------------------------------------------------------

			$app_logger = new Logger('animeclient');
			$app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE));
			$kitsu_request_logger = new Logger('kitsu-request');
			$kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE));
			$mal_request_logger = new Logger('mal-request');
			$mal_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/mal_request-cli.log', Logger::NOTICE));
			$container->setLogger($app_logger, 'default');
			$container->setLogger($kitsu_request_logger, 'kitsu-request');
			$container->setLogger($mal_request_logger, 'mal-request');
{'fraction_non_alphanumeric': 0.1910925009516559, 'fraction_numerical': 0.0049486105824134, 'mean_word_length': 3.2379032258064515, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1654845', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1662, 'n_words': 342}