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


PHP StreamHandler::getFormatter方法代码示例

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


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

示例1: init

 public static function init()
 {
     if (!self::$logger instanceof Mlogger) {
         strtolower(C('LOG_TYPE')) == 'monolog' && C('SHOW_PAGE_TRACE', false);
         // 关闭, 以将日志记录到 \Think\Log::$log
         self::$logger = new Mlogger('Monolog');
         $handler = new StreamHandler(C('LOG_PATH') . date('y_m_d') . '.log', Logger::DEBUG);
         $handler->getFormatter()->allowInlineLineBreaks();
         $handler->getFormatter()->ignoreEmptyContextAndExtra();
         self::$logger->pushProcessor(new WebProcessor());
         self::$logger->pushHandler($handler);
         // 文件
     }
 }
开发者ID:snowair,项目名称:think-monolog,代码行数:14,代码来源:Logger.php

示例2: add_log

/** Add information to the log file */
function add_log($text, $function, $type = LOG_INFO, $projectid = 0, $buildid = 0, $resourcetype = 0, $resourceid = 0)
{
    global $CDASH_LOG_FILE, $CDASH_LOG_FILE_MAXSIZE_MB, $CDASH_LOG_LEVEL, $CDASH_TESTING_MODE;
    $level = to_psr3_level($type);
    if (($buildid === 0 || is_null($buildid)) && isset($GLOBALS['PHP_ERROR_BUILD_ID'])) {
        $buildid = $GLOBALS['PHP_ERROR_BUILD_ID'];
    }
    $context = array('function' => $function);
    if ($projectid !== 0 && !is_null($projectid)) {
        $context['project_id'] = $projectid;
    }
    if ($buildid !== 0 && !is_null($buildid)) {
        $context['build_id'] = strval($buildid);
    }
    if ($resourcetype !== 0 && !is_null($resourcetype)) {
        $context['resource_type'] = $resourcetype;
    }
    if ($resourceid !== 0 && !is_null($resourceid)) {
        $context['resource_id'] = $resourceid;
    }
    $minLevel = to_psr3_level($CDASH_LOG_LEVEL);
    if (!is_null($CDASH_LOG_FILE)) {
        // If the size of the log file is bigger than 10 times the allocated memory
        // we rotate
        $logFileMaxSize = $CDASH_LOG_FILE_MAXSIZE_MB * 100000;
        if (file_exists($CDASH_LOG_FILE) && filesize($CDASH_LOG_FILE) > $logFileMaxSize) {
            $tempLogFile = $CDASH_LOG_FILE . '.tmp';
            if (!file_exists($tempLogFile)) {
                rename($CDASH_LOG_FILE, $tempLogFile);
                // This should be quick so we can keep logging
                for ($i = 9; $i >= 0; $i--) {
                    // If we do not have compression we just rename the files
                    if (function_exists('gzwrite') === false) {
                        $currentLogFile = $CDASH_LOG_FILE . '.' . $i;
                        $j = $i + 1;
                        $newLogFile = $CDASH_LOG_FILE . '.' . $j;
                        if (file_exists($newLogFile)) {
                            cdash_unlink($newLogFile);
                        }
                        if (file_exists($currentLogFile)) {
                            rename($currentLogFile, $newLogFile);
                        }
                    } else {
                        $currentLogFile = $CDASH_LOG_FILE . '.' . $i . '.gz';
                        $j = $i + 1;
                        $newLogFile = $CDASH_LOG_FILE . '.' . $j . '.gz';
                        if (file_exists($newLogFile)) {
                            cdash_unlink($newLogFile);
                        }
                        if (file_exists($currentLogFile)) {
                            $gz = gzopen($newLogFile, 'wb');
                            $f = fopen($currentLogFile, 'rb');
                            while ($f && !feof($f)) {
                                gzwrite($gz, fread($f, 8192));
                            }
                            fclose($f);
                            unset($f);
                            gzclose($gz);
                            unset($gz);
                        }
                    }
                }
                // Move the current backup
                if (function_exists('gzwrite') === false) {
                    rename($tempLogFile, $CDASH_LOG_FILE . '.0');
                } else {
                    $gz = gzopen($CDASH_LOG_FILE . '.0.gz', 'wb');
                    $f = fopen($tempLogFile, 'rb');
                    while ($f && !feof($f)) {
                        gzwrite($gz, fread($f, 8192));
                    }
                    fclose($f);
                    unset($f);
                    gzclose($gz);
                    unset($gz);
                    cdash_unlink($tempLogFile);
                }
            }
        }
        $pid = getmypid();
        if ($pid !== false) {
            $context['pid'] = getmypid();
        }
    }
    if (Registry::hasLogger('cdash') === false) {
        if ($CDASH_LOG_FILE === false) {
            $handler = new SyslogHandler('cdash', LOG_USER, $minLevel);
            $handler->getFormatter()->ignoreEmptyContextAndExtra();
        } else {
            if ($CDASH_TESTING_MODE) {
                $filePermission = 0666;
            } else {
                $filePermission = 0664;
            }
            $handler = new StreamHandler($CDASH_LOG_FILE, $minLevel, true, $filePermission);
            $handler->getFormatter()->allowInlineLineBreaks();
            $handler->getFormatter()->ignoreEmptyContextAndExtra();
        }
        $logger = new Logger('cdash');
//.........这里部分代码省略.........
开发者ID:kitware,项目名称:cdash,代码行数:101,代码来源:log.php

示例3: getFormatter

 public function getFormatter()
 {
     return $this->streamHandler->getFormatter();
 }
开发者ID:surfnet,项目名称:stepup-bundle,代码行数:4,代码来源:PrimaryLogHandler.php


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