本文整理汇总了PHP中openlog函数的典型用法代码示例。如果您正苦于以下问题:PHP openlog函数的具体用法?PHP openlog怎么用?PHP openlog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了openlog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
/**
* Prepares use of logger.
*
* This method may be called to switch previous name of application. It
* might be called at any time as it's preventing multiple preparations
* internally.
*
* @param string $applicationName name of application to show in logs
*/
public static function prepare($applicationName = null)
{
if (!self::$prepared || $applicationName !== null && $applicationName !== self::$prepared) {
openlog($applicationName !== null ? "TXF.{$applicationName}" : 'TXF', LOG_NDELAY + LOG_PID, LOG_USER);
self::$prepared = $applicationName !== null ? $applicationName : true;
}
}
示例2: __construct
function __construct($_sFeaturePath, $_iPort = 16816)
{
openlog("cuke4php", LOG_PID, LOG_DAEMON);
if (is_file($_sFeaturePath)) {
$_sFeaturePath = dirname($_sFeaturePath);
}
if ($_iPort > 0) {
$this->iPort = $_iPort;
} else {
$this->iPort = 16816;
}
foreach (self::rglob("*.php", 0, $_sFeaturePath . "/support") as $sFilename) {
require_once $sFilename;
}
set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
require_once "Cucumber.php";
foreach (self::rglob("*.php", 0, $_sFeaturePath . "/step_definitions") as $sFilename) {
require_once $sFilename;
}
$this->aStepClasses = CucumberSteps::getSubclasses();
foreach ($this->aStepClasses as $sClass) {
$oReflection = new ReflectionClass($sClass);
$aMethods = $oReflection->getMethods();
foreach ($aMethods as $oMethod) {
$sComment = $oMethod->getDocComment();
$aMatches = array();
$aMethod = array();
$aMethod['method'] = $oMethod->name;
$aMethod['class'] = $oMethod->class;
$aMethod['filename'] = $oMethod->getFileName();
$aMethod['startline'] = $oMethod->getStartLine();
if (substr($oMethod->name, 0, 4) === "step") {
preg_match("/(?:Given|When|Then) (.+)\$/im", $sComment, $aMatches);
$aMethod['regexp'] = $aMatches[1];
$this->aWorld['steps'][] = $aMethod;
continue;
}
preg_match("/(@.+)/im", $sComment, $aMatches);
if (array_key_exists(1, $aMatches)) {
$aMethod['tags'] = explode(" ", str_replace("@", "", $aMatches[1]));
} else {
$aMethod['tags'] = array();
}
if (substr($oMethod->name, 0, 6) === "before") {
$this->aWorld['before'][] = $aMethod;
continue;
}
if (substr($oMethod->name, 0, 5) === "after") {
$this->aWorld['after'][] = $aMethod;
continue;
}
if (substr($oMethod->name, 0, 9) == "transform") {
preg_match("/(?:Transform) (.+)\$/im", $sComment, $aMatches);
$aMethod['regexp'] = $aMatches[1];
$this->aWorld['transform'][] = $aMethod;
continue;
}
}
}
}
示例3: __construct
function __construct(array $params = array())
{
if (isset($params['application'])) {
$this->_appName = $params['application'];
}
openlog($this->_appName, LOG_PID, LOG_USER);
}
示例4: __construct
/**
* Constructor.
*
* @param array &$options Log object options.
*
* @since 11.1
*/
public function __construct(array &$options)
{
// Call the parent constructor.
parent::__construct($options);
// Ensure that we have an identity string for the Syslog entries.
if (empty($this->options['sys_ident'])) {
$this->options['sys_ident'] = 'Joomla Platform';
}
// If the option to add the process id to Syslog entries is set use it, otherwise default to true.
if (isset($this->options['sys_add_pid'])) {
$this->options['sys_add_pid'] = (bool) $this->options['sys_add_pid'];
} else {
$this->options['sys_add_pid'] = true;
}
// If the option to also send Syslog entries to STDERR is set use it, otherwise default to false.
if (isset($this->options['sys_use_stderr'])) {
$this->options['sys_use_stderr'] = (bool) $this->options['sys_use_stderr'];
} else {
$this->options['sys_use_stderr'] = false;
}
// Build the Syslog options from our log object options.
$sysOptions = 0;
if ($this->options['sys_add_pid']) {
$sysOptions = $sysOptions | LOG_PID;
}
if ($this->options['sys_use_stderr']) {
$sysOptions = $sysOptions | LOG_PERROR;
}
// Open the Syslog connection.
openlog((string) $this->options['sys_ident'], $sysOptions, LOG_USER);
}
示例5: write
public function write(string $level, string $message)
{
$l = LOG_INFO;
$message = $this->interpolate($level, $message);
switch ($level) {
case 'emergency':
case 'alert':
case 'critical':
case 'error':
case 'warning':
$l = LOG_WARNING;
break;
case 'notice':
$l = LOG_NOTICE;
break;
case 'debug':
$l = LOG_DEBUG;
break;
default:
break;
}
if (\openlog($this->ident, LOG_PID, LOG_USER)) {
\syslog($l, $message);
}
}
示例6: open
/**
* Opens a connection to the system logger, if it has not already
* been opened. This is implicitly called by log(), if necessary.
* @access public
*/
function open()
{
if (!$this->_opened) {
$this->_opened = openlog($this->_ident, LOG_PID, $this->_name);
}
return $this->_opened;
}
示例7: __construct
function __construct($name = 'ykval')
{
$this->name = $name;
$this->fields = array();
$this->LOG_LEVELS = array(LOG_EMERG => 'LOG_EMERG', LOG_ALERT => 'LOG_ALERT', LOG_CRIT => 'LOG_CRIT', LOG_ERR => 'LOG_ERR', LOG_WARNING => 'LOG_WARNING', LOG_NOTICE => 'LOG_NOTICE', LOG_INFO => 'LOG_INFO', LOG_DEBUG => 'LOG_DEBUG');
openlog("ykval", LOG_PID, LOG_LOCAL0);
}
示例8: log
/**
* Write a log message to the log socket.
*
* @param int $priority The priority.
* @param string $message The message.
* @param string $ident Defaults to the ident set via setIdent()
* @param int $date Timestamp for log message. Defaults to now.
*
* @return \YapepBase\Syslog\LegacySyslogConnection
*
* @throws \YapepBase\Exception\SyslogException on error
* @throws \YapepBase\Exception\NotImplementedException if the date is set, because this implementation
* doesn't support it.
*/
public function log($priority, $message, $ident = null, $date = null)
{
$this->validatePriority($priority);
$this->validateIdent($ident);
if (!\is_null($date)) {
throw new NotImplementedException('PHP\'s internal syslog functions don\'t support passing the date');
}
if (!is_string($ident)) {
$ident = $this->ident;
}
if (!openlog($ident, $this->options, $this->facility)) {
throw new SyslogException('openlog() failed');
} else {
if (!syslog($priority, $message)) {
$e = new SyslogException('syslog() failed');
}
if (!closelog()) {
if (isset($e)) {
throw new SyslogException('syslog() and closelog() failed');
} else {
throw new SyslogException('closelog() failed');
}
} elseif (isset($e)) {
throw $e;
}
}
return $this;
}
示例9: processData
function processData()
{
$flag = false;
$firstName = $_POST['firstname'];
if (strlen($firstName) == 0) {
$flag = true;
}
$lastName = $_POST['lastname'];
if (strlen($lastName) == 0) {
$flag = true;
}
$emailAddress = $_POST['emailaddress'];
if (strlen($emailAddress) == 0) {
$flag = true;
}
if ($flag == false) {
openlog('php', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER | LOG_PERROR);
syslog(LOG_ERR, 'Error!');
syslog(LOG_INFO, "{$firstName} {$lastName} {$emailAddress}");
closelog();
echo "<style type='text/css'>#formContainer{display:none;}</style>";
echo "\n\t\t\t\t\t\t\t\t\t\t<h3 class='FormLabel'>SUCCESS!</h3>\n\t\t\t\t\t\t\t\t\t\tThank you for creating an account {$firstName} {$lastName}!\n\t\t\t\t\t\t\t\t\t\tA confirmation email has been sent to {$emailAddress}.\n\t\t\t\t\t\t\t\t\t\tOnce you receive this email please follow the instructions\n\t\t\t\t\t\t\t\t\t\tprovided to active your new account.\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<h6>This page will refresh in 10 seconds...</h6>\n\t\t\t\t\t\t\t\t\t";
header("refresh:10;url=index.php");
}
}
示例10: init
public static function init($ident, $facility)
{
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
self::$facilities['local0'] = LOG_LOCAL0;
self::$facilities['local1'] = LOG_LOCAL1;
self::$facilities['local2'] = LOG_LOCAL2;
self::$facilities['local3'] = LOG_LOCAL3;
self::$facilities['local4'] = LOG_LOCAL4;
self::$facilities['local5'] = LOG_LOCAL5;
self::$facilities['local6'] = LOG_LOCAL6;
self::$facilities['local7'] = LOG_LOCAL7;
}
if (array_key_exists(strtolower($facility), self::$facilities)) {
$facility = self::$facilities[strtolower($facility)];
} elseif (!in_array($facility, array_values(self::$facilities), true)) {
throw new \UnexpectedValueException('Unknown facility value "' . $facility . '"');
}
return function ($info) use($ident, $facility) {
if (!openlog($ident, LOG_PID, $facility)) {
throw new \LogicException('Can\'t open syslog for ident "' . $ident . '" and facility "' . $facility . '"');
}
syslog(Syslog::$levels[$info['level']], vsprintf('%1$s: %4$s', $info));
closelog();
};
}
示例11: logMessage
function logMessage($type, $level, $message)
{
global $debug;
global $use_syslog;
if ($use_syslog) {
define_syslog_variables();
if ($debug) {
}
if ($level == 0) {
$s_level = LOG_ERR;
} else {
if ($level == 1) {
$s_level = LOG_WARNING;
} else {
if ($level == 2) {
$s_level = LOG_INFO;
} else {
if ($level == 3) {
$s_level = LOG_DEBUG;
} else {
$s_level = LOG_ERR;
}
}
}
}
$s_message = $type . " " . $message;
openlog("restbot", LOG_PID, LOG_DAEMON);
syslog($s_level, $s_message);
closelog();
}
}
示例12: _log
function _log($text)
{
_trace($text);
openlog("alarm", LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog(LOG_DEBUG, var_export($text));
closelog();
}
示例13: __construct
/**
* class constructor opens syslog with passed log ident and options
*
* @error 12101
* @param string $ident expects log identifier
* @param int $facility expects optional bitmasked values
* @throws Xapp_Log_Writer_Exception
*/
public function __construct($ident = 'Xapp', $facility = LOG_USER)
{
$this->_ident = trim((string) $ident);
if (!openlog($this->_ident, LOG_CONS, $facility)) {
throw new Xapp_Log_Writer_Exception(_("unable to open sys log with passed parameters"), 1210101);
}
}
示例14: __construct
public function __construct()
{
$this->config = \Jelix\Core\App::config()->syslogLogger;
$this->catSyslog = array('error' => LOG_ERR, 'warning' => LOG_WARNING, 'notice' => LOG_NOTICE, 'deprecated' => LOG_NOTICE, 'strict' => LOG_NOTICE, 'debug' => LOG_DEBUG);
$ident = strtr($this->config['ident'], array('%sapi%' => php_sapi_name(), '%domain%' => \Jelix\Core\App::config()->domainName, '%pid%' => getmypid()));
openlog($ident, LOG_ODELAY | LOG_PERROR, $this->config['facility']);
}
示例15: writeLog
public function writeLog($message = null, $code = null)
{
if (empty($this->message) && empty($message)) {
return;
} else {
$this->message = $message;
}
if (empty($this->code) && empty($code)) {
$this->code = 0;
} else {
$this->code = $code;
}
if (openlog(LoggingConfig::LOG_IDENT, LOG_PID | LOG_CONS, LoggingConfig::LOG_FACILITY) === true) {
$entries = explode("\n", $this->message);
foreach ($entries as $entry) {
syslog(LOG_INFO, sprintf("(%s) [%s] %s %s %s - %s", $this->ip, $this->user, strtoupper($this->method), $this->code, $this->uri, $entry));
}
if (LoggingConfig::LOG_DEBUG == true && !empty($this->input) && $this->input != "null") {
syslog(LOG_DEBUG, sprintf("(%s) [%s] Input: %s", $this->ip, $this->user, $this->input));
}
if (LoggingConfig::LOG_DEBUG == true && !empty($this->output) && $this->output != "null") {
syslog(LOG_DEBUG, sprintf("(%s) [%s] Output: %s", $this->ip, $this->user, $this->output));
}
closelog();
} else {
trigger_error("Could not open syslog facility", E_USER_ERROR);
}
}