本文整理汇总了PHP中syslog函数的典型用法代码示例。如果您正苦于以下问题:PHP syslog函数的具体用法?PHP syslog怎么用?PHP syslog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了syslog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_instance
function get_instance($id, $name)
{
global $KERNEL_INFO_TABLE;
$db = openqrm_get_db_connection();
if ("{$id}" != "") {
$kernel_array = $db->Execute("select * from {$KERNEL_INFO_TABLE} where kernel_id={$id}");
} else {
if ("{$name}" != "") {
$kernel_array = $db->Execute("select * from {$KERNEL_INFO_TABLE} where kernel_name='{$name}'");
} else {
$this->__event->log("get_instance", $_SERVER['REQUEST_TIME'], 2, "kernel.class.php", "Could not create instance of kernel without data", "", "", 0, 0, 0);
foreach (debug_backtrace() as $key => $msg) {
syslog(LOG_ERR, $msg['function'] . '() ' . basename($msg['file']) . ':' . $msg['line']);
}
return;
}
}
foreach ($kernel_array as $index => $kernel) {
$this->id = $kernel["kernel_id"];
$this->name = $kernel["kernel_name"];
$this->version = $kernel["kernel_version"];
$this->capabilities = $kernel["kernel_capabilities"];
$this->comment = $kernel["kernel_comment"];
}
return $this;
}
示例2: 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);
}
}
示例3: save
function save($filename, $image_type = IMAGETYPE_JPEG, $compression = 80)
{
if (!$this->image) {
return false;
}
if ($image_type == -1) {
// Save in the same format
$image_type = $this->image_type;
}
switch ($image_type) {
case IMAGETYPE_JPEG:
$res = imagejpeg($this->image, $filename, $compression);
break;
case IMAGETYPE_GIF:
$res = imagegif($this->image, $filename);
break;
case IMAGETYPE_PNG:
$res = imagepng($this->image, $filename);
break;
default:
syslog(LOG_INFO, "IMAGE not type found: {$image_type}");
return false;
}
if ($res) {
return true;
} else {
return false;
}
}
示例4: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
if (!openlog($this->ident, $this->logopts, $this->facility)) {
throw new \LogicException('Can\'t open syslog for ident "' . $this->ident . '" and facility "' . $this->facility . '"');
}
syslog($this->logLevels[$record['level']], (string) $record['formatted']);
}
示例5: saveContacts
function saveContacts($contacts)
{
global $contacts_file;
// parse permissions
if (!file_exists($contacts_file)) {
echo 'error: notes file ' . $contacts_file . ' does not exist';
return;
}
if (!is_writable($contacts_file)) {
echo 'error: cannot write projects file (' . $contacts_file . ')';
return;
}
// lets sort the contacts alphabetically first
//sort($contacts);
//echo ("{ \"message\": \"save these values: " . join($contacts) . "\"}");
// be more careful here, we need to write first to a new file, make sure that this
// works and copy the result over to the pw_file
$testfn = $contacts_file . '_test';
file_put_contents($testfn, json_encode($contacts, JSON_PRETTY_PRINT));
if (filesize($testfn) > 0) {
// seems to have worked, now rename this file to pw_file
rename($testfn, $contacts_file);
} else {
syslog(LOG_EMERG, 'error: could not write file into ' . $testfn);
}
}
示例6: fwLog
function fwLog($str)
{
global $STDIN, $STDOUT, $STDERR;
$lfstat = @stat("/tmp/firewall.log");
if (is_array($lfstat) && $lfstat['size'] > 1048576) {
// Logfile is over 1mb
@unlink("/tmp/firewall.log.old");
rename("/tmp/firewall.log", "/tmp/firewall.log.old");
// This is so hacky.
if (is_resource($STDIN)) {
fclose($STDIN);
fclose($STDOUT);
fclose($STDERR);
$STDIN = fopen('/dev/null', 'r');
$STDOUT = fopen('/tmp/firewall.log', 'ab');
$STDERR = fopen('/tmp/firewall.err', 'ab');
}
print "Rotated Log\n";
}
print time() . ": {$str}\n";
// No need to write to the logfile, as we're sending it there already by the print
// $fh = fopen("/tmp/firewall.log", "a");
// fwrite($fh, time().": $str\n");
syslog(LOG_WARNING | LOG_LOCAL0, $str);
}
示例7: Debuglogs
function Debuglogs($text = null, $function = null, $line = null)
{
if (!$GLOBALS["DEBUG"]) {
return;
}
if ($text == null) {
return;
}
$linetext = null;
if ($function == null) {
if (function_exists("debug_backtrace")) {
$trace = @debug_backtrace();
}
if (is_array($trace)) {
$filename = basename($trace[1]["file"]);
$function = $trace[1]["function"];
$line = $trace[1]["line"];
}
}
$linetext = $text;
if ($function != null) {
$linetext = "{$function}/{$line} {$linetext}";
} else {
if ($line != null) {
$linetext = "{$line} {$linetext}";
}
}
if (function_exists("syslog")) {
$LOG_SEV = LOG_INFO;
openlog("error_page", LOG_PID, LOG_SYSLOG);
syslog($LOG_SEV, $linetext);
closelog();
}
}
示例8: logEvent
function logEvent($logLine, $logType = LOG_INFO)
{
global $logFile, $useSysLog, $logFd, $auth;
$attr = array();
if (isset($auth['name'])) {
$attr[] = $auth['name'];
}
if (isset($_SERVER['REMOTE_ADDR'])) {
$attr[] = $_SERVER['REMOTE_ADDR'];
}
if (count($attr)) {
$logLine = '[' . implode(", ", $attr) . '] ' . $logLine;
}
if ($logType == LOG_ERR) {
$logLine = 'error: ' . $logLine;
}
if ($useSysLog) {
syslog($logType, $logLine);
} elseif (!isset($logFd)) {
if ($logType == LOG_ERR) {
error_log('DL: ' . $logLine);
}
} else {
$logLine = "[" . date(DATE_W3C) . "] {$logLine}\n";
flock($logFd, LOCK_EX);
fseek($logFd, 0, SEEK_END);
fwrite($logFd, $logLine);
fflush($logFd);
flock($logFd, LOCK_UN);
}
}
示例9: log
public function log()
{
$argsNum = func_num_args();
if ($argsNum < 2) {
return false;
}
$args = func_get_args();
$priority = $args[0];
$message = $args[1];
if ($priority > $this->allowPriority) {
return false;
}
$priorityName = $this->getLevelName($priority);
$strLog = '';
if ($priorityName) {
$strLog = "[{$priorityName}]";
}
$strLog .= "{$message}";
for ($i = 2; $i < $argsNum; $i++) {
$strLog .= $args[$i];
}
openlog('SPF', LOG_PID, LOG_USER);
syslog($priority, $strLog);
closelog();
}
示例10: SetElements
public function SetElements($id, $elements)
{
$es = (array) $elements;
foreach ($es as $a) {
// Force as an array
$a = (array) $a;
// Preprocessing
$a['form_id'] = $id;
// If id = 0, process as new entry
if ((int) $a['id'] == 0) {
syslog(LOG_DEBUG, "SetElements: adding new address for {$id}");
$GLOBALS['sql']->load_data($a);
$query = $GLOBALS['sql']->insert_query('xmr_element', $this->element_keys);
$GLOBALS['sql']->query($query);
} else {
if ($a['altered']) {
syslog(LOG_DEBUG, "SetElements: modifying address for form {$id}, id = " . $a['id']);
$GLOBALS['sql']->load_data($a);
$query = $GLOBALS['sql']->update_query('xmr_element', $this->element_keys, array('id' => $a['id']));
$GLOBALS['sql']->query($query);
}
}
}
return true;
}
示例11: log
public function log($err)
{
if (!is_string($err['message'])) {
$err['message'] = print_r($err['message'], true);
}
syslog(LOG_WARNING, 'error in file: ' . $err['file'] . ' (line ' . $err['line'] . '). ' . $err['message']);
}
示例12: log_debug
static function log_debug($msg, $skip_trace = 1)
{
if (strlen(Config::get('app.loglevel')) < 5) {
return;
}
syslog(LOG_DEBUG, Util::get_trace($skip_trace) . $msg);
}
示例13: syslog_msg
/**
* Verify that syslog logging is activated in the config via the
* debug->syslog variable and does a call to the syslog() function is it
* is true.
*
* @param emergency Syslog emergency.
* @param log_string String to log.
*/
function syslog_msg($emergency, $log_string)
{
if (!function_exists('syslog') || !isset($_SESSION[APPCONFIG]) || !$_SESSION[APPCONFIG]->getValue('debug', 'syslog')) {
return;
}
return syslog($emergency, $log_string);
}
示例14: 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");
}
}
示例15: output
protected function output($level, $msg)
{
// map logging levels to syslog priority levels
$priorities = array(LogLevel::EMERGENCY => LOG_EMERG, LogLevel::ALERT => LOG_ALERT, LogLevel::CRITICAL => LOG_CRIT, LogLevel::ERROR => LOG_ERR, LogLevel::WARNING => LOG_WARNING, LogLevel::NOTICE => LOG_NOTICE, LogLevel::INFO => LOG_INFO, LogLevel::DEBUG => LOG_DEBUG);
$priority = isset($priorities[$level]) ? $priorities[$level] : LOG_INFO;
syslog($priority, $this->prefix . $msg);
}