public function boot() { $em = $this->container->get("doctrine.orm.entity_manager"); try { Registry::getInstance("app"); } catch (InvalidArgumentException $e) { Registry::addLogger($this->container->get("logger"), "app"); } try { Type::addType("encryptedstring", "\\Keboola\\ProvisioningBundle\\Types\\EncryptedStringType"); Type::addType("enumservertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumServerTypeType"); Type::addType("enumservermode", "\\Keboola\\ProvisioningBundle\\Types\\EnumServerModeType"); Type::addType("enumaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumAccountTypeType"); Type::addType("enumwrdbaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumWrdbAccountTypeType"); Type::addType("enumredshiftaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftAccountTypeType"); Type::addType("enumsnowflakeaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountTypeType"); Type::addType("enumsnowflakeaccountwithluckyguesstype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountWithLuckyguessTypeType"); Type::addType("enumsnowflakeaccountwithluckyguessandwritertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountWithLuckyguessAndWriterTypeType"); Type::addType("enumredshiftworkspaceaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountTypeType"); Type::addType("enumdockeraccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumDockerAccountTypeType"); Type::addType("enumredshiftworkspaceaccountwithluckyguestype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountWithLuckyguessTypeType"); Type::addType("enumredshiftworkspaceaccountwithluckyguessandwritertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountWithLuckyguessAndWriterTypeType"); $encryptor = new AesEncryptor($this->container->getParameter("provisioning_api.key")); // 256 bit key EncryptedStringType::setEncryptor($encryptor); $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping("encryptedstring", "encryptedstring"); } catch (\Doctrine\DBAL\DBALException $e) { // For some reason this exception gets thrown during // the clearing of the cache. I didn't have time to // find out why :-) } }
/** * @dataProvider hasLoggerProvider * @covers Monolog\Registry::hasLogger */ public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult) { foreach ($loggersToAdd as $loggerToAdd) { Registry::addLogger($loggerToAdd); } foreach ($loggersToCheck as $index => $loggerToCheck) { $this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck)); } }
/** * Create a new Logger object and push it to the registry * * @see Monolog\Logger::__construct * * @param string $name The logging channel * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, * etc. * @param callable[] $processors Optional array of processors * * @throws \InvalidArgumentException: if no name is given * * @return Logger newly created Logger */ public static function createLogger($name, array $handlers = array(), array $processors = array()) { if (empty($name)) { throw new \InvalidArgumentException('Logger name is required.'); } $logger = new Logger($name, $handlers, $processors); Registry::addLogger($logger); return $logger; }
public function __construct($raw) { $this->eventManager = new EventManager(); // Setup logging if (!Registry::hasLogger('PhlowLog')) { $logger = new Logger('phlow'); $logger->pushHandler(new StreamHandler("phlow.log")); Registry::addLogger($logger, 'PhlowLog'); } $this->raw = $raw; $this->inflate(); }
/** * Set local variables and bootstrap logging * * @param string $domain * @param string $taskList */ private function setup($identity, $domain, $taskList, Logger $logger) { if (!$identity) { $this->identity = get_class() . '-' . microtime(); } $this->taskList = $taskList; $this->domain = $domain; // Setup logging if (!Registry::hasLogger('PhlowLog')) { Registry::addLogger($logger, 'PhlowLog'); } }
/** * Load loggers and register them into \Monolog\Registry * * @param $config \Centreon\Config The application configuration */ public static function load($config) { $logger = new \Monolog\Logger('MAIN'); $loggers = $config->get('loggers', 'logger'); foreach ($loggers as $loggerName) { $loggerType = $config->get('logger_' . $loggerName, 'type'); if (!is_null($loggerType) && isset(self::$loggerHandler[$loggerType])) { try { $handler = self::createHandler($config->getGroup('logger_' . $loggerName), $loggerName); $logger->pushHandler($handler); } catch (\Exception $e) { } } } \Monolog\Registry::addLogger($logger, $logger->getName(), true); }
<?php /* * This file is part of the Pathfinder package. * * (c) bitExpert AG * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare (strict_types=1); // include and configure Composer autoloader include __DIR__ . '/../vendor/autoload.php'; // configure the Simple Logging Facade for PSR-3 loggers with a Monolog backend \bitExpert\Slf4PsrLog\LoggerFactory::registerFactoryCallback(function ($channel) { if (!\Monolog\Registry::hasLogger($channel)) { \Monolog\Registry::addLogger(new \Monolog\Logger($channel)); } return \Monolog\Registry::getInstance($channel); });
/** Add information to the log file */ function add_log($text, $function, $type = LOG_INFO, $projectid = 0, $buildid = 0, $resourcetype = 0, $resourceid = 0) { global $CDASH_LOG_FILE, $CDASH_LOG_FILE_MAXSIZE_MB, $CDASH_LOG_LEVEL, $CDASH_TESTING_MODE; $level = to_psr3_level($type); if (($buildid === 0 || is_null($buildid)) && isset($GLOBALS['PHP_ERROR_BUILD_ID'])) { $buildid = $GLOBALS['PHP_ERROR_BUILD_ID']; } $context = array('function' => $function); if ($projectid !== 0 && !is_null($projectid)) { $context['project_id'] = $projectid; } if ($buildid !== 0 && !is_null($buildid)) { $context['build_id'] = strval($buildid); } if ($resourcetype !== 0 && !is_null($resourcetype)) { $context['resource_type'] = $resourcetype; } if ($resourceid !== 0 && !is_null($resourceid)) { $context['resource_id'] = $resourceid; } $minLevel = to_psr3_level($CDASH_LOG_LEVEL); if (!is_null($CDASH_LOG_FILE)) { // If the size of the log file is bigger than 10 times the allocated memory // we rotate $logFileMaxSize = $CDASH_LOG_FILE_MAXSIZE_MB * 100000; if (file_exists($CDASH_LOG_FILE) && filesize($CDASH_LOG_FILE) > $logFileMaxSize) { $tempLogFile = $CDASH_LOG_FILE . '.tmp'; if (!file_exists($tempLogFile)) { rename($CDASH_LOG_FILE, $tempLogFile); // This should be quick so we can keep logging for ($i = 9; $i >= 0; $i--) { // If we do not have compression we just rename the files if (function_exists('gzwrite') === false) { $currentLogFile = $CDASH_LOG_FILE . '.' . $i; $j = $i + 1; $newLogFile = $CDASH_LOG_FILE . '.' . $j; if (file_exists($newLogFile)) { cdash_unlink($newLogFile); } if (file_exists($currentLogFile)) { rename($currentLogFile, $newLogFile); } } else { $currentLogFile = $CDASH_LOG_FILE . '.' . $i . '.gz'; $j = $i + 1; $newLogFile = $CDASH_LOG_FILE . '.' . $j . '.gz'; if (file_exists($newLogFile)) { cdash_unlink($newLogFile); } if (file_exists($currentLogFile)) { $gz = gzopen($newLogFile, 'wb'); $f = fopen($currentLogFile, 'rb'); while ($f && !feof($f)) { gzwrite($gz, fread($f, 8192)); } fclose($f); unset($f); gzclose($gz); unset($gz); } } } // Move the current backup if (function_exists('gzwrite') === false) { rename($tempLogFile, $CDASH_LOG_FILE . '.0'); } else { $gz = gzopen($CDASH_LOG_FILE . '.0.gz', 'wb'); $f = fopen($tempLogFile, 'rb'); while ($f && !feof($f)) { gzwrite($gz, fread($f, 8192)); } fclose($f); unset($f); gzclose($gz); unset($gz); cdash_unlink($tempLogFile); } } } $pid = getmypid(); if ($pid !== false) { $context['pid'] = getmypid(); } } if (Registry::hasLogger('cdash') === false) { if ($CDASH_LOG_FILE === false) { $handler = new SyslogHandler('cdash', LOG_USER, $minLevel); $handler->getFormatter()->ignoreEmptyContextAndExtra(); } else { if ($CDASH_TESTING_MODE) { $filePermission = 0666; } else { $filePermission = 0664; } $handler = new StreamHandler($CDASH_LOG_FILE, $minLevel, true, $filePermission); $handler->getFormatter()->allowInlineLineBreaks(); $handler->getFormatter()->ignoreEmptyContextAndExtra(); } $logger = new Logger('cdash'); $logger->pushHandler($handler); Registry::addLogger($logger); } else { $logger = Registry::getInstance('cdash'); } $logger->log($level, $text, $context); }
public function __construct(Logger $log, $appName) { $this->log = $log; $this->appName = $appName; Registry::addLogger($log, "log"); }
public function boot(Application $app) { \Monolog\Registry::addLogger($app['logger'], 'logger'); }
* * (c) bitExpert AG * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require __DIR__ . '/../config/config.inc.php'; // Configure logger infrastructure if (isset($APP_CONF['logger'], $APP_CONF['logger']['logfile'], $APP_CONF['logger']['level'])) { // configure the Simple Logging Facade for PSR-3 loggers with a Monolog backend \bitExpert\Slf4PsrLog\LoggerFactory::registerFactoryCallback(function ($channel) use($APP_CONF) { if (!\Monolog\Registry::hasLogger($channel)) { $handler = new \Monolog\Handler\StreamHandler($APP_CONF['logger']['logfile'], $APP_CONF['logger']['level']); $log = new \Monolog\Logger('name'); $log->pushHandler($handler); \Monolog\Registry::addLogger($log, $channel); return $log; } return \Monolog\Registry::getInstance($channel); }); } // Create Disco cache dir if (isset($APP_CONF['di'], $APP_CONF['di']['cache']) and !is_dir($APP_CONF['di']['cache'])) { @mkdir($APP_CONF['di']['cache'], 0777, true); } // Configure and set up the BeanFactory instance $config = new \bitExpert\Disco\BeanFactoryConfiguration($APP_CONF['di']['cache'], null, null, !$APP_CONF['di']['devMode']); $beanFactory = new \bitExpert\Disco\AnnotationBeanFactory($APP_CONF['di']['config'], $APP_CONF, $config); \bitExpert\Disco\BeanFactoryRegistry::register($beanFactory); $request = \Zend\Diactoros\ServerRequestFactory::fromGlobals(); $response = new \Zend\Diactoros\Response();
/** * Rejestruje nowy dziennik. * * @param \Psr\Log\LoggerInterface $logger Dziennik * @throws InvalidArgumentException Nie można ponownie zapisać tego * samego dziennika */ public function addLogger(LoggerInterface $logger) { MonologRegistry::addLogger($logger); }
/** * */ private function initLoggers() { $logger = new \Monolog\Logger(self::$logger); if (WP_DEBUG) { $logger->pushHandler(new \Monolog\Handler\StreamHandler(self::$logDir . '/jigoshop.debug.log', \Monolog\Logger::DEBUG)); } $logger->pushHandler(new \Monolog\Handler\StreamHandler(self::$logDir . '/jigoshop.log', \Monolog\Logger::WARNING)); $logger->pushProcessor(new \Monolog\Processor\IntrospectionProcessor()); $logger->pushProcessor(new \Monolog\Processor\WebProcessor()); \Monolog\Registry::addLogger($logger); }