/** * Construct the handler to log to files. The config array will be check * because all configs are strict * * @param array $config */ public function __construct(array $config) { if (!array_key_exists('path', $config)) { throw new Exception('You must define \'path\' in file log driver config options at least with null'); } if (!isset($config['log']) || !is_array($config['log'])) { throw new Exception('You must define \'log\' levels in file log driver config options at least with empty array'); } if (isset($config['email_on']) && !is_array($config['email_on'])) { throw new Exception('If \'email_on\' is defined, then it has to be an array'); } if (!isset($config['email_on'])) { $config['email_on'] = array(); } if (!array_key_exists('email', $config)) { $config['email'] = null; } if (!isset($config['dump'])) { $config['dump'] = array(); } if (isset($config['get_message_fn'])) { if (is_object($config['get_message_fn']) && $config['get_message_fn'] instanceof \Closure) { $this->getMessageFunction = $config['get_message_fn']; } else { if (is_object($config['get_message_fn'])) { $got = get_class($config['get_message_fn']); } else { $got = gettype($config['get_message_fn']); } throw new Exception('Invalid get_message_fn type; expected \\Closure object, got: ' . $got); } } parent::__construct($config); }
/** * Construct the DB writer * * @param array $config * @throws Exception */ public function __construct(array $config) { if (!isset($config['table'])) { throw new Exception('Undefined \'table\' in DB writer options'); } if (!array_key_exists('connection', $config)) { throw new Exception('Undefined \'connection\' in DB writer options'); } if (isset($config['get_data_fn']) && !is_callable($config['get_data_fn'])) { throw new Exception('get_data_fn in DB writer options is not callable'); } if (!isset($config['email'])) { $config['email'] = null; } parent::__construct($config); }