• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Handler\StreamHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Monolog\Handler\StreamHandler的典型用法代码示例。如果您正苦于以下问题:PHP StreamHandler类的具体用法?PHP StreamHandler怎么用?PHP StreamHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: initialize

 /**
  * Initialize the provider
  *
  * @return void
  */
 public function initialize()
 {
     $this->options = array_merge($this->defaultConfig, $this->options);
     date_default_timezone_set($this->options['log.timezone']);
     // Finally, create a formatter
     $formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false);
     // Create a new directory
     $logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path'];
     if (!is_dir($logPath)) {
         mkdir($logPath, 0755);
     }
     // Create a handler
     $stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log');
     // Set our formatter
     $stream->setFormatter($formatter);
     // Create LogWriter
     $logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor())));
     // Bind our logger to Bono Container
     $this->app->container->singleton('log', function ($c) {
         $log = new Log($c['logWriter']);
         $log->setEnabled($c['settings']['log.enabled']);
         $log->setLevel($c['settings']['log.level']);
         $env = $c['environment'];
         $env['slim.log'] = $log;
         return $log;
     });
     // Set the writer
     $this->app->config('log.writer', $logger);
 }
开发者ID:krisanalfa,项目名称:b-comp,代码行数:34,代码来源:LogProvider.php


示例2: register

 public function register(Application $app)
 {
     //parent service provider activation
     $app->register(new MonologServiceProvider());
     //define default options
     $app['monolog.fingerscrossed.level'] = Logger::NOTICE;
     $app['monolog.fingerscrossed'] = true;
     $app['monolog.rotatingfile'] = false;
     $app['monolog.rotatingfile.maxfiles'] = 10;
     $app['monolog.fingerscrossed.handler'] = function () use($app) {
         $level = SuperMonologServiceProvider::translateLevel($app['monolog.level']);
         return new StreamHandler($app['monolog.logfile']);
     };
     //main override function
     $app['monolog.handler'] = function () use($app) {
         //setup level
         $Activationlevel = SuperMonologServiceProvider::translateLevel($app['monolog.fingerscrossed.level']);
         $level = SuperMonologServiceProvider::translateLevel($app['monolog.level']);
         //debug mode
         if ($app['debug']) {
             $handler = new StreamHandler($app['monolog.logfile'], $level);
             $handler->setFormatter(new \Ibsciss\Monolog\Formatter\LineFormatter());
             return $handler;
         }
         //if rotatingfile enable : figerscrossedHandler override
         if ($app['monolog.rotatingfile']) {
             $app['monolog.fingerscrossed.handler'] = new RotatingFileHandler($app['monolog.logfile'], $app['monolog.rotatingfile.maxfiles'], $level);
         }
         //apply default strategy
         $handler = $app['monolog.fingerscrossed'] ? new FingersCrossedHandler($app['monolog.fingerscrossed.handler'], $Activationlevel) : $app['monolog.fingerscrossed.handler'];
         $handler->setFormatter(new \Ibsciss\Monolog\Formatter\LineFormatter());
         return $handler;
     };
 }
开发者ID:ewake,项目名称:supermonolog-service-provider,代码行数:34,代码来源:SuperMonologServiceProvider.php


示例3: write

 /**
  * 写入日志
  * @param $msg
  * @param $name
  * @param int $level
  * @param AbstractHandler $handler
  */
 public static function write($msg, $name, $level = Logger::INFO, AbstractHandler $handler = null)
 {
     $name .= '_' . $level;
     $name = $name . '_' . date('Y-m-d-H', Date::now());
     if (isset(self::$loggers[$name])) {
         $logger = self::$loggers[$name];
         if ($handler != null) {
             $logger->pushHandler($handler);
         }
     } else {
         $logger = new Logger($name);
         if ($handler == null) {
             $path = ConfigManager::get('log');
             $handler = new StreamHandler($path . DIRECTORY_SEPARATOR . $name . '.log', $level);
             $formatter = new LineFormatter(ConfigManager::get('log_formatter'), 'Y-m-d H:i:s');
             $handler->setFormatter($formatter);
         }
         $logger->pushHandler($handler);
         self::$loggers[$name] = $logger;
     }
     if (is_scalar($msg) === false) {
         $msg = json_encode($msg);
     }
     $logger->log($level, $msg);
 }
开发者ID:songsihan,项目名称:simple,代码行数:32,代码来源:LogUtil.php


示例4: createLogger

 protected function createLogger($name)
 {
     $logger_title = "";
     if ($name == "_default_") {
         $logger_title = property_exists($this, "__log_title") ? $this->__log_title : "";
     }
     if ($name == "_default_") {
         $file = property_exists($this, "__log_file") ? storage_path("logs/" . $this->__log_file) : storage_path("logs/common.log");
     } else {
         if (strpos($name, "!") === 0) {
             $file = storage_path(str_replace("!", "", $name));
         } else {
             $file = storage_path("logs/" . $name . ".log");
         }
     }
     if (strpos($file, '%') !== false) {
         $file = str_replace("%d", date("Ymd"), $file);
     }
     if (!file_exists(dirname($file))) {
         mkdir(dirname($file));
     }
     $this->loggers[$name] = new Logger($logger_title, [], [new WebProcessor()]);
     $this->loggers[$name]->pushHandler($handler = new StreamHandler($file), Logger::INFO);
     $handler->setFormatter(new Formatter\LineFormatter(null, null, true, true));
 }
开发者ID:skvn,项目名称:laraext,代码行数:25,代码来源:LoggerTrait.php


示例5: __construct

 /**
  * @param $functionname
  */
 public function __construct($resourcename)
 {
     //When the HTTP request didn't set a User Agent, set it to a blank
     if (!isset($_SERVER['HTTP_USER_AGENT'])) {
         $_SERVER['HTTP_USER_AGENT'] = '';
     }
     //Default timezone is Brussels
     date_default_timezone_set('Europe/Brussels');
     //This is the current resource that's handled. E.g., stations, connections, vehicleinfo or liveboard
     $this->resourcename = $resourcename;
     try {
         $this->log = new Logger('irapi');
         //Create a formatter for the logs
         $logFormatter = new LineFormatter("%context%\n", 'Y-m-d\\TH:i:s');
         $streamHandler = new StreamHandler(__DIR__ . '/../storage/irapi.log', Logger::INFO);
         $streamHandler->setFormatter($logFormatter);
         $this->log->pushHandler($streamHandler);
         $requestname = ucfirst(strtolower($resourcename)) . 'Request';
         include_once "requests/{$requestname}.php";
         $this->request = new $requestname();
         $this->dataRoot = new DataRoot($resourcename, $this->VERSION, $this->request->getFormat());
     } catch (Exception $e) {
         $this->buildError($e);
     }
 }
开发者ID:jncn,项目名称:iRail,代码行数:28,代码来源:APICall.php


示例6: createStreamHandler

 /**
  * @return \Monolog\Handler\StreamHandler
  */
 protected function createStreamHandler()
 {
     $streamHandler = new StreamHandler(Config::get(LogConstants::LOG_FILE_PATH), Config::get(LogConstants::LOG_LEVEL, Logger::INFO));
     $formatter = new LogstashFormatter('Spryker');
     $streamHandler->setFormatter($formatter);
     return $streamHandler;
 }
开发者ID:spryker,项目名称:Application,代码行数:10,代码来源:SprykerLoggerConfig.php


示例7: setUp

 /**
  * Set up test environment.
  */
 public function setUp()
 {
     parent::setUp();
     $this->link = new \MySQLi('localhost', 'root', '');
     if ($this->link->connect_error) {
         throw new \RuntimeException('Failed to connect to database. MySQL said: ' . $this->link->connect_error);
     }
     if (!$this->link->select_db('activecollab_jobs_queue_test')) {
         throw new \RuntimeException('Failed to select database.');
     }
     $this->connection = new MysqliConnection($this->link);
     $this->queue = new MySqlQueue($this->connection);
     $this->dispatcher = new Dispatcher($this->queue);
     $this->log_file_path = dirname(__DIR__) . '/logs/' . date('Y-m-d') . '.txt';
     if (is_file($this->log_file_path)) {
         unlink($this->log_file_path);
     }
     $this->log = new Logger('cli');
     $handler = new StreamHandler($this->log_file_path, Logger::DEBUG);
     $formatter = new LineFormatter();
     $formatter->includeStacktraces(true);
     $handler->setFormatter($formatter);
     $this->log->pushHandler($handler);
     $this->container = new Container(['dispatcher' => $this->dispatcher, 'log' => $this->log]);
 }
开发者ID:activecollab,项目名称:jobsqueue,代码行数:28,代码来源:TestCase.php


示例8: register

 public function register(Container $app)
 {
     $app['logger'] = function () use($app) {
         return $app['monolog'];
     };
     if ($bridge = class_exists('Symfony\\Bridge\\Monolog\\Logger')) {
         $app['monolog.handler.debug'] = function () use($app) {
             $level = MonologServiceProvider::translateLevel($app['monolog.level']);
             return new DebugHandler($level);
         };
         if (isset($app['request_stack'])) {
             $app['monolog.not_found_activation_strategy'] = function () use($app) {
                 return new NotFoundActivationStrategy($app['request_stack'], array('^/'), $app['monolog.level']);
             };
         }
     }
     $app['monolog.logger.class'] = $bridge ? 'Symfony\\Bridge\\Monolog\\Logger' : 'Monolog\\Logger';
     $app['monolog'] = function ($app) {
         $log = new $app['monolog.logger.class']($app['monolog.name']);
         $handler = new Handler\GroupHandler($app['monolog.handlers']);
         if (isset($app['monolog.not_found_activation_strategy'])) {
             $handler = new Handler\FingersCrossedHandler($handler, $app['monolog.not_found_activation_strategy']);
         }
         $log->pushHandler($handler);
         if ($app['debug'] && isset($app['monolog.handler.debug'])) {
             $log->pushHandler($app['monolog.handler.debug']);
         }
         return $log;
     };
     $app['monolog.formatter'] = function () {
         return new LineFormatter();
     };
     $app['monolog.handler'] = $defaultHandler = function () use($app) {
         $level = MonologServiceProvider::translateLevel($app['monolog.level']);
         $handler = new Handler\StreamHandler($app['monolog.logfile'], $level, $app['monolog.bubble'], $app['monolog.permission']);
         $handler->setFormatter($app['monolog.formatter']);
         return $handler;
     };
     $app['monolog.handlers'] = function () use($app, $defaultHandler) {
         $handlers = array();
         // enables the default handler if a logfile was set or the monolog.handler service was redefined
         if ($app['monolog.logfile'] || $defaultHandler !== $app->raw('monolog.handler')) {
             $handlers[] = $app['monolog.handler'];
         }
         return $handlers;
     };
     $app['monolog.level'] = function () {
         return Logger::DEBUG;
     };
     $app['monolog.listener'] = function () use($app) {
         return new LogListener($app['logger'], $app['monolog.exception.logger_filter']);
     };
     $app['monolog.name'] = 'app';
     $app['monolog.bubble'] = true;
     $app['monolog.permission'] = null;
     $app['monolog.exception.logger_filter'] = null;
     $app['monolog.logfile'] = null;
     $app['monolog.use_error_handler'] = !$app['debug'];
 }
开发者ID:abdonor,项目名称:silex_simple_api,代码行数:59,代码来源:MonologServiceProvider.php


示例9: getLogger

 /**
  * @return \Monolog\Logger
  */
 protected function getLogger()
 {
     $handler = new StreamHandler(storage_path('logs/api_request.log'), Logger::DEBUG);
     $handler->setFormatter(new LineFormatter(null, null, true, true));
     $logger = new Logger('ApiRequestLog');
     $logger->pushHandler($handler);
     return $logger;
 }
开发者ID:realshadow,项目名称:satis-control-panel,代码行数:11,代码来源:ConfigManager.php


示例10: getLogger

 public function getLogger($logger)
 {
     $formatter = new LineFormatter();
     $stream = new StreamHandler($_SERVER['DOCUMENT_ROOT'] . "tomata/app/logs/tomata.log");
     $stream->setFormatter($formatter);
     $logger->pushHandler($stream, Logger::INFO);
     return $logger;
 }
开发者ID:tonialcaide,项目名称:tomata,代码行数:8,代码来源:Util.php


示例11: getStreamHandlers

 /**
  * @param $logFolder
  *
  * @return StreamHandler[]
  */
 protected function getStreamHandlers($logFolder)
 {
     // create Monolog file stream
     $stream = new StreamHandler($logFolder . DIRECTORY_SEPARATOR . $this->getLogfileName());
     $stream->pushProcessor(array($this, 'streamProcessor'));
     $stream->setFormatter(new JSONFormatter());
     return [$stream];
 }
开发者ID:gavincsch,项目名称:jsonlogger,代码行数:13,代码来源:Loggable.php


示例12: getLogger

 /**
  * @return \Monolog\Logger
  */
 public function getLogger()
 {
     $handler = new StreamHandler(storage_path('logs/builder_sync.log'), Logger::DEBUG);
     $handler->setFormatter(new LineFormatter(null, null, true, true));
     $logger = new Logger('SyncBuildLog');
     $logger->pushHandler($handler);
     return $logger;
 }
开发者ID:realshadow,项目名称:satis-control-panel,代码行数:11,代码来源:SyncCommand.php


示例13: __construct

 private function __construct()
 {
     $fileName = sprintf('logs/hookbot-%s.log', Carbon::now()->format('Ymd'));
     $lineFormatter = new LineFormatter(null, null, true, true);
     $streamHandler = new StreamHandler(storage_path($fileName), MonoLogger::DEBUG);
     $streamHandler->setFormatter($lineFormatter);
     $this->logger = new MonoLogger('HookBot', [$streamHandler]);
 }
开发者ID:jshayes,项目名称:hookbot,代码行数:8,代码来源:Logger.php


示例14: createChannel

 /**
  * @param string $channel
  * @param string $level
  */
 private function createChannel($channel, $level)
 {
     $fileName = $this->appPath->getCacheDir() . 'logs/' . $channel . '.log';
     $logLevelConst = constant(\Monolog\Logger::class . '::' . strtoupper($level));
     $stream = new StreamHandler($fileName, $logLevelConst);
     $stream->setFormatter(new LineFormatter(null, null, true));
     $this->channels[$channel] = new \Monolog\Logger($channel, [$stream]);
 }
开发者ID:acp3,项目名称:core,代码行数:12,代码来源:Logger.php


示例15: registerLogging

 public function registerLogging()
 {
     $formatter = new LineFormatter(null, null, true, true);
     $stream = new StreamHandler(logdir() . 'error.log', Logger::ERROR);
     $stream->setFormatter($formatter);
     $this->log = new Logger('default');
     $this->log->pushHandler($stream);
 }
开发者ID:JanFoerste,项目名称:blivy,代码行数:8,代码来源:Exception.php


示例16: createLogger

 /**
  * Create a log
  *
  * @param string        $name      Name of the log
  * @param LineFormatter $formatter Formatting object for log entries
  * @param string        $output    Destination of the log entries (filename or stream)
  *
  * @return MonoLogger   $logger    Reference object to the logger created
  */
 private function createLogger($name, LineFormatter $formatter, $output)
 {
     $stream = new StreamHandler($output, MonoLogger::INFO);
     $stream->setFormatter($formatter);
     $logger = new MonoLogger($name);
     $logger->pushHandler($stream);
     return $logger;
 }
开发者ID:comodojo,项目名称:composer-events-handler,代码行数:17,代码来源:Logger.php


示例17: getHandler

 /**
  *
  * Get streamhandler
  * @param string $file
  * @param integer $level
  * @return \Monolog\Handler\StreamHandler
  */
 protected function getHandler($file, $level)
 {
     if (empty(self::$handler)) {
         $handler = new StreamHandler($file, $level);
         $handler->setFormatter($this->getCustomFormatter());
         self::$handler = $handler;
     }
     return self::$handler;
 }
开发者ID:victordiges,项目名称:Vatsimphp,代码行数:16,代码来源:Logger.php


示例18: createLogger

 /**
  * @param $name
  * @return Logger
  * @throws \Exception
  */
 public function createLogger($name)
 {
     $logger = new Logger($name);
     $stream = new StreamHandler($this->getFilePath($name), $this->getLogLevel($name));
     $stream->setFormatter(new LineFormatter("[%datetime%] [%level_name%] %message% %context%\n"));
     $logger->pushHandler($stream);
     $this->resetLogger($logger);
     return $logger;
 }
开发者ID:omerucel,项目名称:micro-sample-project,代码行数:14,代码来源:MonologHelper.php


示例19: register

 public function register()
 {
     $this->app->extend(LoggerInterface::class, function (Logger $log) {
         $handler = new StreamHandler('php://stdout', env("APP_LOGLEVEL", Logger::WARNING));
         $handler->setFormatter(new LineFormatter("%message%\n", null, true, true));
         $log->pushHandler($handler);
         return $log;
     });
 }
开发者ID:chatbox-inc,项目名称:heroku-php,代码行数:9,代码来源:HerokuLoggerServiceProvider.php


示例20: before

 public function before($param)
 {
     $logger = new Logger('Daemon');
     $file_log = $this->log_file;
     $handler = new StreamHandler($file_log, Logger::INFO);
     $handler->setFormatter(new LineFormatter(null, null, false, true));
     $logger->pushHandler($handler);
     $this->logger = $logger;
 }
开发者ID:glial,项目名称:pmacontrol,代码行数:9,代码来源:Agent.controller.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Handler\TestHandler类代码示例发布时间:2022-05-23
下一篇:
PHP Handler\SocketHandler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap