當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Handler\RotatingFileHandler類代碼示例

本文整理匯總了PHP中Monolog\Handler\RotatingFileHandler的典型用法代碼示例。如果您正苦於以下問題:PHP RotatingFileHandler類的具體用法?PHP RotatingFileHandler怎麽用?PHP RotatingFileHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RotatingFileHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($name = 'PHPUnit', $level = 'debug')
 {
     /**
      * Filter growl notifications and send only
      * - test failures ($handerLevel = Logger::NOTICE; see GrowlHandler constructor)
      * - summary of test suites (message "Results OK ...", or "Results KO ..."
      */
     $filters = array(function ($record, $handlerLevel) {
         if ($record['level'] > $handlerLevel) {
             return true;
         }
         return preg_match('/^Results/', $record['message']) === 1;
     });
     $stream = new RotatingFileHandler(__DIR__ . DIRECTORY_SEPARATOR . 'monologTestListener.log', 0, Logger::toMonologLevel($level));
     $stream->setFilenameFormat('{filename}-{date}', 'Ymd');
     $handlers = array($stream);
     try {
         // be notified only for test suites and test failures
         $growl = new GrowlHandler(array(), Logger::NOTICE);
         $handlers[] = new CallbackFilterHandler($growl, $filters);
     } catch (\Exception $e) {
         // Growl server is probably not started
         echo $e->getMessage(), PHP_EOL, PHP_EOL;
     }
     parent::__construct($name, $handlers);
 }
開發者ID:jclaveau,項目名稱:phpunit-LoggerTestListener,代碼行數:26,代碼來源:bootstrap.monolog.php

示例2: terminate

 public function terminate($request, $response)
 {
     $log = new Logger('HTTP');
     $handler = new RotatingFileHandler(config('laravelmiddlewarelogger.options.file'), Logger::INFO);
     $handler->setFormatter(new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context%\n\n"));
     $log->pushHandler($handler);
     if (config('laravelmiddlewarelogger.options.enabled')) {
         $inputs = $request->input();
         if (!empty($inputs)) {
             $inputSafe = config('laravelmiddlewarelogger.options.input_safe');
             foreach ($inputSafe as $safe) {
                 if (!empty($inputs[$safe])) {
                     $inputs[$safe] = '[*** SENSOR ***]';
                 }
             }
         }
         $request_array = ['method' => $request->method(), 'full-url' => $request->fullUrl(), 'client-ip' => $request->ip(), 'user-agent' => $request->header('user-agent'), 'query-string' => $request->query(), 'inputs' => $inputs];
         $response_array = [];
         if (config('laravelmiddlewarelogger.options.log_response')) {
             $response_array = ['status' => $response->status(), 'content' => ''];
             json_decode($response->content());
             if (json_last_error() == JSON_ERROR_NONE) {
                 $response_array['content'] = $response->content();
             }
         }
         $log->addInfo('REQUEST', $request_array);
         $log->addInfo('RESPONSE', $response_array);
     }
 }
開發者ID:quintet-solutions,項目名稱:laravel-middleware-logger,代碼行數:29,代碼來源:LogAfterRequest.php

示例3: testReuseCurrentFile

 public function testReuseCurrentFile()
 {
     $log = __DIR__ . '/Fixtures/foo-' . date('Y-m-d') . '.rot';
     file_put_contents($log, "foo");
     $handler = new RotatingFileHandler(__DIR__ . '/Fixtures/foo.rot');
     $handler->write(array('message' => 'test'));
     $this->assertEquals('footest', file_get_contents($log));
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:8,代碼來源:RotatingFileHandlerTest.php

示例4: setHande

 private function setHande()
 {
     date_default_timezone_set("PRC");
     self::$log = new Logger('name');
     $rotating = new RotatingFileHandler($this->filepath, $this->log_keepDays, $this->log_level);
     $rotating->setFormatter($this->formatter);
     self::$log->pushHandler($rotating);
 }
開發者ID:eSDK,項目名稱:esdk_obs_native_php,代碼行數:8,代碼來源:S3Log.php

示例5: configureFileLogs

 public static function configureFileLogs(Monolog $monolog, $filePath)
 {
     $files = new RotatingFileHandler($filePath, 365, Logger::DEBUG, true, 0666);
     $files->setFormatter(new HtmlFormatter());
     $files->pushProcessor(new WebProcessor());
     $files->pushProcessor(new IntrospectionProcessor(Logger::DEBUG));
     $monolog->pushHandler($files);
 }
開發者ID:swayok,項目名稱:laravel-extended-errors,代碼行數:8,代碼來源:ConfigureLogging.php

示例6: init

 public static function init($channel, $filename)
 {
     $logger = new MongoLog($channel);
     $stream = new RotatingFileHandler($filename, 0, MongoLog::DEBUG);
     $stream->setFormatter(new LineFormatter("%datetime% [%channel%] %level_name% %message% %context%\n", "Y-m-d H:i:s"));
     $logger->pushHandler($stream);
     static::$object = $logger;
 }
開發者ID:bileji,項目名稱:async,代碼行數:8,代碼來源:Logger.php

示例7: __construct

 /**
  * Class constructor
  *
  * @param string $loggerName Logger name (the logging channel)
  * @param int $logLevel The minimum logging level at logging handler will be triggered
  * @param string $fileName Log file name
  */
 private function __construct($loggerName = DEFAULT_LOGGER_NAME, $logLevel = MIN_LOG_LEVEL, $fileName = DEFAULT_LOG_PATH . DEFAULT_LOG_FILE)
 {
     $fullLogFilePath = $fileName;
     $formatter = new LineFormatter(null, null, false, true);
     $this->_logger = new Logger($loggerName);
     $handler = new RotatingFileHandler($fullLogFilePath, MAX_LOG_FILES_TO_KEEP, $logLevel);
     $handler->setFormatter($formatter);
     $this->_logger->pushHandler($handler);
 }
開發者ID:storou,項目名稱:storou,代碼行數:16,代碼來源:Log.php

示例8: logger

 private function logger()
 {
     $log = new Logger("slim");
     $formatter = new LineFormatter("[%datetime%] [%level_name%]: %message%\n");
     $rotating = new RotatingFileHandler(__DIR__ . "/../../logs/slim.log", 0, Logger::DEBUG);
     $rotating->setFormatter($formatter);
     $log->pushHandler($rotating);
     return new MonologSQLLogger($log);
 }
開發者ID:lacteosdelcesar,項目名稱:s3-untitledApi-K,代碼行數:9,代碼來源:EntityManager.php

示例9: testReuseCurrentFile

 public function testReuseCurrentFile()
 {
     $log = __DIR__ . '/Fixtures/foo-' . date('Y-m-d') . '.rot';
     file_put_contents($log, "foo");
     $handler = new RotatingFileHandler(__DIR__ . '/Fixtures/foo.rot');
     $handler->setFormatter($this->getIdentityFormatter());
     $handler->handle($this->getRecord());
     $this->assertEquals('footest', file_get_contents($log));
 }
開發者ID:qasem2rubik,項目名稱:laravel,代碼行數:9,代碼來源:RotatingFileHandlerTest.php

示例10: addDefaultLoggerDataProvider

 /**
  * @return array
  */
 public function addDefaultLoggerDataProvider()
 {
     $logHandler1 = new RotatingFileHandler(Http::DEFAULT_LOG_FILE_NAME);
     $logHandler1->setFormatter(new LineFormatter(Http::DEFAULT_LOG_LINE_FORMAT, null, true));
     $logHandler2 = new RotatingFileHandler('fileName');
     $logHandler2->setFormatter(new LineFormatter('%message%', null, true));
     return ['Default params' => ['fileName' => null, 'lineFormat' => null, 'messageFormat' => null, 'logLevel' => LogLevel::INFO, 'logger' => new Logger('Logger', [$logHandler1]), 'messageFormatter' => new MessageFormatter(Http::DEFAULT_LOG_MESSAGE_FORMAT), 'middlewareCallback' => function () {
     }], 'Custom params' => ['fileName' => 'fileName', 'lineFormat' => '%message%', 'messageFormat' => '{code}', 'logLevel' => LogLevel::NOTICE, 'logger' => new Logger('Logger', [$logHandler2]), 'messageFormatter' => new MessageFormatter('{code}'), 'middlewareCallback' => function () {
     }]];
 }
開發者ID:subscribepro,項目名稱:subscribepro-php,代碼行數:13,代碼來源:HttpTest.php

示例11: configureLogger

 private function configureLogger()
 {
     $dateFormat = 'Y-m-d H:i:s';
     $logFormat = "%datetime% %level_name% |[%codeInfo%] %message%\n";
     $formatter = new LineFormatter($logFormat, $dateFormat);
     $rotatingLogger = new RotatingFileHandler($this->logPath, 30);
     $rotatingLogger->setFormatter($formatter);
     $this->pushHandler($rotatingLogger);
     $this->pushProcessor(new IntrospectionProcessor());
 }
開發者ID:jwyuen,項目名稱:dotslash,代碼行數:10,代碼來源:DotLogger.php

示例12: getLogger

 /**
  * Here it's using Monolog for writing logs
  *
  * @param int  $level  Log level
  *
  * @return \Monolog\Logger
  */
 public static function getLogger($level = Logger::DEBUG)
 {
     $config = self::getConfig();
     $logger = new Logger($config['log']['channelName']);
     if (!is_dir($config['log']['baseDirectory'])) {
         mkdir($config['log']['baseDirectory'], 0777);
     }
     $handler = new RotatingFileHandler($config['log']['baseDirectory'] . 'messages.log', $config['log']['maxFilesRotation'], $level);
     $handler->setFormatter(new LineFormatter($config['log']['format']));
     $logger->pushHandler($handler);
     return $logger;
 }
開發者ID:arkanmgerges,項目名稱:tasker,代碼行數:19,代碼來源:Helper.php

示例13: createLogger

 /**
  * @param string $stream
  * @param string $path
  * @param mixed $level
  * @param string $format
  * @param $errorPath
  * @return LoggerInterface
  */
 protected function createLogger($stream, $path, $level, $format, $errorPath)
 {
     $defaultHandler = new RotatingFileHandler($path, 0, $level);
     $defaultHandler->setFormatter(new LineFormatter($format));
     $logger = new MonologWrapper($stream, array($defaultHandler));
     if ($path !== $errorPath) {
         $errorHandler = new RotatingFileHandler($errorPath, 0, Logger::ERROR);
         $errorHandler->setFormatter(new LineFormatter($format));
         $logger->pushHandler($errorHandler);
     }
     return $logger;
 }
開發者ID:qshurick,項目名稱:logger,代碼行數:20,代碼來源:Monolog.php

示例14: getJobLogger

 /**
  * @return Logger
  */
 protected function getJobLogger()
 {
     $jobLogger = new Logger('Jobs');
     $lineFormatter = new LineFormatter("[%datetime%] %message% %context% %extra%\n", null, true, true);
     $streamHandler = new StreamHandler("php://output");
     $streamHandler->setFormatter($lineFormatter);
     $jobLogger->pushHandler($streamHandler);
     $fileHandler = new RotatingFileHandler(storage_path() . '/logs/jobs.log');
     $fileHandler->setFormatter($lineFormatter);
     $jobLogger->pushHandler($fileHandler);
     $jobLogger->debug(static::class);
     return $jobLogger;
 }
開發者ID:antriver,項目名稱:ctrlv-api,代碼行數:16,代碼來源:Job.php

示例15: __construct

 public function __construct()
 {
     $this->path = MAIN_DIRECTORY . DIRECTORY_SEPARATOR . 'log';
     if (!is_dir($this->path)) {
         File::createDirectory($this->path, $this->dirMode, true);
     }
     $this->logFile = $this->path . DIRECTORY_SEPARATOR . 'app.log';
     $this->log = new Logger('app');
     $webProcessor = new WebProcessor();
     $format = "[%datetime%] %channel%.%level_name%: %message% %extra.ip% %extra.http_method% %context% %extra%\n";
     $formatter = new LineFormatter($format, null, true);
     $logRotate = new RotatingFileHandler($this->logFile, 45, Logger::INFO, true, 0777);
     $logRotate->setFormatter($formatter);
     $this->log->pushHandler($logRotate);
     $this->log->pushProcessor($webProcessor);
 }
開發者ID:visionp,項目名稱:TestFramework,代碼行數:16,代碼來源:Log.php


注:本文中的Monolog\Handler\RotatingFileHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。