当前位置: 首页>>代码示例>>PHP>>正文


PHP File::setLogLevel方法代码示例

本文整理汇总了PHP中Phalcon\Logger\Adapter\File::setLogLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP File::setLogLevel方法的具体用法?PHP File::setLogLevel怎么用?PHP File::setLogLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Logger\Adapter\File的用法示例。


在下文中一共展示了File::setLogLevel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerServices

 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $config = (include APP_PATH . "/apps/backend/config/config.php");
     /**
      * Setting up the view component
      */
     $di['view'] = function () use($config) {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
             $volt = new VoltEngine($view, $di);
             $volt->setOptions(array('compiledPath' => __DIR__ . '/cache/', 'compiledSeparator' => '_'));
             $compiler = $volt->getCompiler();
             // format number
             $compiler->addFilter('number', function ($resolvedArgs) {
                 return 'Helpers::number(' . $resolvedArgs . ');';
             });
             return $volt;
         }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
         return $view;
     };
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         $config = $config->database->toArray();
         $dbAdapter = '\\Phalcon\\Db\\Adapter\\Pdo\\' . $config['adapter'];
         unset($config['adapter']);
         return new $dbAdapter($config);
     };
     /**
      * Logger service
      */
     $di->set('logger', function ($filename = null, $format = null) use($config) {
         $format = $format ?: $config->get('logger')->format;
         $filename = trim($filename ?: $config->get('logger')->filename, '\\/');
         $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
         $formatter = new FormatterLine($format, $config->get('logger')->date);
         $logger = new FileLogger($path . $filename);
         $logger->setFormatter($formatter);
         $logger->setLogLevel($config->get('logger')->logLevel);
         return $logger;
     });
     $di->set('url', function () use($config) {
         $url = new UrlResolver();
         $url->setBaseUri("/backend/");
         return $url;
     });
 }
开发者ID:vietdh85,项目名称:product-vh,代码行数:57,代码来源:Module.php

示例2: Flash

    return new Flash(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'));
});
/**
 * Start the session the first time some component request the session service
 */
$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
/*
 * Routes
 */
#$di->set('router', function(){
#    require 'routes.php';
#    return $router;
#});
/**
 * Logger service
 */
$di->set('logger', function ($filename = null, $format = null) use($config) {
    $format = $format ?: $config->get('logger')->format;
    $filename = trim($filename ?: $config->get('logger')->filename, '\\/');
    $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
    #$path = "/temp/system.log";
    $formatter = new FormatterLine($format, $config->get('logger')->date);
    $logger = new FileLogger($path . $filename);
    $logger->setFormatter($formatter);
    $logger->setLogLevel($config->get('logger')->logLevel);
    return $logger;
});
开发者ID:vietdh85,项目名称:vh-utility,代码行数:31,代码来源:services.php

示例3: commonServices

 /**
  * 默认服务依赖注入
  *
  */
 protected function commonServices()
 {
     $mode = $this->mode;
     $di = $this->mode === 'CLI' ? new Cli() : new FactoryDefault();
     // 日志
     $di->set('logger', function () {
         $config = load('logger');
         $adapter = $config['adapter'];
         $filename = $config[$adapter]['filename'];
         $filedir = dirname($filename);
         if (empty($config)) {
             throw new \Exception('logger config Require failed');
         }
         if (!is_dir($filedir)) {
             mkdir($filedir, 0755, true);
         }
         $logger = new File($filename);
         $formatter = new Line(null, 'Y-m-d H:i:s');
         $loglevel = config('app.loglevel');
         $logger->setFormatter($formatter);
         $logger->setLogLevel($loglevel ? $loglevel : \Phalcon\Logger::ERROR);
         return $logger;
     }, true);
     $this->application->setDI($di);
     // 命名空间
     $di->set('dispatcher', function () use($mode) {
         $dispatcher = new Dispatcher();
         $dispatcher = $mode === 'CLI' ? new \Phalcon\CLI\Dispatcher() : new Dispatcher();
         $bootstrap = load('bootstrap');
         $default = $bootstrap['dispatcher'];
         $dispatcher->setDefaultNamespace($mode === 'CLI' ? $default['cli'] : $default['default']);
         return $dispatcher;
     }, true);
     // 路由
     if ($load = load('router', null, true)) {
         if ($load instanceof Router) {
             $di->set('router', $load);
         }
     }
     // 视图
     $di->set('view', function () {
         $view = new View();
         $view->setViewsDir(APP_VIEW);
         return $view;
     }, true);
     // 加解密
     if ($config = config('crypt')) {
         $di->set('crypt', function () use($config) {
             $crypt = new Crypt();
             $crypt->setKey($config['authkey']);
             return $crypt;
         }, true);
     }
     // 默认缓存
     if ($config = config('cache')) {
         $di->set('cache', function () use($config) {
             $cache = null;
             $adapter = strtolower($config['adapter']);
             $options = $config[$adapter];
             $frontend = new Data(array('lifetime' => $config['lifetime']));
             switch ($adapter) {
                 case 'memcache':
                     $cache = new Memcache($frontend, $options);
                     break;
                 case 'redis':
                     if (empty($options['auth'])) {
                         unset($options['auth']);
                     }
                     $cache = new \Phalcon\Extend\Cache\Backend\Redis($frontend, $options);
                     break;
             }
             return $cache;
         }, true);
     }
     // Cookies
     if ($config = config('cookies')) {
         $di->set('cookies', function () use($config) {
             $cookies = new \Phalcon\Extend\Http\Response\Cookies($config);
             if (!config('crypt.authkey')) {
                 $cookies->useEncryption(false);
             }
             return $cookies;
         }, true);
     }
     // Session
     if ($config = config('session')) {
         $di->set('session', function () use($config) {
             if (!empty($config['options'])) {
                 foreach ($config['options'] as $name => $value) {
                     ini_set("session.{$name}", $value);
                 }
             }
             $adapter = strtolower($config['adapter']);
             $options = $config[$adapter];
             switch ($adapter) {
                 case 'memcache':
//.........这里部分代码省略.........
开发者ID:smallmenu,项目名称:learning-phalcon,代码行数:101,代码来源:Bootstrap.php

示例4: initLogger

 /**
  * Initialize the Logger.
  *
  * @param DiInterface   $di     Dependency Injector
  * @param Config        $config App config
  * @param EventsManager $em     Events Manager
  *
  * @return void
  */
 protected function initLogger(DiInterface $di, Config $config, EventsManager $em)
 {
     ErrorHandler::register();
     $di->set('logger', function ($filename = null, $format = null) use($config) {
         $format = $format ?: $config->get('logger')->format;
         $filename = trim($filename ?: $config->get('logger')->filename, '\\/');
         $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
         $formatter = new FormatterLine($format, $config->get('logger')->date);
         $logger = new FileLogger($path . $filename);
         $logger->setFormatter($formatter);
         $logger->setLogLevel($config->get('logger')->logLevel);
         return $logger;
     });
 }
开发者ID:huoybb,项目名称:forum,代码行数:23,代码来源:Bootstrap.php

示例5: function

             }
         });
         //设置事件管理器
         $db->setEventsManager($eventsManager);
     }
     return $db;
 });
 // 日志
 Provider::set('log', function ($provider) {
     $log = new LogProvider();
     if ($provider->config->log->enable) {
         $logPath = APP_PATH . $provider->config->path->log . '/';
         foreach ($provider->config->log->groups as $name => $info) {
             $log[$name] = function () use($logPath, $name, $info) {
                 $log = new Logger($logPath . $info['file']);
                 $log->setLogLevel($info['level']);
                 return $log;
             };
         }
         return $log;
     } else {
         return false;
     }
 });
 // 会话
 Provider::set('session', function ($provider) {
     session_name($provider->config->session->name);
     session_save_path(APP_PATH . $provider->config->path->session);
     $session = new Session();
     $session->start();
     return $session;
开发者ID:sujinw,项目名称:passport,代码行数:31,代码来源:bootstrap.php

示例6: FactoryDefault

use Phalcon\Mvc\Model\Metadata\Apc as MetadataApc;
use PhalconX\Mvc\Metadata\Memory as MetadataMemory;
use PhalconX\Annotations;
$di = new FactoryDefault();
$di['config'] = $config;
$di['registry'] = new Config();
$di['loader'] = $loader;
$di['logger'] = function () use($config) {
    $isCli = PHP_SAPI == 'cli';
    $prefix = $config->application->logsDir . ($isCli ? 'cli-' : '');
    $logger = new MultipleStream();
    $appender = new FileAppender($prefix . 'error.log');
    $appender->setLogLevel(Logger::ERROR);
    $logger->push($appender);
    $appender = new FileAppender($prefix . 'default.log');
    $appender->setLogLevel(Logger::INFO);
    $logger->push($appender);
    if ($isCli) {
        $appender = new ConsoleAppender('php://stderr');
        $formatter = new LineFormatter("%date% [%type%] %message%\n");
        $appender->setFormatter($formatter);
        $appender->setLogLevel(Logger::ERROR);
        $logger->push($appender);
    }
    return $logger;
};
$di['db'] = function () use($di, $config) {
    Model::setup(['notNullValidations' => false]);
    $conn = new DbAdapter($config->database->toArray());
    if (isset($config->eventListeners->db)) {
        $em = $di['eventsManager'];
开发者ID:wenbinye,项目名称:admin-gen,代码行数:31,代码来源:services.php

示例7: initLogger

 /**
  * 日志处理
  */
 protected function initLogger()
 {
     $config = $this->config;
     $this->di['logger'] = function () use($config) {
         $logLevel = $this->debug ? Logger::DEBUG : Logger::ERROR;
         if ($config->offsetExists('logger')) {
             try {
                 if ($config->logger->offsetExists('path') == false) {
                     throw new \Exception('logger path not in config.');
                 }
                 $path = $config->logger->path;
                 $path = str_replace('{{date}}', date("Ymd"), $path);
                 if ($config->logger->offsetExists('formatter')) {
                     $formatter = new LineFormatter($config->logger->formatter);
                 } else {
                     $formatter = new LineFormatter('%date%[%type%] - %message%');
                 }
                 $logger = new LoggerFile($path);
                 $logger->setFormatter($formatter);
                 $logger->setLogLevel($logLevel);
                 return $logger;
             } catch (\Exception $e) {
             }
         }
         $logger = new LoggerStream("php://stderr");
         $logger->setLogLevel($logLevel);
         return $logger;
     };
 }
开发者ID:c78702505,项目名称:phalcon-phputils,代码行数:32,代码来源:Bootstrap.php

示例8: initLogger

 /**
  * Initialize the Logger.
  */
 protected function initLogger()
 {
     ErrorHandler::register();
     $this->di->set('logger', function ($filename = null, $format = null) {
         /** @var DiInterface $this */
         $config = $this->getShared('config');
         $format = $format ?: $config->get('logger')->format;
         $filename = trim($filename ?: $config->get('logger')->filename, '\\/');
         $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
         if (false === strpos($filename, '.log')) {
             $filename = "{$filename}.log";
         }
         $formatter = new FormatterLine($format, $config->get('logger')->date);
         $logger = new FileLogger($path . $filename);
         $logger->setFormatter($formatter);
         $logger->setLogLevel($config->get('logger')->logLevel);
         return $logger;
     });
 }
开发者ID:phalcon,项目名称:forum,代码行数:22,代码来源:Bootstrap.php

示例9: createLogger

 protected function createLogger($name)
 {
     if (!$this->config->get('app.log.enable')) {
         return new Null();
     }
     $level = (int) $this->config->get('.log.' . $name, Logger::SPECIAL);
     $logger = new LogFile($this->paths['storage'] . 'logs/' . $name . '.log');
     $logger->setLogLevel($level)->begin();
     return $logger;
 }
开发者ID:panlatent,项目名称:swilab,代码行数:10,代码来源:Log.php


注:本文中的Phalcon\Logger\Adapter\File::setLogLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。