本文整理汇总了PHP中Monolog\Logger类的典型用法代码示例。如果您正苦于以下问题:PHP Logger类的具体用法?PHP Logger怎么用?PHP Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: interventionRequestAction
/**
*
* @param Request $request
* @param string $queryString
* @param string $filename
* @return Response
*/
public function interventionRequestAction(Request $request, $queryString, $filename)
{
$log = new Logger('InterventionRequest');
$log->pushHandler(new StreamHandler(ROADIZ_ROOT . '/logs/interventionRequest.log', Logger::INFO));
try {
$cacheDir = ROADIZ_ROOT . '/cache/rendered';
if (!file_exists($cacheDir)) {
mkdir($cacheDir);
}
$conf = new Configuration();
$conf->setCachePath($cacheDir);
$conf->setImagesPath(ROADIZ_ROOT . '/files');
/*
* Handle short url with Url rewriting
*/
$expander = new ShortUrlExpander($request);
$expander->injectParamsToRequest($queryString, $filename);
/*
* Handle main image request
*/
$iRequest = new InterventionRequest($conf, $request, $log);
$iRequest->handle();
return $iRequest->getResponse();
} catch (\Exception $e) {
if (null !== $log) {
$log->error($e->getMessage());
}
return new Response($e->getMessage(), Response::HTTP_NOT_FOUND, ['content-type' => 'text/plain']);
}
}
开发者ID:justinpocta,项目名称:roadiz,代码行数:37,代码来源:AssetsController.php
示例2: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$configPath = __DIR__ . '/../config/sql-logging.php';
$this->mergeConfigFrom($configPath, 'sql-logging');
if (config('sql-logging.log', false)) {
Event::listen('illuminate.query', function ($query, $bindings, $time) {
$data = compact('bindings', 'time');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} else {
if (is_string($binding)) {
$bindings[$i] = "'{$binding}'";
}
}
}
// Insert bindings into query
$query = str_replace(array('%', '?'), array('%%', '%s'), $query);
$query = vsprintf($query, $bindings);
$log = new Logger('sql');
$log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
// add records to the log
$log->addInfo($query, $data);
});
}
}
开发者ID:oscaragcp,项目名称:sql-logging,代码行数:32,代码来源:SqlLoggingServiceProvider.php
示例3: run
public static function run()
{
echo "say hello on " . date('Y-m-d H:i:s');
$log = new Logger('hello');
$log->pushHandler(new StreamHandler('app.log', Logger::INFO));
$log->addInfo("say hello on " . date('Y-m-d H:i:s'));
}
开发者ID:gudongkun,项目名称:greeting,代码行数:7,代码来源:Hello.php
示例4: setUp
/**
* Instantiate mediavorus to register the mime types
*/
public function setUp()
{
parent::setUp();
$logger = new Logger('test');
$logger->pushHandler(new NullHandler());
$mediavorus = new MediaVorus(Reader::create($logger), Writer::create($logger), FFProbe::create());
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:10,代码来源:FileTest.php
示例5: register
public function register(Container $container)
{
$log = new Logger('grav');
$log_file = LOG_DIR . 'grav.log';
$log->pushHandler(new StreamHandler($log_file, Logger::WARNING));
$container['log'] = $log;
}
开发者ID:locii,项目名称:corporation-documentation,代码行数:7,代码来源:LoggerServiceProvider.php
示例6: __construct
/**
* @param array $config
* @throws \Exception
*/
protected function __construct($config)
{
parent::__construct($config);
$this->memcache = new \Memcache();
/**
* This is something tricky in PHP. If you use pconnect (p=persistent) the connection will remain open all the time.
* This is not a bad thing since we're using the cache all the time (you don't turn off the light of the kitchen if you're running in and out, switching it too much would even consume more)
* In memcache, the old but stable implementation in PHP of memcached the persistent connection works like charm
* In memcached however there is a severe bug which leads to a memory leak. If you'd take over code from this class to implement memcached, DON'T use the persistent connect!
*/
if (!isset($this->config["host"])) {
// the default host for memcached localhost
$this->config["host"] = "localhost";
}
if (!isset($this->config["port"])) {
// the default port for memcached is 11211
$this->config["port"] = 11211;
}
if (!$this->memcache->pconnect($this->config["host"], $this->config["port"])) {
if (isset($this->config["log_dir"])) {
$log_dir = rtrim($this->config["log_dir"], "/");
$log = new Logger('cache');
$log->pushHandler(new StreamHandler($log_dir . "/log_" . date('Y-m-d') . ".txt", Logger::CRITICAL));
$log->addCritical("Could not connect to memcached.", $this->config);
} else {
/*
* if we have no log directory, it's no use to throw a TDTException
*/
throw new \Exception("No connection could be made to the memcache. Please check your given configuration.");
}
}
}
开发者ID:Tjoosten,项目名称:cache,代码行数:36,代码来源:MemCache.php
示例7: fetchAllRates
function fetchAllRates(Logger $logger)
{
$url = "https://api.vircurex.com/api/get_info_for_currency.json";
$logger->info($url);
$json = Fetch::jsonDecode(Fetch::get($url));
$result = array();
$ignored = 0;
foreach ($json as $pair2 => $pairs) {
if ($pair2 == "status") {
continue;
}
foreach ($pairs as $pair1 => $market) {
if ($market['last_trade'] == 0 || $market['lowest_ask'] == 0 || $market['highest_bid'] == 0) {
// ignore empty markets
$ignored++;
continue;
}
$currency1 = $this->getCurrencyCode($pair1);
$currency2 = $this->getCurrencyCode($pair2);
if (CurrencyOrder::hasOrder($currency1) && CurrencyOrder::hasOrder($currency2)) {
if (!CurrencyOrder::isOrdered($currency1, $currency2)) {
// do not duplicate ordered currencies
continue;
}
}
$rate = array("currency1" => $currency1, "currency2" => $currency2, "last_trade" => $market['last_trade'], "volume" => $market['volume'], 'bid' => $market['highest_bid'], 'ask' => $market['lowest_ask']);
$result[] = $rate;
}
}
$logger->info("Ignored " . $ignored . " markets with last trade price of 0");
return $result;
}
开发者ID:openclerk,项目名称:exchanges,代码行数:32,代码来源:Vircurex.php
示例8: setUp
function setUp()
{
$logger = new \Monolog\Logger("test");
$logger->pushHandler(new SilentLogger());
$parser = new Parser($logger);
$this->result = $parser->load($this->getFile());
}
开发者ID:soundasleep,项目名称:phpdoc2,代码行数:7,代码来源:DocCommentTest.php
示例9: notify
public function notify(Service\Record $record, DOMDocument $config, Logger $logger)
{
$activity = $config->getElementsByTagName('activity')->item(0);
if ($activity !== null) {
$logger->info('Create user activity template');
try {
$templates = $activity->childNodes;
for ($i = 0; $i < $templates->length; $i++) {
$template = $templates->item($i);
if (!$template instanceof DOMElement) {
continue;
}
if ($template->nodeName == 'template') {
$type = $template->getAttribute('type');
$verb = $template->getAttribute('verb');
$table = $template->getAttribute('table');
$path = $template->getAttribute('path');
$summary = $template->nodeValue;
if (isset($this->registry['table.' . $table])) {
$table = $this->registry['table.' . $table];
} else {
throw new Exception('Invalid table ' . $table);
}
if (!empty($type) && !empty($verb) && !empty($table) && !empty($summary)) {
$this->sql->insert($this->registry['table.user_activity_template'], array('type' => $type, 'verb' => $verb, 'table' => $table, 'path' => $path, 'summary' => $summary));
$logger->info('> Created user activity template');
$logger->info($summary);
}
}
}
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
}
}
开发者ID:visapi,项目名称:amun,代码行数:35,代码来源:ConfigListener.php
示例10: setUpBeforeClass
/**
* This method is called before the first test of this test class is run.
*/
public static function setUpBeforeClass()
{
// First, generate the INI files
$buildNumber = time();
$resourceFolder = __DIR__ . '/../../resources/';
self::$buildFolder = __DIR__ . '/../../build/browscap-ua-test-' . $buildNumber . '/build/';
$cacheFolder = __DIR__ . '/../../build/browscap-ua-test-' . $buildNumber . '/cache/';
// create build folder if it does not exist
if (!file_exists(self::$buildFolder)) {
mkdir(self::$buildFolder, 0777, true);
}
if (!file_exists($cacheFolder)) {
mkdir($cacheFolder, 0777, true);
}
$logger = new Logger('browscap');
$logger->pushHandler(new NullHandler(Logger::DEBUG));
$buildGenerator = new BuildGenerator($resourceFolder, self::$buildFolder);
$writerCollectionFactory = new PhpWriterFactory();
$writerCollection = $writerCollectionFactory->createCollection($logger, self::$buildFolder);
$buildGenerator->setLogger($logger)->setCollectionCreator(new CollectionCreator())->setWriterCollection($writerCollection);
$buildGenerator->run($buildNumber, false);
$cache = new File([File::DIR => $cacheFolder]);
self::$browscap = new Browscap();
self::$browscap->setCache($cache)->setLogger($logger);
self::$browscapUpdater = new BrowscapUpdater();
self::$browscapUpdater->setCache($cache)->setLogger($logger);
self::$propertyHolder = new PropertyHolder();
}
开发者ID:browscap,项目名称:browscap,代码行数:31,代码来源:UserAgentsTest.php
示例11: storeSupportedCurrencies
function storeSupportedCurrencies($currencies, Logger $logger)
{
$logger->info("Storing " . count($currencies) . " currencies persistently");
// find all existing currencies
$existing = $this->getSupportedCurrencies(true);
// remove removed currencies
foreach ($existing as $currency) {
if (array_search($currency, $currencies) === false) {
$logger->info("Removing currency {$currency}");
$q = $this->db->prepare("DELETE FROM account_currencies WHERE exchange=? AND currency=?");
$q->execute(array($this->exchange->getCode(), $currency));
}
}
// add new currencies
foreach ($currencies as $currency) {
if (array_search($currency, $existing) === false) {
if (strlen($currency) != 3) {
$logger->info("Ignoring currency '" . $currency . "': not three characters long");
continue;
}
$logger->info("Adding currency {$currency}");
$q = $this->db->prepare("INSERT INTO account_currencies SET exchange=?, currency=?");
$q->execute(array($this->exchange->getCode(), $currency));
}
}
// reset cache
$this->cached_currencies = null;
}
开发者ID:phpsource,项目名称:openclerk,代码行数:28,代码来源:PersistentAccountType.php
示例12: createService
/**
* @param ServiceLocatorInterface $serviceLocator
* @return Logger
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$handler = new Handler\RotatingFileHandler('data/logs/error.log');
$logger = new Logger('error-handling');
$logger->pushHandler($handler);
return $logger;
}
开发者ID:Tigerlee1987,项目名称:modules.zendframework.com,代码行数:11,代码来源:LoggerFactory.php
示例13: setUp
public function setUp()
{
parent::setUp();
$this->monolog = new Monolog\Logger('log-decorator');
$this->handler = new Monolog\Handler\TestHandler();
$this->monolog->pushHandler($this->handler);
}
开发者ID:olegpopadko,项目名称:log-decorator,代码行数:7,代码来源:Test.php
示例14: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::$logger = new Logger('filefindtest');
self::$logger->pushHandler(new TestHandler());
self::$logger->pushHandler(new StreamHandler('test.log'));
}
开发者ID:ubermichael,项目名称:filefinder,代码行数:7,代码来源:FileFindTest.php
示例15: testLogsFromListeners
public function testLogsFromListeners()
{
$output = new BufferedOutput();
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
$handler = new ConsoleHandler(null, false);
$logger = new Logger('app');
$logger->pushHandler($handler);
$dispatcher = new EventDispatcher();
$dispatcher->addListener(ConsoleEvents::COMMAND, function () use($logger) {
$logger->addInfo('Before command message.');
});
$dispatcher->addListener(ConsoleEvents::TERMINATE, function () use($logger) {
$logger->addInfo('Before terminate message.');
});
$dispatcher->addSubscriber($handler);
$dispatcher->addListener(ConsoleEvents::COMMAND, function () use($logger) {
$logger->addInfo('After command message.');
});
$dispatcher->addListener(ConsoleEvents::TERMINATE, function () use($logger) {
$logger->addInfo('After terminate message.');
});
$event = new ConsoleCommandEvent(new Command('foo'), $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'), $output);
$dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
$this->assertContains('Before command message.', $out = $output->fetch());
$this->assertContains('After command message.', $out);
$event = new ConsoleTerminateEvent(new Command('foo'), $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'), $output, 0);
$dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
$this->assertContains('Before terminate message.', $out = $output->fetch());
$this->assertContains('After terminate message.', $out);
}
开发者ID:egmax,项目名称:symfony,代码行数:30,代码来源:ConsoleHandlerTest.php
示例16: findJob
/**
* Find the next job that should be executed.
* By default, just selects any job instance that is in the database that isn't
* already executing, hasn't already been finished, and hasn't errored out.
* @return a job array (id, job_type, [user_id], [arg_id]) or {@code false} if there is none
*/
function findJob(Connection $db, Logger $logger)
{
// TODO timeout jobs
// mark all repeatedly failing jobs as failing
$execution_limit = Config::get("job_execution_limit", 5);
$q = $db->prepare("SELECT * FROM jobs WHERE is_executed=0 AND is_executing=0 AND execution_count >= ?");
$q->execute(array($execution_limit));
if ($failed = $q->fetchAll()) {
$logger->info("Found " . number_format(count($failed)) . " jobs that have executed too many times ({$execution_limit})");
foreach ($failed as $f) {
$q = $db->prepare("UPDATE jobs SET is_executed=1,is_error=1 WHERE id=?");
$q->execute(array($f['id']));
$logger->info("Marked job " . $f['id'] . " as failed");
}
}
// find first a job that has zero execution count
$q = $db->prepare("SELECT * FROM jobs WHERE " . $this->defaultFindJobQuery() . " AND execution_count=0 LIMIT 1");
$q->execute();
if ($job = $q->fetch()) {
return $job;
}
// or, any job
$q = $db->prepare("SELECT * FROM jobs WHERE " . $this->defaultFindJobQuery() . " LIMIT 1");
$q->execute();
return $q->fetch();
}
开发者ID:openclerk,项目名称:jobs,代码行数:32,代码来源:JobRunner.php
示例17: runRequest
public function runRequest($request)
{
$c = $this->loadController($request);
$sess = \Sessionx::start();
$sess->refreshCookie();
if (is_callable(array($c, 'load'))) {
$c->name = $request;
$c->load();
$c->checkSession();
$c->dispatch();
// If the controller ask to display a different page
if ($request != $c->name) {
$new_name = $c->name;
$c = $this->loadController($new_name);
$c->name = $new_name;
$c->load();
$c->dispatch();
}
// We display the page !
$c->display();
} else {
$log = new Logger('movim');
$log->pushHandler(new SyslogHandler('movim'));
$log->addError(t("Could not call the load method on the current controller"));
}
}
开发者ID:Anon215,项目名称:movim,代码行数:26,代码来源:Front.php
示例18: systemErrorHandler
/**
* Error Handler...
*/
function systemErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = null)
{
$log = new Logger('movim');
$log->pushHandler(new SyslogHandler('movim'));
$log->addError($errstr);
return false;
}
开发者ID:Nyco,项目名称:movim,代码行数:10,代码来源:bootstrap.php
示例19: __construct
/**
* Método constructor de la clase.
*
* Construye el log de Monolog y lo asigna a la variable de clase log.
*/
private function __construct()
{
$log = new Logger("Sistema." . $this->getAppEnv());
$log->pushHandler(new StreamHandler(__DIR__ . "/../../../storage/logs/System.log"));
$log->pushProcessor(new WebProcessor());
$this->log = $log;
}
开发者ID:stokekld,项目名称:UCRest,代码行数:12,代码来源:SystemLog.php
示例20: register
/**
* {@inheritDoc}
*/
public function register(Container $container)
{
// Append custom settings with missing params from default settings
$container['settings']['database'] = self::mergeWithDefaultSettings($container['settings']['database']);
$settings = $container['settings']['database'];
$logLevel = $settings['logger']['level'] ?? null;
$logPath = $settings['logger']['path'] ?? null;
$className = $settings['classname'] ?? null;
if (!$className) {
$className = 'Propel\\Runtime\\Connection\\ConnectionWrapper';
if ($logLevel == Logger::DEBUG) {
$className = 'Propel\\Runtime\\Connection\\ProfilerConnectionWrapper';
}
}
$manager = new ConnectionManagerSingle();
$manager->setConfiguration(['classname' => $className, 'dsn' => $settings['dsn'], 'user' => $settings['user'], 'password' => $settings['password'], 'settings' => $settings['settings']]);
$manager->setName($settings['connection']);
/** @var StandardServiceContainer $serviceContainer */
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->checkVersion($settings['version']);
$serviceContainer->setAdapterClass($settings['connection'], $settings['adapter']);
$serviceContainer->setConnectionManager($settings['connection'], $manager);
$serviceContainer->setDefaultDatasource($settings['connection']);
if ($logPath && $logLevel) {
$logger = new Logger('defaultLogger');
$logger->pushHandler(new StreamHandler($logPath, $logLevel));
$serviceContainer->setLogger('defaultLogger', $logger);
if ($logLevel == Logger::DEBUG) {
/** @var ConnectionWrapper $con */
$con = Propel::getConnection();
$con->useDebug(true);
}
}
}
开发者ID:ansas,项目名称:php-component,代码行数:37,代码来源:PropelProvider.php
注:本文中的Monolog\Logger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论