本文整理汇总了PHP中Monolog\Handler\RotatingFileHandler类的典型用法代码示例。如果您正苦于以下问题:PHP RotatingFileHandler类的具体用法?PHP RotatingFileHandler怎么用?PHP RotatingFileHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RotatingFileHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getPhealLogger
/**
* @return \Monolog\Logger
*/
private function getPhealLogger()
{
// If its already setup, just return it.
if (!is_null($this->logger)) {
return $this->logger;
}
// Configure the logger by setting the logfile
// path and the format logs should be.
$log_file = storage_path('logs/pheal.log');
$format = new LineFormatter(null, null, false, true);
$stream = new RotatingFileHandler($log_file, 30, Logger::INFO);
$stream->setFormatter($format);
$this->logger = new Logger('pheal');
$this->logger->pushHandler($stream);
return $this->logger;
}
开发者ID:eveseat,项目名称:eveapi,代码行数:19,代码来源:PhealSetup.php
示例17: addLogger
public function addLogger($name, $logToSystemFile = true)
{
if (!empty($this->loggers[$name])) {
return;
}
$this->setFormatter();
$this->loggers[$name] = new Logger($name);
if ($logToSystemFile === true) {
$filename = ROOT_PATH . "/log/" . LogService::$system_logger . ".log";
} else {
$filename = ROOT_PATH . "/log/{$name}.log";
}
$handler = new RotatingFileHandler($filename);
$handler->setFormatter($this->formatter);
// $handler->setFormatter(new JsonFormatter());
$this->loggers[$name]->pushHandler($handler);
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:17,代码来源:LogService.php
示例18: register
public function register(Application $app)
{
$app->register(new \Silex\Provider\MonologServiceProvider());
$app['monolog.handler'] = function () use($app) {
$levels = Logger::getLevels();
if ($app['debug']) {
$level = Logger::DEBUG;
} else {
$level = $app['config']['log']['log_level'];
}
$RotateHandler = new RotatingFileHandler($app['monolog.logfile'], $app['config']['log']['max_files'], $level);
$RotateHandler->setFilenameFormat($app['config']['log']['prefix'] . '{date}' . $app['config']['log']['suffix'], $app['config']['log']['format']);
$RotateHandler->setFormatter(new LineFormatter(null, null, true));
$FingerCrossedHandler = new FingersCrossedHandler($RotateHandler, new ErrorLevelActivationStrategy($levels[$app['config']['log']['action_level']]));
return $FingerCrossedHandler;
};
$app['listener.requestdump'] = $app->share(function ($app) {
return new \Eccube\EventListener\RequestDumpListener($app);
});
}
开发者ID:hiroyasu55,项目名称:ec-cube,代码行数:20,代码来源:EccubeMonologServiceProvider.php
示例19: register
public function register(Container $app)
{
$app['logger'] = function () use($app) {
return $app['monolog'];
};
$app['monolog'] = function ($app) {
$logger = new Logger($app['monolog.name']);
$rotate = $app['config']->get('app.log.rotate', 'single');
$logger->pushHandler($app['monolog.handler.' . $rotate]);
return $logger;
};
$app['monolog.formatter'] = function () {
return new LineFormatter();
};
$app['monolog.handler.single'] = function ($app) {
$handler = new StreamHandler($app['monolog.logfile'], $app['monolog.level']);
$handler->setFormatter($app['monolog.formatter']);
return $handler;
};
$app['monolog.handler.daily'] = function ($app) {
$maxFiles = $app['config']->get('app.log.max_files', 5);
$handler = new RotatingFileHandler($app['monolog.logfile'], $maxFiles, $app['monolog.level']);
$handler->setFormatter($app['monolog.formatter']);
return $handler;
};
$app['monolog.handler.error'] = function ($app) {
$handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $app['monolog.level']);
$handler->setFormatter($app['monolog.formatter']);
return $handler;
};
$app['monolog.handler.syslog'] = function ($app) {
$handler = new SyslogHandler($app['monolog.name'], LOG_USER, $app['monolog.level']);
$handler->setFormatter($app['monolog.formatter']);
return $handler;
};
$level = $app['config']->get('app.log.level', 'debug');
$app['monolog.level'] = $this->parseLevel($level);
$app['monolog.logfile'] = $app['path.logs'] . $this->getSettings('app.log.logfile');
$app['monolog.name'] = $this->getSettings('monolog.name', 'app.name');
}
开发者ID:speedwork,项目名称:framework,代码行数:40,代码来源:MonologServiceProvider.php
示例20: __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
*/
public function __construct($name, array $handlers = array(), array $processors = array())
{
parent::__construct($name, $handlers, $processors);
// set handler
$elgg_log_level = _elgg_services()->logger->getLevel();
if ($elgg_log_level == \Elgg\Logger::OFF) {
// always log errors
$elgg_log_level = \Elgg\Logger::ERROR;
}
$handler = new RotatingFileHandler(elgg_get_data_path() . 'elasticsearch/client.log', 0, $elgg_log_level);
// create correct folder structure
$date = date('Y/m/');
$path = elgg_get_data_path() . "elasticsearch/{$date}";
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
$handler->setFilenameFormat('{date}_{filename}', 'Y/m/d');
$this->pushHandler($handler);
// set logging processor
$processor = new IntrospectionProcessor();
$this->pushProcessor($processor);
}
开发者ID:coldtrick,项目名称:elasticsearch,代码行数:27,代码来源:DatarootLogger.php
注:本文中的Monolog\Handler\RotatingFileHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论